Wednesday, 29 April 2015

Failed making the smallest WiFi throwie ever

It all looked so simple. I had the video equipment set up and rolling. Assembled the (to my knowledge) first ever WiFi-Throwie. But those in the know might spot the problem right away in this picture.

Yes, the CR2032 battery totally caved in under the 70mA load of the ESP8266 / ESP-01 module.
And I should have known.
The typical discharge rate for a CR2032 is 0.2mA. I need about 350 times more, well knowing this wouldn't last for long.
I then learned the hard way that the internal resistance is obviously way too high.
TI has a document here, where they tried discharge currents beyond the recommended 15mA maximum. But they wouldn't go beyond 30mA. This blog article also confirms that.
So it's back to 18650 rechargeables. Or quite possibly CR123 if size matters.

EDIT; Ordered a CR123 and suitable battery holder today. I'll keep you posted.

Wednesday, 22 April 2015

ESP-01 Wifi softap drops

Today I noticed Wifi connectivity loss at regular intervals of 25 seconds.
A friend of mine played with a CaptiveIntraweb prototype and repeatedly lost connectivity.
This sucks because Apple IOS devices will close the captive portal screen when the WiFi network disappears.

The problem is clearly visible on the Fluke Airwatch tester:


I haven't had this before, so the first thing is to look into power problems. At the time of testing, I had the ESP8266 running on a top quality 3.7V 18650 lithium cell with a 1N diode in series to get rid of 0.6V. That is well within the module's specs.
More research is required....

Edit 10150424:
It clearly was not a power problem. The module ran on this high quality lithium battery for another day (about 45hrs in total). The problem disappeared after a while. I haven't found any problems since.

Friday, 17 April 2015

Joined forces with CPMalek to further refine the CaptiveIntraweb

I am very pleased to announce that today CPMalek joined as collaborator for the CaptiveIntraweb project on GitHub. CP will do away with the "early 90s" look & feel of my HTML code.
CaptiveIntraweb runs on an ESP-01 module (ESP8266)

We see CaptiveIntraweb as an art project exploring the feasibility of wifi throwies. The use as highly localized web service should open new possibilities using well established technologies.

Extremely limited RAM/Flash ressources and the high power requirement of an access-point make this an interesting challenge.

Wednesday, 15 April 2015

Scanning for i2c devices on ESP-01 / ESP8266 modules running NodeMCU / LUA

Trying to get my OLED module to work on one of my ESP-01 modules, the first thing I did today was making sure the ESP-01 "sees" the OLED.
I had found an excellent little LUA script here: http://www.esp8266.com/viewtopic.php?f=19&t=1049#p6198 the user goes by the name "gwizz". Kudos to him (gareth@l0l.org.uk)

 dofile("i2c-autoscan.lua")  
 Scanning all pins for I2C Bus device  
 Device found at address 0x3C  
 Device is wired: SDA to GPIO0 - IO index 3  
 Device is wired: SCL to GPIO2 - IO index 4  
 >  

This works a treat and helps me to avoid silly mistakes. - Highly recommended.

Monday, 13 April 2015

ESP8266 / ESP-01 NodeMCU playing the Imperial March

Looking at the NodeMCU documentation, I came across the PWM feature of the Firmware. And one of the fundamental laws of electronics is: "If it can make noise, it has to play the Imperial March."
Gooooogling didn't show any results, so it might not have been done before. We can fix that.

