Kindle WiFi Remote Footswitch

by mosivers in Circuits > Gadgets

7049 Views, 15 Favorites, 0 Comments

Kindle WiFi Remote Footswitch

DSC_0421.JPG
kindle remote footswitch.gif

My brother is playing several instruments and has many of his song lyrics and chords saved on his Kindle. It is a very convenient way to have your sheet music ready for live performances with one major downside, you cannot flip pages while your playing an instrument. Since my brother knows I love to build electronic stuff he came up with the task for me to build him a footswitch that he can use to flip pages on his kindle.

While this project is mainly targeted at musicians it could also be useful for disabled people who cannot flip pages by hand. Also there are apparently man people who think it is just inconvenient to flip pages using the touchscreen, e.g., when reading in bed. My remote is of course not limited to footswitches but any button could be integrated into the design.

While researching the internet it was not surprising that many people already thought a remote for flipping pages would be a good idea and some have come up with good solutions. This instructable by chigozie uses a webserver to flip pages on an older kindle model (without touchscreen) from any device that is connected to the same WiFi (e.g. your phone). Building upon this Marcin Barabasz created a custom remote control using an ESP8266 equipped with two buttons. The is also KindleLazy which is a custom app that allows you to control your Kindle using a wireless presenter. Finally, this guy chose the mechanical solution and created a device which can be attached to the the side of your kindle and taps the screen with a mechanical arm rotated by a servo.

First Experiments

experimenting.gif
IMG_20181222_205103.jpg

Looking at the remotes that other people already built I thought if there was an easier solution for a Kindle with touchscreen. The disadvantage of the mentioned WiFi remotes is that they require the Kindle to be jailbroken and involve more or less heavy coding. In addition, the mechanical solution requires a lot of hardware and of course also some coding. As many touchscreens, that of my brother's kindle is working capacitively and if your search the internet people have already eyperimented a lot with ways to trigger it without hands (see e.g. here, here and here). My fist idea was to just have a piece of copper foil placed on the touchscreen that gets connected to the ground of the micro USB connector when pressing a pushbutton. As you can see in the GIF, the experiment was successfull. I then 3D printed a small holder that can be attached to the side of the Kindle, glued the copper foil onto the holder and connected it to a wire. The wire was connected to a longer cable with a pushbutton at the end so that it could be used as a footswitch. The cable is running back to the Kindle and plugged into the micro USB. Unfortunately, I was not able to trigger the touchscreen in this way any more and some experimentation showed that the configuration above only works when the switch is very close to the screen. It seems that if the cable is too long its stray capacitance is too large. I then tried to place a transistor very close to the screen and use it as a switch between the copper foil and the USB ground. However, this also did not work most likely again because of the stray capacitance of the transistor.

Because of these unsuccessfull experiments I decided to build to a WiFi remote instead. The remote I created is very similar to that by Marcin Barabasz but while his Kindle is a non-touch version I had to make some changes to control the touchscreen. In addition, while he connects the ESP8266 and Kindle to a common WiFi network, I managed to connect the Kindle to the WiFi Access Point created by the ESP8266.

Gather Materials

IMG_20181222_154327.jpg
IMG_20181222_184911.jpg

  • 2x footswitch (conrad.de)
  • 1x pushbutton switch
  • 18560 Li ion battery and battery holder
  • TP4056 charger module (amazon.de)
  • NodeMCU Lolin v3 ESP8266 developer board (amazon.de)
  • 5 mm LED and bezel holder + current limiting resistor
  • project box that fits all the components

In addition to the components above I used a step up module which increases the output voltage of the battery to 5 V. This was necessary because the battery voltage is too high to connect it directly to the 3.3 V input but too low for the voltage regulator on the board. I only did this because I had the step up module still at hand, it would have been more efficient to get a low dropout 3.3 V voltage regulator (e.g. MCP1700) instead.

Jailbreak Your Kindle

IMG_20181216_154536.jpg

Since we need to run a webserver on the kindle we have to perform a jailbreak. The jailbreak offers to make all kind of modifications to your kindle like running custom apps. The jailbreak procedure depends on the model and firmware version of your kindle and if you are unlucky can only be performed by opening the housing and using a USB-serial converter, therefore, the first step is to identify your kindle using the first four digits of the serial number as shown in the link below.

https://wiki.mobileread.com/wiki/Kindle_Serial_Num...

The jailbreak procedure for most kindles (firmware version 5.x) is described in the link below.

https://wiki.mobileread.com/wiki/5_x_Jailbreak

If you have a Kindle PW 1 with firmware version 5.6.1.1 like I do, you first have to downgrade the firmware as described here.

Make sure to follow the instructions closely when performing the jailbreak as there is always the risk of "bricking" your kindle.

Install MRPI, KUAL and USBNet

After you have successfully jailbroken your kindle you should install MRPI, KUAL and USBNet. The MobileRead Package Installer (MRPI) lets you install custom plugins to your Kindle while the Kindle Unified Application Launcher (KUAL) lets you run the plugins. Finally, USB Networking enables you to connect to your kindle via ssh and will install busybox which includes a httpd webserver applet. Detailed installation instructions for all packages can be found below.

https://www.mobileread.com/forums/showthread.php?t...

