Solarpunk Web Server

At the end of September last year, I wired together a tiny solar-powered web server.

Some time ago, on Mastodon, I’ve stumbled upon compost.party. I love this project in its entirety: the domain, the setup, the trash museum, and everything else. I was also impressed by kaimac running his site on a repurposed EMF camp badge and talked with Tomoe a lot about running a set-up similar to compost.party on an older phone.

I like the shared understanding of both the limitations and the possibilities of these projects.

In a true digital garden fashion, I decided to update this post instead of making a second part, so forgive me if it's too chaotic.

solar charger?

I started looking for a solar charger online to buy second-hand and found one listed as “solar charger?” for around €3. I got it mainly because of the intriguing title, but also because it had speakers and a multitude of dongles. I hoped that one of them would fit the Casio digital diary that I’ve been trying to revive, but sadly the thin barrel is too thin and the thick one is too thick.

Dongles: thick barrel to Apple’s 30 pin connector, thick barrel to mini usb, thick barrel to micro usb, thick barrel to thin barrel

The charger is surprisingly nicely designed (and documented), although a bit difficult to disassemble because of the glued bits. I assume it’s from around 2010 because it mentions the PSP in the manual, the 30-pin Apple connector was last used in an iPhone 4s in 2011 and there’s also a review online from 2012. The review says that the case cost $59.95, which adjusted for inflation has the same buying power as $83.26 in August 2024. I don’t think the charger was ever used because it still had a protective film on.

Here’s a link to the manual shown above as a PDF (with OCR). Is this interesting? I’m not sure. But I like the pictogram of the Sun with a smile.

preventing the battery from going spicy

The charger is designed in such a way that it won’t charge the battery and power the connected device at the same time, so I replaced the PCB with a TP4056 based charging module. It costs around €0.5 on AliExpress. I had this module for a long time and I never really knew how to use it, but it is actually enough to connect a power source in the range of 4V to 8V to the input terminals and a lithium battery to the battery terminals.

I have read a lot of conflicting opinions online whether it’s safe to use it with load connected and the battery charging, but this video by Big Clive explains that the overcharge protection will still work anyway. Other videos by Big Clive show more interesting ideas for this charging module, such as using it with salvaged batteries from “single-use” vape pens.

microcontroller microcontrolling

I used a Wemos S2 mini board, which has an ESP32 microcontroller and costs around €2.5 on AliExpress. I really like these boards because they’re tiny, have USB-C, and a lot of I/O pins. It also has a voltage regulator on-board that can take between 2V to 6V, so I can power it directly from the TP4056 module, and 4MB of flash memory, which is quite a bit. It could technically contain a React app (with unoptimized dependencies, the minified bundle size of React is around 6.4kB (2.5 kB gzipped), and of React DOM around 130.1 kB (41.9kB gzipped)). Some people have tried doing that and it seems to work pretty well.

There are limitations, but there are also possibilities, and some fun ways for optimizing the assets - for example, here’s a great article about image dithering, and here’s another one advocating for keeping websites under 14kB in size.

only sometimes digital (only when the sun is out)

For a couple of hours, the page was hosted at only.sometimes.digital. In that time, a whole bunch of people signed the guestbook, which made me very happy.

One entry was in Basque, which was really cool.

There were two main issues with the set-up. The first one was the charging, which I was perhaps too optimistic about:

It will definitely go offline a lot considering the amount of sun we get. On a full charge, it should last around 6.5 hours at maximum current consumption and around 25 hours at stand-by. I can also charge the battery through micro USB on the TP4056 board, or power the microcontroller board directly through the on-board USB-C port (but there would be no art to that).

The problem was that the tiny solar panel present in the case was not capable of delivering the required charge. I knew that – the manual stated clearly that the output of the solar panel will only be around 70 mA – but I guess I just hoped that it would be fine anyway. At first I hoped that the weather was to blame – it was September after all – but even on the sunnier days there was not enough power for the microcontroller to run.

Perhaps an ESP8266 would be fine, but an ESP32 takes more power.

The embarrassing truth was that after the initial charge ran out, the server never woke up again.

I really liked the form factor of the solar case, but the panel was just too small, so instead I ordered two solar panels from AliExpress that should be able to deliver 400 mA in total.

I found another use for the solar case though – since it has built-in speakers, it’s actually perfect for a radio, and for some reason I do own a radio module that takes only around 20mA.

μmanager

The second issue was that it was quite annoying to maintain:

To make it easier to maintain, I might try to make it update over-the-air, so that I don’t have to physically connect it to my computer.

Setting up remote file system management for the server seemed impossibly intimidating to me, until I stumbled upon this Hackaday article. It featured a blog post in which the author described how they created their own web updater. I was really inspired by how simple it was.

I rewrote the code to work with LittleFS instead of SPIFFS, and used Eleventy to develop the UI more easily – in the development build, the site gets built in a preview directory, with mocked data – but in the actual build, the HTML gets minified and saved in a C++ header file, as a PROGMEM string. This way, since the UI is saved in the program memory, it’s not treated as a part of the file system.

I put the source code on Codeberg. It’s a bit rough around the edges, but could be a good starting point for someone trying to do a similar thing. The original implementation allows for updating the firmware and formatting the whole file system, but I haven’t tested those features.


There is still at least one issue left – after the battery runs out of charge, the ESP32 doesn’t wake back up unless I manually press the reset button. For some time I would press the reset button every morning after I’d wake up, but there has to be a better way…