This Vape Web Server Is Not Vaporware

Bogdan Ionescu has turned a disposable vape with an Arm Cortex-M0+ microcontroller into a web server that is perfect for personal projects.

nickbild
about 18 hours ago Upcycling
This old vape was turned into a web server (📷: Bogdan Ionescu)

With all of the home automation systems and personal project websites that electronics and software hobbyists build in their free time, they start to really add up. Before they know it, they might have a closet full of single-board computers serving up ancient web applications that have not been touched since the introduction of the iPod’s click wheel. After all that time, that hardware might be starting to lose its steam.

Upgrading to new single-board computers might be the most sensible option, but Bogdan Ionescu has come up with a more interesting way to help that hardware get its steam (or rather, aerosol) back. Ionescu has proven that the ridiculously overpowered disposable vapes that litter parking lots everywhere, of all things, can make perfectly fine web servers — as long as you don’t need to push them too hard.

For years, Ionescu had been collecting disposable vapes to salvage the batteries. But as the devices became more sophisticated, he started to consider what other hardware could be repurposed. Inside newer vapes, instead of the expected epoxy-blobbed ASICs, he discovered microcontrollers from PUYA. These particular chips, in the PY32 series, feature a 24 MHz Arm Cortex-M0+ CPU, 24 KB of flash storage, and 3 KB of RAM. That may not be a lot of power, but it is hardly worthy of being called “disposable.”

There were resources to spare (📷: Bogdan Ionescu)

The idea of using one of these vapes as a web server came after experimenting with semihosting, which is a debugging feature that allows an embedded microcontroller to pass system calls through to a host machine. By chaining semihosting with old-school SLIP (Serial Line Internet Protocol), Ionescu was able to trick Linux into treating the vape like a dial-up modem. From there, he could transmit and receive real IP packets by running uIP, a lightweight TCP/IP stack designed for memory-constrained systems.

At first, the results were quite awful, with pings of 1.5 seconds, 50% packet loss, and web pages that took more than 20 seconds to load. But the bottleneck turned out to be the byte-by-byte handling of SLIP packets. By adding a ring buffer to cache reads and batching writes, Ionescu unleashed the vape’s full potential. With that, pings dropped to 20 ms, packet loss vanished, and full web pages loaded in around 160 ms.

With just under 1.4 KB of RAM consumed, there was still room to run other small tasks, and only about 20% of flash storage was used. That left enough space to host his entire blog post and even add a simple JSON API reporting page request counts and the device’s unique ID.

Of course, this is not going to replace data centers anytime soon. Twenty kilobytes of storage does not leave much room for any web frameworks, and the setup depends on a connected debugger. Still, the experiment shows just how much hidden computing power exists in everyday gadgets that are designed to be thrown away.

nickbild

R&D, creativity, and building the next big thing you never knew you wanted are my specialties.

Latest Articles