Marcin Barabasz

imagination is more important than knowledge… A. Einstein


Leave a comment

Improvised charcoal grill blower

I really like all sorts of life-hacks, I use few of them in my everyday life. It is time to contribute something Video

 

Advertisements


6 Comments

ESP8266 Kindle Remote Page Turner

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


Leave a comment

module not found: com.typesafe.sbteclipse#sbteclipse-plugin;2.5.0

If you’ve ever came across this error:

[warn]  module not found: com.typesafe.sbteclipse#sbteclipse-plugin;2.5.0
...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.sbteclipse#sbteclipse-plugin;2.5.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
...
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependenc es exist with the requested attributes.
[warn] com.typesafe.sbteclipse:sbteclipse-plugin:2.5.0 (scalaVersion=2.10, sbtVersion=0.13)
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.typesafe.sbteclipse:sbteclipse-plugin:2.5.0 (scalaVersion=2.10, sbtVersion=0.13) (C:\development\WorkspaceSTS\HelloScala\plugins.sbt#L3-4)
[warn] +- file-searcher:file-searcher_2.10:0.1
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.sbt eclipse#sbteclipse-plugin;2.5.0: not found

Make sure that your plugins.sbt is in fact in project subfolder, and not in project root. This seems like common mistake.

Proper project structure should be:

my-app
|-- build.sbt
`-- project
    |-- build.properties
    |-- plugins.sbt