I found a rather nice Arduino sketch by Andre Tagliati here and ported that over to LUA for the ESP8266. So all the credits for the artistic work converting the original score go to Andre.
The schematic is rather simple:
I had found a piezo speaker in the junk box. That connects to GPIO2. I added a 100 Ohms resistor just because of a gut-feeling that at high frequencies the current might be too high. It works without that just as well.
The rest of the circuit is exactly the same as always.
Now for the interesting bit - The LUA script:

 --Ported to LUA from https://gist.github.com/tagliati/1804108 (Andre Tagliati)  
 --by AReResearch (www.areresearch.net) Andy Reischle  
 --Port index4=GPIO2  
 speakerPin = 4;  
 gpio.mode(speakerPin,gpio.OUTPUT)  
 --speaker connected port  
 --Tone table  
 t={}  
 t["c"]=261  
 t["d"]= 294  
 t["e"]= 329  
 t["f"]= 349  
 t["g"]= 391  
 t["gS"]= 415  
 t["a"]= 440  
 t["aS"]= 455  
 t["b"]= 466  
 t["cH"]= 523  
 t["cSH"]= 554  
 t["dH"]= 587  
 t["dSH"]= 622  
 t["eH"]= 659  
 t["fH"]= 698  
 t["fSH"]= 740  
 t["gH"]= 784  
 t["gSH"]= 830  
 t["aH"]= 880  
 --frequencies for the tones we're going to use  
 --used http://home.mit.bme.hu/~bako/tonecalc/tonecalc.htm to get these  
 function beep(pin, tone, duration)  
 local freq = t[tone]  
 print ("Frequency:" .. freq)  
 pwm.setup(pin, freq, 512)  
 pwm.start(pin)  
 -- delay in uSeconds  
 tmr.delay(duration * 1000)  
 pwm.stop(pin)  
 --20ms pause  
 tmr.wdclr()  
 tmr.delay(20000)  
 end  
 --Play it  
   --for the sheet music see:  
   --http://www.musicnotes.com/sheetmusic/mtd.asp?ppn=MN0016254  
   --this is just a translation of said sheet music to frequencies / time in ms  
   --used 500 ms for a quart note  
   beep(speakerPin, "a", 500)  
   beep(speakerPin, "a", 500)  
   beep(speakerPin, "a", 500)  
   beep(speakerPin, "f", 350)  
   beep(speakerPin, "cH", 150)  
   beep(speakerPin, "a", 500)  
   beep(speakerPin, "f", 350)  
   beep(speakerPin, "cH", 150)  
   beep(speakerPin, "a", 1000)  
   --first bit  
   beep(speakerPin, "eH", 500)  
   beep(speakerPin, "eH", 500)  
   beep(speakerPin, "eH", 500)  
   beep(speakerPin, "fH", 350)  
   beep(speakerPin, "cH", 150)  
   beep(speakerPin, "gS", 500)  
   beep(speakerPin, "f", 350)  
   beep(speakerPin, "cH", 150)  
   beep(speakerPin, "a", 1000)  
   --second bit...  
   beep(speakerPin, "aH", 500)  
   beep(speakerPin, "a", 350)  
   beep(speakerPin, "a", 150)  
   beep(speakerPin, "aH", 500)  
   beep(speakerPin, "gSH", 250)  
   beep(speakerPin, "gH", 250)  
   beep(speakerPin, "fSH", 125)  
   beep(speakerPin, "fH", 125)  
   beep(speakerPin, "fSH", 250)  
   tmr.delay(250000)  
   beep(speakerPin, "aS", 250)  
   beep(speakerPin, "dSH", 500)  
   beep(speakerPin, "dH", 250)  
   beep(speakerPin, "cSH", 250)  
   --start of the interesting bit  
   beep(speakerPin, "cH", 125)  
   beep(speakerPin, "b", 125)  
   beep(speakerPin, "cH", 250)  
   tmr.delay(250000)  
   beep(speakerPin, "f", 125)  
   beep(speakerPin, "gS", 500)  
   beep(speakerPin, "f", 375)  
   beep(speakerPin, "a", 125)  
   beep(speakerPin, "cH", 500)  
   beep(speakerPin, "a", 375)  
   beep(speakerPin, "cH", 125)  
   beep(speakerPin, "eH", 1000)  
   --more interesting stuff (this doesn't quite get it right somehow)  
   beep(speakerPin, "aH", 500)  
   beep(speakerPin, "a", 350)  
   beep(speakerPin, "a", 150)  
   beep(speakerPin, "aH", 500)  
   beep(speakerPin, "gSH", 250)  
   beep(speakerPin, "gH", 250)  
   beep(speakerPin, "fSH", 125)  
   beep(speakerPin, "fH", 125)  
   beep(speakerPin, "fSH", 250)  
   tmr.delay(250000)  
   beep(speakerPin, "aS", 250)  
   beep(speakerPin, "dSH", 500)  
   beep(speakerPin, "dH", 250)  
   beep(speakerPin, "cSH", 250)  
   --repeat... repeat  
   beep(speakerPin, "cH", 125)  
   beep(speakerPin, "b", 125)  
   beep(speakerPin, "cH", 250)  
   tmr.delay(250000)  
   beep(speakerPin, "f", 250)  
   beep(speakerPin, "gS", 500)  
   beep(speakerPin, "f", 375)  
   beep(speakerPin, "cH", 125)  
   beep(speakerPin, "a", 500)  
   beep(speakerPin, "f", 375)  
   beep(speakerPin, "c", 125)  
   beep(speakerPin, "a", 1000)  
   --and we're done \ó/  
The beep() function is the only moderately interesting bit. I had to insert a tmr.wdclr() to avoid problems with the watchdog timer. The rest is pretty much what Andre had prepared. Just in a LUA flavour.

The videos will appear on my Youtube channel shortly.
Here is the first video: https://youtu.be/dlnj3u-Tj3A

Wednesday, 8 April 2015

More work on the CaptiveIntraweb - ESP-01 NodeMCU

With all basic programming issues out of the way, I built a first prototype of a somewhat oversized Wifi-throwie. Schematics will be published in one of the next posts.

There is a 1N4001 diode hidden in the red heat-shrink tubing to get rid of about 0,6V. It might not be the most energy efficient way to drop a few thenths of volts, but it sure is cheap.
For the power consumption I measured 70mA. That is A LOT!
With an estimated realistic capacity of around 1000mAh, my Ultrafire battery will only give me a 14h run time.
Not really spectacular.
This also makes it rather inefficient for a tiny WiFi-throwie. A CR2032 has around a capacity of around 200mAh, giving us only 3hrs of fun.
ESP8266 sleep modes (according to the WIKI) do not work in SoftAP mode. So the only thing that helps is a bigger battery.

Battery options:

  • CR2032 (3V / 200mAh) < 3h
  • 14500 Lithium cell (3,7V, 800 mAh) > 10h
  • 18650 Lithium call (3.7V, 2000 mAh) > 28h
  • Energizer L92 (1,5V, 3000 mAh) > 40h
I have some unused, low quality 18650s, matching battery holders and a suitable enclosure, so I'll stick with them,

Cost:
  • 18650 battery (well, nothing really but let's say:) = 2€
  • ESP-01 = 3,30€
  • Battery holder = 1€ (less)
  • Dupont cables = 1€ (less)
  • Enclosure = 1,30€
  • 1N diode = 0,10€ (less)
  • Rare earth magnet = 1€
So I get away with less than 10€ (also less than 10$ US) - Cheap enough to put at risk in public places. That is why I shy away from good quality 18650s.

The code on github is a bad mess of English and German fragments. The next step is to clean up the translations.

Sunday, 5 April 2015

Progress on the esp8266 NodeMCU / Lua Captive Portal

I'm making good progress on the ESP8266 based captive portal. - That is: if the name captive portal really fits, as it doesn't lead anywhere but holds the device captive. - So I named it "CaptiveIntraweb".
I've been working on this on-and-off for about two months and once it sort-of worked, I put the code in the dev-tree of the github project. Tonight I made good progress when I had figured out how Apple's IOS devices handled captive portals. Now we can play games on the logon-screen.
Windows mobile devices were less picky and worked weeks ago.

Currently it requires:
  1. an ESP-01 module (others will do as well)
  2. two AA batteries of a 3.7V lithium cell with a 1N diode in series to drop 0.6V
  3. some dupont jumper cables
On the software side:
  1. modified NodeMCU firmware
    I use an older version 20150213 with two modifications:
    Reduced the 4* LUALBUFFERSIZE back to the original value.
    Switched on the DNS-feature of the DHCP server in softAP mode
  2. the .lua and .htm files found in the dev-branch here:
    https://github.com/reischle/CaptiveIntraweb/tree/dev
The firmware apparently contains binary blobs of unclear copyright, so I won't distribute the custom firmware. Building the firmware is well documented. Send a PM if you need help.

One of my friends already figured out where this all is going to lead eventually. So I didn't bother removing the clues from the code and html files.

The files in the dev branch are only partly translated.