Building a Kindle Page Turner Twice
I wanted to turn pages while reading in bed without reaching for the Kindle.
I solved that problem twice. The first solution was an ESP8266, a power bank and a custom enclosure shaped like a laser pointer. The second was a cheap Tuya scene switch, OpenBeken and Berry.
The second remote was much smaller. Getting there took a year.
Making a Kindle accept commands
My Kindle Paperwhite 4 was jailbroken, which made the software side possible. The first plan was wonderfully direct:
- Start the Kindle’s BusyBox
httpd. - Record touchscreen events from
/dev/input/event2. - Expose small HTTP endpoints which replay those events.
- Have a handheld controller call the endpoints.
The controller was a D1 Mini with an ESP8266. It created its own Wi-Fi access point, gave the Kindle a predictable address and sent HTTP requests for next and previous page. This made the remote independent of my home network.
The recovered sketch used the OneButton library. A single click turned the page forward, a double click went back and a long press shut the controller down. After five minutes of inactivity it told the Kindle to restore normal screensaver behavior and put the ESP8266 into deep sleep.
There was an important limitation hidden in that last sentence. The ESP8266 did not wake from an ordinary button press in this design. It needed a reset.
Still, by 1 June 2024 I had a working physical prototype. The next problem was making it pleasant to hold.
A circuit looking for a body
The prototype needed room for a D1 Mini, buttons and a power bank. I started building standoffs, button mounts, a battery holder and a cap.
At first I was treating the enclosure as a box which needed enough internal volume. That produced a box. It held the parts, but it was not a natural object to keep in one hand while reading.
The useful comparison was a laser pointer. A laser pointer is long because its parts need length, but its exterior does not apologize for that fact. It is a deliberate handheld shape rather than a project box with rounded corners.
The modeling breakthrough fit in one line of my notes:
ellipse and circle revolved and cut
Instead of constructing the outside face by face, I drew a profile from an ellipse and a circle, revolved it into a body and cut that body into printable top and bottom halves. The electronics then became cutouts inside the form.
That reversal mattered. I was no longer arranging walls around components. I was starting with the object I wanted to hold and subtracting the space required by the hardware.
The FreeCAD model grew board and power-bank pockets, a tube, a locating pin, button cutouts and internal standoffs. Printed iterations exposed the ordinary details which CAD renders invisible: a button hole needed more clearance, a standoff needed to be larger, a button was not quite centered and the edges still needed a chamfer.
I also experimented with another power arrangement using pogo pins and considered keyboard switches with replaceable inserts. The custom remote was becoming a substantial mechanical project of its own.
A better enclosure from a factory
In February 2025 I was flashing Tuya devices with OpenBeken.
Among them were two compact LKWSW201 two-button Wi-Fi scene switches, each 51 × 51 × 16.5 mm and 18 g.
Each already contained:
- two usable buttons;
- a BK7231N module;
- a finished enclosure;
- space for two AAA batteries;
- hardware designed to spend most of its life asleep.
It was almost exactly the object I had been trying to manufacture around the ESP8266.
The ready-made ergonomics and battery hardware were better suited to the job, and OpenBeken’s deep-sleep support gave the remote a more appropriate power model. A handheld remote should wake, do one thing and disappear again.
The first OpenBeken scripts were mostly bring-up code. They sampled the wake GPIOs, copied button states into channels, waited for Wi-Fi, called HTTP endpoints and returned to deep sleep. Distinguishing which button caused wake did not work reliably at first, and the device could also wake periodically.
The hardware was right. The coordination logic was still awkward.
Berry and KOReader
By then I was porting the Berry embedded language from Tasmota into OpenBeken, a project with its own longer story. The Kindle remote became one of its first serious uses.
I also changed the Kindle side. Instead of replaying raw touchscreen events, the final remote talked to KOReader’s HTTP Inspector interface directly:
/koreader/event/GotoViewRel/-1
/koreader/event/GotoViewRel/1
In May 2025 I wrote a kindleremote Berry module which attached handlers to the two button channels, sent previous-page and next-page events, called preventScreenSaver.cgi on the Kindle while active and reset a one-minute inactivity timer after every press:
addEventHandler("Channel5", def()
runCmd("sendGet " + host + ":8080/koreader/event/GotoViewRel/-1")
prevent_sleep()
inactivity_timeout()
end)
addEventHandler("Channel4", def()
runCmd("sendGet " + host + ":8080/koreader/event/GotoViewRel/1")
prevent_sleep()
inactivity_timeout()
end)
When that timer expired, it called disconnect.cgi to restore the Kindle’s sleep behavior and put the BK7231N back into PinDeepSleep for six hours (waking immediately on a button press).
By July 2025 the remote could run in two network modes selected by Channel 3.
At home it joined the existing Wi-Fi network and talked to kindle.test.
Away from home it created its own access point and the Kindle connected directly to it, preserving the useful property of the first ESP8266 prototype.
This version became a deployed device.
The remote finds a firmware bug
The project also exposed a problem in OpenBeken’s Berry integration.
Importing kindleremote from an HTTP command worked.
Importing the same module from addRepeatingEvent crashed the BK7231N.
The difference was not Berry source code.
The two calls ran in different FreeRTOS tasks: berry import over HTTP ran in the HTTP server task, while addRepeatingEvent ran inside the QuickTick timer task.
Compilation (be_loadstring) succeeded, and execution (be_pcall) blew the stack.
I enabled uxTaskGetStackHighWaterMark and logged the minimum free stack inside berryRun: 1784 words left on the HTTP task, versus just 222 words on the timer task.
Increasing configTIMER_TASK_STACK_DEPTH to 6000 bytes made the import work, and in the meantime deferring the import via setTimeout(def() import kindleremote end, 0) worked around it on stock builds.
That diagnosis became OpenBeken issue #1663.
A script can be perfectly valid and still fail because one firmware callback happens to place the VM on a smaller task stack.
Solving the right problem
I still like the custom enclosure. The laser-pointer insight changed how I approached its shape, and the model became far more intentional after it. That work was not wasted merely because the final remote used an enclosure somebody else had manufactured.
But the object I wanted was not a showcase for a D1 Mini, a power bank or my ability to model two mating shells. It was a page button for reading in bed.
The Tuya scene switch was already a good page button.
OpenBeken let me replace the software which made it dependent on Tuya.
Berry let me express the behavior I wanted.
KOReader gave me a cleaner interface than pretending to be a finger on /dev/input/event2.
The first build taught me how to make the whole system. The second taught me which parts I did not need to make.