Hosting a Website on a Disposable Vape | DIY Web Server

 Disposable vapes have become surprisingly advanced in recent years. Many now include USB-C ports, rechargeable batteries, and embedded microcontrollers. Instead of tossing them away, I’ve been salvaging parts from these devices for hobby projects.

Hosting a Website on a Disposable Vape | DIY Web Server

Recently, while tearing one down, I discovered something unusual — not the usual epoxy-covered ASIC, but a tiny microcontroller labeled PUYA. These are ARM Cortex-M0+ chips with enough flash and RAM to run small programs. That got me thinking: could I host a web server on a disposable vape?

Turns out, the answer is yes.

Inside the Vape: The Hardware

The chip I found was marked PUYA C642F15, which turned out to be part of the PY32 family of microcontrollers.

Here are the specs I worked with:

  • 24MHz ARM Cortex-M0+
  • 24KB Flash
  • 3KB RAM
  • A handful of peripherals

On paper, this looks laughably underpowered. But with the right software stack, it’s just enough to host a tiny HTTP server.

Getting Online

Since the vape doesn’t have Wi-Fi or Ethernet, the solution came through semihosting.

Semihosting allows ARM microcontrollers to make syscalls by passing values through registers and triggering a breakpoint. Normally, this is used for debugging, but with some creativity, you can tunnel data in both directions.

To emulate a network connection, I used SLIP (Serial Line Internet Protocol) over a virtual TTY. Linux still supports SLIP, and tools like slattach and socat make it possible to bridge serial data into TCP/IP.

pyocd gdb -S -O semihost_console_type=telnet -T $(PORT) $(PYOCDFLAGS) & socat PTY,link=$(TTY),raw,echo=0 TCP:localhost:$(PORT),nodelay & sudo slattach -L -p slip -s 115200 $(TTY) & sudo ip addr add 192.168.190.1 peer 192.168.190.2/24 dev sl0 sudo ip link set mtu 1500 up dev sl0

Now the vape’s microcontroller appeared as a network device, ready to push packets.

Running a Web Server

To handle TCP/IP and HTTP, I used uIP, a lightweight IP stack designed for memory-constrained devices. It includes a minimal HTTP server example, which I ported to work with the semihosting+SLIP setup.

At first, performance was terrible — pings took 1.5 seconds and web pages loaded in 20 seconds. The issue? The default SLIP code was sending one byte at a time, which introduced huge overhead.

I fixed this by adding a ring buffer for incoming data and batching outgoing writes. That small optimization boosted speeds dramatically:

  • Ping time: ~20ms (down from 1.5s)
  • Page load: ~160ms (down from 20s)

Not bad for a “disposable” microcontroller with only 3KB of RAM!

Memory Usage

Here’s what the final setup looked like:

Memory region Used Size Region Size %age Used FLASH: 5116 B 24 KB 20.82% RAM: 1380 B 3 KB 44.92%

Plenty of room left for a static HTML page — or even a small JSON API.

What Can It Serve?

With ~20KB of free flash, you’re not going to host React or WordPress. But for static websites, APIs, or experimental projects, it’s more than enough.

In fact, this very blog post could fit on the vape’s microcontroller.

I even added a JSON API endpoint that returns:

  • Number of requests since last reboot
  • Unique microcontroller ID

Hosting a website on a disposable vape might sound absurd, but it shows just how powerful even the tiniest microcontrollers can be. With a bit of creativity, semihosting, and an old-school protocol like SLIP, you can turn e-waste into a working web server.

Is it practical? Not really. Is it fun? Absolutely.

Resources

Post a Comment

0 Comments

Write For Us

Recommended Posts