The TinyLibrary
Jan 18, 2024
I’ve been on a big ebook kick lately (currently rereading the first scifi I ever consumed as a little kid, Contact by Carl Sagan). The concept of written words that have been a major part of my development (or recreation) being subject to the same resilience, shareability, and indexing as other digital goods delights me, so I’ve spent quite a bit of time and effort to get every book I’ve ever read (and some I haven’t read yet) into a well-tagged digital library that’s coming up on 800 books.
I also love guerilla education. Getting knowledge into the hands of the people in ways they might not expect and sparking curiosity is something I value very much. I’ve been hankering to combine this with my recent love of ebooks for some time, and I finally got around to sitting down and building the project I’ve been sketching out in my head on and off for the last few months.
Enter: TinyLibrary — ultra lightweight, ultra low-power, wifi-broadcasting ebook library suitable for guerilla deployment to USB ports or small solar panels.
I’ve really wanted to build something meaningful with an ESP32 for a while. I had an aborted idea of a wifi-enabled plant light with integrated fan for growing plants in mason jars on a desk, but that never quite took off. This was the perfect thing to scratch the make-something itch. With built in wifi and easy hook-up for a micro SD card reader, it was actually super simple to get a pretty energy efficient web server off the ground.
I then sunk time into making a pipeline from Calibre (my open-source ebook manager of choice) exports into a web interface to display metadata and launch a browser-based ebook reader. It’s simple but functional, and fairly compact to account for the ~100kbps speeds you get running a web and DNS server on something with less than half the RAM of a 1987 Mac II.
Its power usage is fine but not fantastic for the form factor — broadcasting an access point draws about 150mA idle and 250mA when it’s serving a hefty file; nothing like the double digit MICRO amps you can draw in deep sleep on the ESP32. That being said, a web server + wireless access point + DNS server + storage layer running at under 1.5W at all times is still pretty fantastic, and beats out a RasPi Zero W for sure. Excellently, that kind of wattage is SUPER doable on a small solar cell, which is my next phase.
Here’s a quick demo of the user interface:
Generally, I’m pretty pleased with this. The only catch is that is it uses DNS responses to force the user to the captive portal, which I hate on principle. I’ve opened a pull request on the ESP32 repo to merge in support for DHCP option 114, the more modern standard for indicating to the client that it needs to open a captive portal for the user in the actual DHCP offer itself, but who knows how long that will take to even get eyes on it, much less whether it will actually get merged in. Until then, DNS is how it will have to be.
I might mock up a nicer case for it; I mistyped my digikey order so now I have batched hardware ready to go for eight of these little guys. I think I’m gonna get ahold of some solar panels and regulators, weather proof the package, and find some out-of-the-way places to stash some public domain classics!
Of course, as always, all code is available under MIT License on Github.
Happy reading!