https://www.mobileread.com/forums/showthread.php?t...

https://wiki.mobileread.com/wiki/Kindle_Touch_Hack...

Record Touch Event

When triggering the touchscreen it will write data to /dev/input/event0, therefore, in order to simulate a touchscreen event we can just record this data and write it to a file. If we later write the content of this file to /dev/input/event0 it will simulate the touch event.

At first you need to log in to your kindle via ssh, alternatively you can also use a terminal app on the kindle like kterm. To record the touch event that corresponds to a forward page flip simply type the following terminal command.

cat /dev/input/event0 > f.txt

After this tap the screen on the right as if you would flip the page forward. The data of this touch event will be written to the file "f.txt". Then do the same with a backward page flip and write it to the file "b.txt".

You can check if the simulated touch event works by typing

cat f.txt > /dev/input/event0

This will write the data from the text file to /dev/input/event0 and therefore simulate the touch event.

Create CGI Scripts

Following the instructable by chigozie we need to create cgi scripts for the page flips which can then later be executed via http commands. Create the folder /www/cgi-bin in the usb root directory (/mnt/us/) of your kindle and copy the attached cgi files there. You may also need to make the files executable using the following terminal command

chmod +x f.cgi
chmod +x b.cgi

Also move the previously created text files "f.txt" and "b.txt" to the same directory. As you can see the last line of the cgi script executes the commands that will simulate the touch event.

Downloads

Configure Webserver

Next, we need to configure the webserver that runs on the kindle. Copy the attached httpd.conf file to /mnt/us/usbnet/etc/. The line "A:192.168.4.1" will allow connections from the default ip address of the ESP8266 access point. Note that I have commented out the option to log into the webserver via a username and password. This probably makes you kindle a bit vulnerable to hacking attempts but I have not yet figured out how to implement the authentication feature into the ESP code.

To start the webserver create a file called serverstart.sh in /mnt/us/ with the following content

#!/bin/sh
iptables -A INPUT -i wlan0 -p tcp --dport www -j ACCEPT;
/mnt/us/usbnet/bin/busybox httpd -h /mnt/us/www -c /mnt/us/usbnet/etc/httpd.conf

Make the file executable by typing

chmod +x serverstart.sh

Executing the serverstart.sh script will start the httpd webserver on your kindle.

It is a good idea to test if the cgi scripts are working by executing them from a PC or phone in your local WiFi. For this replace the line "A:192.168.4.1" in the httpd.conf file with "A:192.168.". Then start the webserver by executing the serverstart.sh script. Connect the kindle to your local WiFi and find out its ip address (e.g. by typing ";711" in the kindle search bar as described in the next step). Then open a browser on any device connected to the same WiFi and go to "<kindleip>/cgi-bin/f.cgi". You should see a page with a forward and a backward arrow symbol. By clicking the symbol the corresponding cgi script will be executed and flip the page.

Since we later want to connect the Kindle to the access point created by the ESP we have to do one more modification. Normally your Kindle will not let you connect to a WiFi that has no internet access, to avoid this we need to create a file called WIFI_NO_NET_PROBE in the USB root directory by typing

touch /mnt/us/WIFI_NO_NET_PROBE
restart wifid

Downloads

Upload Code on ESP

The attached file includes the code for the ESP8266 written with the arduino IDE. When executed the code will create a WIFI access point and wait for a button press. When the button is pressed it will connect to the webserver of the kindle and execute the corresponding cgi script.

Before uploading the code you can change the SSID and password for your access point. In addition, you need to enter the ip address of your Kindle in the two variables byte ip[] and const char* host. In order to find out the latter first upload the code with a random ip adress. Then connect your kindle to the access point and type ";711" in the search bar of your Kindle. This will show up a page with all network information including your Kindle`s ip address.

Wire Electronics

IMG_20181222_194439_1.jpg
kindle switch schematic.png

Now it is time to wire the buttons and battery to the ESP according to the attached schematic. Note that I put the schematic of the preferred configuration which uses a 3.3 V voltage regulator connected directly to the Vin of the microcontroller. In addition, I did not find the TP4056 charger module in the Fritzing library so I just put the layout of a similar module.

Mount Electronics in Housing

IMG_20181222_201740.jpg

I drilled some holes in the housing for the pushbutton switches and also cut some slots for the micro USB connectors of the ESP and charger module using a rotary tool. The PCBs were all fixed with hot glue.

Finished Project

IMG_20181222_202825.jpg

After closing up the housing the project is finished. If you haven't done already it is time to test if everything is working. After switching on the remote you should see a WiFi accesspoint with the defined SSID to which you can login with your Kindle. Once the Kindle is connected you should be able to flip pages using the pushbuttons.

There are some possible improvements to this project.

  • When the Kindle is restarted you also have to restart the webserver by executing the serverstart.sh script. Therefore, it would be convenient for the script to be executed automatically upon startup.
  • As already mentioned, the webserver is not password protected and any device with the allowed ip address can connect to it. If you know how the ESP code needs to be modified in order to use the authentication feature please leave it in the comments.
  • Executing the cgi scripts which then execute the terminal commands seems a bit overcomplicated to me. There is maybe a more direct way to execute the terminal command from the ESP. Again if you have any good ideas please leave a comment.