Marcin Barabasz

imagination is more important than knowledge… A. Einstein

ESP8266 Kindle Remote Page Turner

5 Comments

20150416_233208

Finally I had time to publish a new updated version of my Kindle Remote Page Turner. This time the build will be made using ESP8266 module I got from ebay for about 3$. This module is just brilliant and fits this project perfectly since kindle’s only wireless interface is wifi, so lets start.

What I will be using in this build is one ESP8266 module ESP-03 to be more precisely. There are various packages available, but 03 seems to be perfect combination of size and features (lots of GPIOs). I will just use three gpios in this project two for switches and probably also one for WIFI status led. The first challenge was to solder additional wires to the module to be able to stick it on a breadboard for prototyping. This is what I ended up with:20150416_223954

Since this will be battery powered also I need a way to provide a stable 3.3V. I went with a DC to DC converter and a pair of AAA batteries.

I bought a battery case for 3xAAA batteries, but the plan is to use only 2 batteries, and utilize extra space for all the electronics (DC converter, esp8266, 2 resistors and some wiring).

20150416_221927

Kindle is prepared as in previous post “Kindle remote page turner” with the addition of cgi scripts for turning the pages via web requests. This modification is very well explained here.

Everything is connected as shown on the schematic

kindle_page_turner_bb

kindle_page_turner_schem

But first I need to program my esp8266 to do what it is supposed. I went with NodeMCU firmware as it proves to have biggest community and using it is very easy. What you need is just NodeMCU Programmer ldownload. and ideally ESPlorer IDE ldownload to make programming nice and flawless. The main ideas for the program are:

1. Put ESP8266 into AccessPoint mode.

2. Configure interrupts to wait for key presses on two selected GPIOs

3. Once interrupts occur send HTTP calls to interface created on Kindle to turn pages forward and back

4. How would I know the ip of kindle. This can be addressed by allowing just two possible IP addresses via mask. This way first one will always be for the host and another for the kindle once it connects. This should be sufficient as I don’t want to allow more than one device to connect anyway.

UNFORTUNATELY THIS APPROACH DID NOT WORK SINCE KINDLE IS UNABLE TO CONNECT TO ACCESS POINT CREATED USING ESP8266 MODULE. COMPUTER DOES! I WILL KEEP DIGGING WHY IT CAN’T BUT UNTIL THEN THERE IS ALTERNATIVE.

the alternative is to put ESP into Station mode and connect to the same network as kindle. This solution has however some shortcomings:

1. you can not use this solution outside of one defined network

2. you have to know details like kindles IP address and program your ESP with these details.

but for testing purposes it is ok. The program looks like:

-- This is the original idea to put kindle into AP mode however kindle is unable to connect-- to the device

--wifi.setmode(wifi.SOFTAP)
--wifi.ap.config({ssid="kindle",pwd="0000"})
--wifi.ap.setip({ip="192.168.1.1",netmask="255.255.255.252",gateway="192.168.1.1"})

wifi.setmode(wifi.STATION)
 wifi.sta.config("<SSID>","<PASSWORD>")
 tmr.alarm(0, 1000, 1, function()
 if wifi.sta.getip()==nil then
 print("Connect AP, Waiting...")
 else
 tmr.stop(0)
 print(wifi.sta.getip())
 gpio.mode(8,gpio.INT, gpio.FLOAT)
 gpio.trig(8,"down",forward)

gpio.mode(5,gpio.INT, gpio.FLOAT)
 gpio.trig(5,"down",back)
 end
 end)

function forward(level)
 conn=net.createConnection(net.TCP, false)
 conn:on("receive", function(conn, payload) print(payload) end )

conn:connect(80,"192.168.1.14")
 --conn:connect(80,"192.168.1.2")
 conn:send("GET /cgi-bin/f.cgi HTTP/1.1\r\n"
 .."Host: 192.168.1.14\r\n"
 --.."Host: 192.168.1.2\r\n"
 .."User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36\r\n"
 .."Content-Type: text/plain; charset=utf-8 \r\n"
 .."Accept: */*\r\n"
 .."Accept-Encoding: gzip, deflate, sdch\r\n"
 .."Accept-Language: pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4\r\n"
 .."\r\n")
 tmr.delay(500000)
 end

function back(level)
 conn=net.createConnection(net.TCP, false)
 conn:on("receive", function(conn, payload) print(payload) end )

conn:connect(80,"192.168.1.14")
 --conn:connect(80,"192.168.1.2")
 conn:send("GET /cgi-bin/b.cgi HTTP/1.1\r\n"
 .."Host: 192.168.1.14\r\n"
 --.."Host: 192.168.1.2\r\n"
 .."User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36\r\n"
 .."Content-Type: text/plain; charset=utf-8 \r\n"
 .."Accept: */*\r\n"
 .."Accept-Encoding: gzip, deflate, sdch\r\n"
 .."Accept-Language: pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4\r\n"
 .."\r\n")
 tmr.delay(500000)
 end

 

Layout of the components inside the case:

20150416_233020

Finished device looks like this:

20150416_233208

Traditionally a short movie showing working device.

movie

Advertisements

5 thoughts on “ESP8266 Kindle Remote Page Turner

  1. Hi Marcin, love your device.
    Is there any chance of you adding the schematic for your device? And what brand/type of DC converter did you use?
    Thanks a lot.

  2. Hello,
    glad to hear that you like the project. I used mini DC-DC 0.8-3.3V to DC 3.3V step up converter from Ebay.
    http://www.ebay.com/itm/281556288481

    About the schematic I will try to attach it to the post soon.
    cheers

  3. Hi Marcin,

    Congratulate to you for your device!! 🙂

    Any update on AP mode?

    Regards,
    R

  4. The reason the kindle can’t connect to the AP is that the kindle sends data through the connection and needs to receive a response before it will accept the connection – i.e. you cannot connect to an AP that is not connected to the internet. I tested this by connecting my kindle to my phone through an AP while having my phones internet turned off. The kindle did not like the connection. Perhaps if the ESP can return the data that the kindle is expecting the connection can be made directly to the ESP?
    Love the work you have done here. Well done!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s