Hamish Cunningham, Gareth Coleman, and Crowds.Work
("Tragedy?!" That was bad science!)
Note: the Lua code uses NodeMCU. This is a great firmware for the ESP8266, but sometimes struggles with the resource constraints of the device. It is also quite a lot of work to port existing Arduino code for the sensors etc. that we're using over to Lua. So the new stuff now uses the ESP Arduino IDE (forum).
- A Lua port of code for the TSL2561 I2C Luminosity sensor.
- A library for configuring the ESP8266 over the air to join existing wifi networks (and later version WeGrow.
- Code exhibiting memory size limits on the ESP.
- A (failed) attempt to abstract the control regime of joinme, Control Freak.
- Arduino-style libraries and sketches for an ESP-based sensor/actuator board: ARDESP.
This is all AGPL 3. Like it or lump it :-)
## Developing on the ESP8266 with NodeMCU- check out this tree including its submodules (third-party dependencies)
git clone --recursive git@github.com:hamishcunningham/fishy-wifi.git
- the Makefile assumes you've either checked out and rebuilt the open source
SDK (see below), or -- if you're on 64 bit Linux -- you're using the local
copy in
./esp8266-local-sdk
- there are targets for
- rebuilding the NodeMCU firmware (inc. with or without a DNS server)
make nodemcu[-with-dns]
- flashing the firmware (inc. to several choices of board)
- pull the relevant ESP pin low; cycle chip enable (or do a hard reset; the Olimex board always seems to require a hard reset) -- see below
make flashnodemcu
(for e.g. the ESP01 or other board with small flash)make flasholimex
(for e.g. the Olimex, 2MB flash)- disconnect the flashing pin and cycle chip enable (or hard reset) again
- rebuilding the NodeMCU firmware (inc. with or without a DNS server)
- running the ESPlorer development tool
- to pick up a set of useful code snippets, run
make seed-esplorer-prefs
- to run ESPlorer
make esplorer
- then do a scan, port open, etc.
- to pick up a set of useful code snippets, run
- uploading Lua code and experimenting
- have a poke around in e.g. the JoinMe code (below)
- open the
.lua
files in ESPlorer and save them to the ESP - restart the board and off you go (details here)
- running the MQTT Spy tool:
make mqtt-spy
If you're using a breadboard from me with a DIP switch, you can fiddle with the flashing pin and chip enable via that switch:
Flashing is enabled by setting switch 1 to on; chip enable is switch 5.
(Note: some of these are superseded by the above...)
Build open source toolchain:
- instructions from http://nathan.chantrell.net/20141230/wifi-mqtt-display-with-the-esp8266/
sudo apt-get install make unrar autoconf automake libtool gcc g++ gperf flex bison texinfo gawk ncurses-dev libexpat-dev python python-serial sed
cd esp-open-sdk
make STANDALONE=n
- Xtensa toolchain is built, to use it:
export PATH=${HOME}/fishy-wifi/esp8266-local-sdk/esp-open-sdk/xtensa-lx106-elf/bin:$PATH
- TODO is this nesc?
- Espressif ESP8266 SDK is installed. Toolchain contains only Open Source components To link external proprietary libraries add:
xtensa-lx106-elf-gcc -I${HOME}/fishy-wifi/esp8266-local-sdk/esp-open-sdk/sdk/include
-L${HOME}/fishy-wifi/esp8266-local-sdk/esp-open-sdk/sdk/lib`
Rebuild NodeMCU:
cd nodemcu-firmware
PATH=${PATH}:${HOME}/fishy-wifi/esp8266-local-sdk/esp-open-sdk/xtensa-lx106-elf/bin make
Flash the firmware to the ESP8266:
cd app
make flashnodemcu
or, for the Olimex board:
make flasholimex
Older methods:
.../esptool.py --port /dev/ttyAMA0 write_flash 0x00000
../bin/0x00000.bin 0x10000 ../bin/0x10000.bin 0x7E000 ../bin/blank.bin
0x7C000 ../bin/esp_init_data_default.bin
.../esptool.py --port /dev/ttyAMA0 write_flash 0x00000 ../nodemcu_512k_latest.bin
Rebuild ESPlorer:
ant -Dplatforms.JDK1.7.home=/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/ jar
Connect via picocom:
(first disable getty on /dev/ttyAMA0 via /etc/inittab)
picocom /dev/ttyAMA0 --omap crcrlf
(then toggle DTR to get elua prompt)
Picocom commands:
^A plus...
^T toggle DTR line
^U baud rate up (^D for down)
Wiring the ESP01 breadboard:
- red vcc
- black module gnd
- brown module rx
- gpio0
- black gnd
- white tx
Wiring the Olimex board:
- gpio 1 & 3 are rxt and txt
- need gpio 15 low and cp_en high
- to flash hold gpio0 low -- sometimes I think it doesn't float high so might try using 4.7k resistor to connect it to high?
- to get normal mode after flashing perhaps most useful
Luatool filetransfer thingy:
${HOME}/fishy-wifi/esp8266-local-sdk/luatool/luatool/luatool.py -p /dev/ttyAMA0 -f init.lua -t init.lua -v
- ESP8266 BB: http://www.esp8266.com/
- Wiki: https://github.com/esp8266/esp8266-wiki/wiki/
- NodeMCU: http://nodemcu.com/index\_en.html
- File API: https://raw.githubusercontent.com/nodemcu/nodemcu-firmware/master/app/modules/file.c
- Why not worth bothering with ad hoc Javascript PK encryption (do HTTPS instead): http://matasano.com/articles/javascript-cryptography/
- Chip datasheet: https://nurdspace.nl/images/e/e0/ESP8266\_Specifications\_English.pdf
- Nurdspace notes: https://nurdspace.nl/ESP8266
- Espressif BB: http://bbs.espressif.com/
- Olimex: https://www.olimex.com/Products/IoT/MOD-WIFI-ESP8266-DEV/