Tame the beast: Ultra-Low Power #ESP8266 Thing




Hardware components:
13711 01
SparkFun ESP8266 Thing – Dev Board
×1
09873 01a
SparkFun FTDI Basic Breakout – 3.3V
×1
Lithium Ion Cylindrical Battery – 3.7v 2200mAh
High Power – check below for the solar power version!
×1
R8326274 01
Raspberry Pi 2 Model B
×1
LiPo battery 200mAh or 400mAh
Low Power – the solar power version needs only a smaller battery
×1
0.5W solar panel
Low Power – the solar power version needs of course an solar panel 5.5V max., 110mA
×1

Tame the beast Ultra Low Power ESP8266 Thing

STORY

Inspired by the lander #Philae on comet 67P we started a while back working on low-power projects assuming that we do have only solar power to recharge batteries and might need to sleep during a period of time to wake up on a given event.

Update: the project has now proven to run solely of solar power for 3 days/nights, that might sound not that much, but bear in mind we are running an power hungry wifi module just from a 200mAh LiPo and harvesting solar power from a tiny 0.5W solar panel … as a comparison the used LiPo would ran out of power without any tricks in a single hour. Read about the tricks used:

The ESP8266 Thing from SparkFun is a nice board – but first we want to get it ready for NodeMCU so we can code it in LUA language without the need of an Arduino(TM) IDE. Further more we use LUA to control the sleep mode (switching off not used components) and wake up for work – isn’t it like real life 😉 With that we can run the ESP8266 Thing and equivalent ESP8226 (e.g. Adafruit) independent from the power grid just by solar power! Btw. we just add a solar panel and a LiPo – *no* expensive solar charger!

Board and LiPo connected

Step 1

Cut the DTR trace on the back of the board for allowing serial debugging and flashing new firmware.

Step 2

Installation of ESP8266 tool chain on Raspberry Pi

Beside the software installation of compiler and tools for flashing the ESP8266 there is also the demand of an appropriate FTDI 3.3V wiring to the ESP8266.

1. ESPtool – python based tool for flashing the ESP8266

wget --no-check-certificate https://github.com/themadinventor/esptool/archive/master.zip

unzip master.zip

cd esptool-master

sudo python setup.py install

2. LUAtool – libs and samples for coding in LUA language

wget --no-check-certificate https://github.com/4refr0nt/luatool/archive/master.zip

unzip master.zip

3. NODEmcu – firmware for the EPS8266 supporting LUA coding

wget --no-check-certificate https://github.com/nodemcu/nodemcu-firmware/archive/master.zip

unzip master.zip

Flash the latest NODEmcu firmware on to ESP8266:

[email protected] ~/esp/nodemcu-firmware-master/pre_build/latest $ python /home/pi/esp/esptool-master/esptool.py --port /dev/ttyUSB0 write_flash 0x00000 nodemcu_latest.bin

Connecting...

Erasing flash...

Writing at 0x00062000... (100 %)

Leaving...

Done – Firmware is flashed, just reboot before the next step.

Now we download the auto startup LUA script to allow the ESP8266 connection to an access point:

[email protected] ~/esp/luatool-master/luatool $ python /home/pi/esp/luatool-master/luatool/luatool.py --port /dev/ttyUSB0 --src init.lua --dest init.lua --verbose

Set timeout None

Set interCharTimeout None

Upload starting

Stage 1. Deleting old file from flash memory

->file.open("init.lua", "w") -> ok

->file.close() -> ok

Stage 2. Creating file in flash memory and write first line->file.remove("init.lua") -> ok

Stage 3. Start writing data to flash memory...->file.open("init.lua", "w+") -> ok

->file.writeline([==[print('init.lua ver 1.2')]==]) -> ok

->file.writeline([==[wifi.setmode(wifi.STATION)]==]) -> ok

->file.writeline([==[print('set mode=STATION (mode='..wifi.getmode()..')')]==]) -> ok

->file.writeline([==[print('MAC: ',wifi.sta.getmac())]==]) -> ok

->file.writeline([==[print('chip: ',node.chipid())]==]) -> ok

->file.writeline([==[print('heap: ',node.heap())]==]) -> ok

->file.writeline([==[-- wifi config start]==]) -> ok

->file.writeline([==[wifi.sta.config("SSID","passkey")]==]) -> ok

->file.writeline([==[-- wifi config end]==]) -> ok

->file.writeline([==[wifi.sta.connect()]==]) -> ok

->file.writeline([==[tmr.alarm(1, 1000, 1, function()]==]) -> ok

->file.writeline([==[if wifi.sta.getip()== nil then]==]) -> ok

->file.writeline([==[print("IP unavaiable, Waiting...")]==]) -> ok

->file.writeline([==[else]==]) -> ok

->file.writeline([==[tmr.stop(1)]==]) -> ok

->file.writeline([==[print("ESP8266 mode is: " .. wifi.getmode())]==]) -> ok

->file.writeline([==[print("The module MAC address is: " .. wifi.ap.getmac())]==]) -> ok

->file.writeline([==[print("Config done, IP is "..wifi.sta.getip())]==]) -> ok

->file.writeline([==[-- dofile ("web.lua")]==]) -> ok

->file.writeline([==[end]==]) -> ok

Stage 4. Flush data and closing file->file.writeline([==[end)]==]) -> ok

->file.flush() -> ok

->file.close() -> ok

--->>> All done <<<---

Read More : Tame the beast: Ultra-Low Power #ESP8266 Thing


Leave a Comment

© 2015 Powered By Engineering Projects Team, Raspberry Pi Projects

Scroll to top