This time, it is about playing with a ESP-201 as well as with the Nodemcu devkit but without nodemcu (the firmware). Here are a few notes about what I discovered while playing with these boards.
As I mentioned in the past, starting with Arduino 1.6.4, there is now full support for ESP8266.
A majority of the Arduino's functions are directly available to be used of the ESP8266 and some additional libraries have been directly developed specifically. The libraries and documentation are changing extremely fast: between my first attempts in the summer and now, a lot of material was added.
The biggest hurdle with these chips seems that timing. While a "normal" Arduino will happily wait for any kind of event to happen, the ESP8266 tends to reset very easily. Too easily maybe and I wasn't able to do some tasks such as the La Crosse decoder and its strict timings.
There is more info about watchdog in the documentation and in this interesting blog entry about porting code from the Spark Core to the ESP8266.
But in practice, they are not used thanks to a clever system (See "USB TO UART" on the schematics)... Flashing mode and reset are done automatically!
Debug with GPIO2
The second Serial output is something nice and not widely documented with ESP8266 modules: GPIO2 (aka pin D4) can indeed be used for debug purpose.
For example on one of my modules, if I press reset, I obtain the following message:
ets Jan 8 2013,rst cause:4, boot mode:(3,7) wdt reset load 0x40100000, len 29132, room 16 tail 12 chksum 0x4c ho 0 tail 12 room 4 load 0x3ffe8000, len 2888, room 12 tail 12 chksum 0xf7 ho 0 tail 12 room 4 load 0x3ffe8b48, len 8, room 12 tail 8 chksum 0xbf csum 0xbf
Not extremely useful (except to check it is properly booting...) but there is more.
For example, on another module, here is the message when connecting to Wifi:
scandone f 0, scandone add 0 aid 1 pm open phy_2,type:2 0 0 cnt connected with MYSSID, channel 3 dhcp client start... ip:192.168.42.101,mask:255.255.255.0,gw:192.168.42.1
Moreover, it is also possible to write from the programme to this serial port and it is very easy. As the Arduino documentation put it:
To use Serial1, call Serial1.begin(baudrate).
But you have to remember that you can only write (only TX exists).
Simply connect GPIO2/D4 and GND to a serial adapter. Speed settings should be 115200 8N1 but as usual with these modules, your mileage may vary.
Different models of Nodemcu
There are quite a few versions of breakout board, all more or less compatible. Below a selection of the most famous ones (I am not even including the clones):
- Doit's NodeMCU (they seem to have "switched" to another MCU though. Cf WifiMCU)
- SparkFun ESP8266 Thing
- Adafruit HUZZAH
- Lolin/WeMos D1 mini
And all this without even mentioning the new generation!