The hardware is the same as the previous article. If you are following along but have not read the previous article, please do so now. We will not repeat anything that has been previously documented, so let's jump right into loading the new sketch.
With this sketch loaded, the serial monitor should present to you something similar to the following:
*WM:When the device boots up, it will attempt to connect to the wireless network saved in its config. Since it won't have a config the first time it boots up, it will instead change into access point mode and wait for you to connect to it and program it. Let's do that now.
*WM: AutoConnect
*WM: Reading SSID
*WM: SSID:
*WM:
*WM: Reading Password
*WM: Password:
*WM: Connecting as wifi client...
*WM: Connection result:
*WM: 0
*WM:
*WM: Configuring access point...
*WM: ESP8266AutoConnectAP
*WM: electricity
*WM: AP IP address:
*WM: 192.168.4.1
*WM: HTTP server started
From any mobile device or wireless pc, connect to the wireless network named "ESP8266AutoConnectAP" using a password of "electricity". Once connected, open a browser and point it to "192.168.4.1". You will be presented with a screen similar to the one shown in the figure.
WiFiManager Initial Screen |
You can have the ESP8266 scan for WiFi networks around you, but it is faster to just type in your WiFi network credentials manually.
Clicking "Configure WiFi (No Scan)" will present you with the following screen.
WiFi Manager Configuration Screen |
Unlike the figure, help text will appear in each field as long as there are no parameters already typed into it. The fields should be self explanatory. Click the Save button when you are done. The device will attempt to reconnect as a client to the WiFi network you specified. If if is successful, it will not return to access point mode.
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Connection result:
*WM: 3
Should save config
WiFi Connected!
saving config
{"zm_server":"192.168.1.122","zmtrigger_port":"6802","monitor_id":"2","alarm_delay":"10","alarm_score":"200","alarm_cause":"Barking detected","alarm_desc":"Go see what the dogs are barking at."}
HTTP server started
WiFi Status
IP address: 192.168.1.196
MAC address: 5C:CF:7F:0B:2F:18
SSID: mgmt
Signal Strength (dBm): -49
From this point on, the device will work just like the previous article. Pressing the button wired to GPIO2 will cause the ESP8266 to trigger an alarm on the ZoneMinder server. Alternatively, the status of GPIO0 and GPIO2 can be actively polled using http as well.