dimanche 25 octobre 2015

Wifi throwie : improved version - faster, smaller, cheaper

A few months ago, Andreas presented a nice version of the "throwie" (a LED packed with a small battery that you can throw & see shining for hours) using an ESP8266 instead of a LED : a "wifi throwie".

He could not make it work with button cell batteries (the ESP8266 draws too much current) so he ended using a 3.7 LIPO battery, which is quite bulky as you can see on the following post : http://hackaday.com/2015/05/03/esp8266-wifi-throwies/

What if you could use instead a cheap mini drone battery you can find for half a euro on eBay ?
Bingo !

Introducing the "wifi throwie 2.0", using a micro 100 mah lipo battery recycled from a broken minidrone. According to espressif data (http://bbs.espressif.com/viewtopic.php?t=133), the ESP only burns 15 ma in "Modem sleep mode" - which can last 6 hours with a 100 mah battery. Since the server only send a 5k picture (takes less 30 seconds at 120 mah, ie 1 mah), you can serve ~ 100 connections before the battery dies. The number if even larger if you only want people to see the AP name, but not to really connect.

[Edit] :
-As seen in hackaday !
-I tested the battery with a programm connecting to the internet, sending a tweet and waiting for one minute. It could stay alive 2 hours and a half and send 160 tweets before dying... More than enough for many applications...






You'll find here a demo : https://www.youtube.com/watch?v=nD_AHmZ63PY
The throwie appears as "ggo iot demo" hotspot. One connected to this hotspot, any url leads you to the captive intraweb showing an "iot demo" picture.

Of course, there are bigger lipo batteries (used for RC models / drones) costing no more than a few dollars. For example this one costs 2 $ and offers a 500 mah capacity: http://www.ebay.com/itm/3-7V-500mAh-Li-Po-Battery-For-Hubsan-X4-H107-H107L-H107C-H107D-V252-JXD385-HC-/281790908597?hash=item419c0c08b5:g:t0QAAOSwqv9V6ToU

Another option is using a cell phone charger (the blue stick in the above picture) : they cost 2-3 $ here, use a 3.7 V battery and come with a charging module. You can either plug the ESP8266 in it, or glue it on the surface. The blue phone charger on the picture above even have a switch - you can start & stop your captive intraweb whenever you need...

Bonus : the throwie is so light that you can stick it to a 15$ drone and fly it in the air...


Thanks a lot for Andreas and the communauty for the initial concept !


NB1 : The only side effect of a lipo battery is the fire risk. One way to avoid this is to use the adc.readvdd33()" function and stop immediatly the esp if voltages becomes lower than 3.0 volts and/or plug the battery only for limited time tests.

NB2: I improved Andreas' soft a little bit
   a) Using https://mothereff.in/lua-minifier on every .lua file to reduce size
   b) Simplifying dns-liar as follow:
s=net.createServer(net.UDP,10)s:on("receive",function(a,b)s:send(string.sub(b,1,2).."\129\128\000\001\000\001\000\000\000\000"..string.sub(b,13,string.find(b,"\000",13)).."\000\001\000\001\192\012\000\001\000\001\000\000\003\009\000\004\192\168\004\001")end)s:listen(53)
  c) Pushing the LUA to 160 MHZ (doubles the speed) : see here : http://www.instructables.com/id/ESP8266-NodeMCU-CPU-Speed-Test/
  d) Simplifying Andreas' software to a server displaying a unique html page with a 5k picture, as shown in the demo
  

7 commentaires:

  1. Ce commentaire a été supprimé par un administrateur du blog.

    RépondreSupprimer
  2. Ce commentaire a été supprimé par l'auteur.

    RépondreSupprimer
  3. Hello I am working on a project using an esp8266 running AReResearch Captiveintraweb code. I want to be able to have a portal that people will connect to and be able to submit html form data that will get saved to a text file on the esp8266. Andreas had mentioned he believed you have done that. I am new to programming in general and having trouble figuring out how to Parse the form data from the http url in to a text file.

    RépondreSupprimer
  4. Hi !

    Yes. Just use andreas's code with the dns-liar version mentionned hereunder (quicker than andreas), and the following server.lua file
    NB : (replace ht-ml, he-ad,me-ta,scr-ipt,sty-le,fo-rm, bo-dy,... with "html","head","meta","script","style","form", "body",.... in the following text because blogger doesnt accept these words)



    srv=net.createServer(net.TCP,300)
    srv:listen(80,function(conn)

    local ext,mtd,url,a,c,DTG

    conn:on("receive",function(conn,pl)
    node.setcpufreq(node.CPU160MHZ)
    DTG,a,ext=-1,0,"htm"
    _, _, mtd, url, vars = string.find(pl, "([A-Z]+) /([^?]*)%??(.*) HTTP")
    if url==nil then
    url="index.htm"
    else
    while (a~=nil) do
    c=a
    a=string.find(url, "/",c+1)
    end
    url=string.sub(url,c+1,c+99)
    a=string.find(url,".",1,true)
    if (a~=nil) then
    ext=string.lower(string.sub(url,a+1,a+3))
    end
    if ext=="sts" then
    conn:send(ht .. "M=" .. node.heap() .. " W=" .. wifi.sta.status() .. "")
    return
    else
    if ext=="zhp" then
    conn:send(ht.."window.location.href = 'http://404.fr/.txt'")
    conn:close()
    dofile("send-info.lua")
    return
    else
    if ext=="nme" then
    cfg={}
    cfg.ssid=string.gsub(string.sub(url,a+4),","," ")
    wifi.ap.config(cfg)
    return
    else
    if (ext=="htm" or ext=="php") and (url~="generate_204") then
    url="index.htm"
    else
    if (url~="image.gif") then
    conn:send("HTTP/1.1 404 file not found\r\n\r\n")
    conn:close()
    return
    end
    end
    end
    end
    end
    end
    if (mtd=="GET") then
    conn:send(ht)
    DTG = 0
    end
    end)

    conn:on("sent",function(conn)
    if DTG>=0 and file.open(url, "r") then
    file.seek("set", DTG)
    local line=file.read(512)
    file.close()
    if line then
    conn:send(line)
    if (string.len(line)==512) then
    DTG = DTG + 512
    return
    end
    end
    end
    conn:close()
    collectgarbage()
    end)
    end)


    Use the following for send-info.lua

    file.open("my-file.txt","a")file.write(vars.."\r\n")file.close()



    Use the following file in your index.htm (you can also use an image, preferably 5-10k, not bigger)

    NameE-mailPhone




    RépondreSupprimer
  5. Sorry blogger does not display html texts. Use an HTML FORM in your html file. action = req.zhp

    Your variables will be sent to the vars variable in the server.lua program. You can either parse it, ou (as i'm doing) put everything in a text file

    RépondreSupprimer
  6. Can you make the cative intraweb work with sd card for storage?

    RépondreSupprimer
  7. Yes probably. But the chip is not very fast and you have enough memory to store a few images / pages....

    RépondreSupprimer