I was on holiday over the weekend and the unit works like a charm, I was notified of all activities detected by the PIR set above my main door.
With wifi_station_set_auto_connect(TRUE) the constant tries to connect to a missing AP or wrong password will run the batteries flat in no time.
Default retries is now set to 4 in which after that the ESP8266 will go in deep sleep to conserve power.
nodemcu is a wonderful piece of code but it don’t work well on my ESP-01, it will go into a boot loop with just a few lines of code. Initially I though it was my mistake but it does that even with published examples.
Moving on, I took a bit of time to set up esp-open-sdk and started to work on what I think will be a base for my future ESP8266 projectts.
My basic code is based on tuanpm’s native mqtt library and stdout which reclaims the RX pin for use as GPIO3.
The code basically logs on to my wifi AP then to the MQTT broker (mosquitto) on my server. By default, I can control a LED connected to GPIO2 by publishing a 1 or 0 to the topic subscribed by the ESP-01 and read a switch on GPIO0. RX/GPIO3 can be configure for other use.
Code available on my Github repository.