An Arduino library to give environmental sensors a common interface of functions for use with Arduino-framework dataloggers, such as the EnviroDIY Mayfly.
I would expect the Module to be treated as a device, rather a distributed database.
Treating it as a device recognizes that it goes through processes, power up/down, connect/disconnect - and has a finite life (especially persistent store, discussed as serial flash in the hardware data sheet)
These notes are made in case there is a need to rework the code, though I haven't tried any of the suggestions
a) use the AT+CWSTATE instead of AT+CIPSTATUS (deprecated)
b) only initiate credentials once every power up. AT+CWJAP="WiFiSsid","WiFiPwd"
However resending credentials forces the hardware to go through a re-initialization sequence.
It would be better to set it (or Audit) parameters once at system power up, and save it to persistent store. Then every access or power up should have the properties restored.
So device testing may need to be redone when CIPSATUS is removed.
Notes : It is recommended to use AT+CWSTATE command to query Wi-Fi state
Currently with the tests, it doesn't send the credentials the first time, but still works in connecting to NIST, perhaps because of previous connection.
[2023-07-08 15:40:32.908] ModemESP32 connected at baud 57600
[2023-07-08 15:40:32.923] AT+GMR
[2023-07-08 15:40:32.923] AT version:2.4.0.0(4c6eb5e - ESP32 - May 20 2022 03:11:58)
[2023-07-08 15:40:33.065] SDK vere2e) (OWIFI GOT IP
[2023-07-08 15:40:34.143] AT+UART_DEF?
[2023-07-08 15:40:34.147] +UART_DEF:57600,8,1,0,0
[2023-07-08 15:40:34.147]
[2023-07-08 15:40:34.147] OK
[2023-07-08 15:40:34.147] AT+UART_CUR?
[2023-07-08 15:40:34.147] +UART_CUR:57600,8,1,0,0
[2023-07-08 15:40:34.147]
[2023-07-08 15:40:34.147] OK
[2023-07-08 15:40:34.147] Attempting to connect to the internet and synchronize RTC with NIST
[2023-07-08 15:40:34.147] This may take up to two minutes!
[2023-07-08 15:40:34.147] AT
[2023-07-08 15:40:34.147]
[2023-07-08 15:40:34.147] OK
[2023-07-08 15:40:34.147] Tested AT command and got OK meaning ESP8266 must be awake <--EspressifESP8266
[2023-07-08 15:40:34.147] ESP8266 was already on! Will not run wake function. <--EspressifESP8266
[2023-07-08 15:40:34.147]
[2023-07-08 15:40:34.147] Waiting up to 700 ms for ESP8266 to respond to AT commands... <--EspressifESP8266
[2023-07-08 15:40:34.147] AT
[2023-07-08 15:40:34.147]
[2023-07-08 15:40:34.147] OK
[2023-07-08 15:40:34.157] ... AT OK after 24 milliseconds! <--EspressifESP8266
[2023-07-08 15:40:34.157] AT
[2023-07-08 15:40:34.157]
[2023-07-08 15:40:34.157] OK
[2023-07-08 15:40:34.157] ATE0
[2023-07-08 15:40:34.157]
[2023-07-08 15:40:34.173] OK
[2023-07-08 15:40:34.173] AT+CIPMUX=1
[2023-07-08 15:40:34.188]
[2023-07-08 15:40:34.188] OK
[2023-07-08 15:40:34.188] AT+CWMODE=1
[2023-07-08 15:40:34.204]
[2023-07-08 15:40:34.204] OK
[2023-07-08 15:40:34.220] ESP8266 should be awake and ready to go. <--EspressifESP8266
[2023-07-08 15:40:34.220] AT
[2023-07-08 15:40:34.220]
[2023-07-08 15:40:34.220] OK
[2023-07-08 15:40:34.220] Tested AT command and got OK meaning ESP8266 must be awake <--EspressifESP8266
[2023-07-08 15:40:34.263] Modem was already awake and should be ready. <--EspressifESP8266
[2023-07-08 15:40:34.263]
[2023-07-08 15:40:34.263] Attempting to connect to WiFi network... <--EspressifESP8266
[2023-07-08 15:40:34.263] AT+CIPSTATUS
[2023-07-08 15:40:34.263] STATUS:2
[2023-07-08 15:40:34.267]
[2023-07-08 15:40:34.283] OK
[2023-07-08 15:40:34.283] ... WiFi connected after 53 milliseconds! <--EspressifESP8266
[2023-07-08 15:40:34.314] AT+CIPSTATUS
[2023-07-08 15:40:34.314] STATUS:2
[2023-07-08 15:40:34.330]
[2023-07-08 15:40:34.330] OK
[2023-07-08 15:40:34.785]
[2023-07-08 15:40:34.785] Connecting to NIST daytime Server <--EspressifESP8266
[2023-07-08 15:40:34.785] AT+CIPCLOSE=0
[2023-07-08 15:40:34.785]
[2023-07-08 15:40:34.785] ERROR
[2023-07-08 15:40:34.801] AT+CIPSTART=0,"TCP","time.nist.gov",37,120
[2023-07-08 15:40:36.182] 0,CONNECT
[2023-07-08 15:40:41.193] AT+CIPSTART=0,"TCP","time.nist.gov",37,120
[2023-07-08 15:40:41.255] 0,CONNECT
[2023-07-08 15:40:41.287]
[2023-07-08 15:40:41.287] OK
[2023-07-08 15:40:41.318]
[2023-07-08 15:40:41.318] +IPD,0,4: Tdj
[2023-07-08 15:40:41.349] 0,CLOSED
[2023-07-08 15:40:41.397] NIST responded after 108 ms <--EspressifESP8266
[2023-07-08 15:40:41.428] AT+CIPSTATUS
[2023-07-08 15:40:41.428] STATUS:4
[2023-07-08 15:40:41.459]
[2023-07-08 15:40:41.459] OK
[2023-07-08 15:40:41.585] Response Byte 0 : = 232 = 11101000 <--LoggerModem
[2023-07-08 15:40:41.585] Response Byte 1 : T = 84 = 1010100 <--LoggerModem
[2023-07-08 15:40:41.585] Response Byte 2 : d = 100 = 1100100 <--LoggerModem
[2023-07-08 15:40:41.585] Response Byte 3 : j = 106 = 1101010 <--LoggerModem
[2023-07-08 15:40:41.585] Seconds from Jan 1, 1900 returned by NIST (UTC): 3897844842 = 11101000010101000110010001101010 <--LoggerModem
[2023-07-08 15:40:41.585] Unix Timestamp returned by NIST (UTC): 1688856042 <--LoggerModem
[2023-07-08 15:40:41.585] Time for Logger supplied by NIST: 1688827242 -> 2023-07-08T14:40:42-08:00 <--LoggerBase
[2023-07-08 15:40:41.585] Current Time on RTC: 1688827242 -> 2023-07-08T14:40:42-08:00 <--LoggerBase
[2023-07-08 15:40:41.585] Offset between NIST and RTC: 0 <--LoggerBase
[2023-07-08 15:40:41.585] Clock already within 5 seconds of time.
and then it connects first time
[2023-07-08 15:40:43.802] Waking up ESP8266 ... <--LoggerBase
[2023-07-08 15:40:44.901] OK
[2023-07-08 15:40:44.901] ... AT OK after 30 milliseconds! <--EspressifESP8266
[2023-07-08 15:40:44.901] AT
[2023-07-08 15:40:44.901] AT
[2023-07-08 15:40:44.901]
[2023-07-08 15:40:44.917] OK
[2023-07-08 15:40:44.917] ATE0
[2023-07-08 15:40:44.933] ATE0
[2023-07-08 15:40:44.933]
[2023-07-08 15:40:44.948] OK
[2023-07-08 15:40:44.948] AT+CIPMUX=1
[2023-07-08 15:40:44.964]
[2023-07-08 15:40:44.964] OK
[2023-07-08 15:40:44.990] AT+CWMODE=1
[2023-07-08 15:40:44.996]
[2023-07-08 15:40:44.996] OK
[2023-07-08 15:40:44.996] ESP8266 should be awake and ready to go. <--EspressifESP8266
[2023-07-08 15:40:45.027] Connecting to the Internet with ESP8266
[2023-07-08 15:40:45.027] AT
[2023-07-08 15:40:45.027]
[2023-07-08 15:40:45.027] OK
[2023-07-08 15:40:45.058] Tested AT command and got OK meaning ESP8266 must be awake <--EspressifESP8266
[2023-07-08 15:40:45.058] Modem was already awake and should be ready. <--EspressifESP8266
[2023-07-08 15:40:45.058]
[2023-07-08 15:40:45.058] Attempting to connect to WiFi network... <--EspressifESP8266
[2023-07-08 15:40:45.058] AT+CIPSTATUS
[2023-07-08 15:40:45.058] WIFI CONNECTED
[2023-07-08 15:40:45.090] STATUS:1
[2023-07-08 15:40:45.121]
[2023-07-08 15:40:45.121] OK
[2023-07-08 15:40:45.692] WIFI GOT IP
[2023-07-08 15:40:47.130] Sending credentials... <--EspressifESP8266
[2023-07-08 15:40:47.130] AT+CWJAP="WiFiSsid","WiFiPwd"
[2023-07-08 15:40:47.130] WIFI DISCONNECT
[2023-07-08 15:40:47.195] WIFI CONNECTED
[2023-07-08 15:40:48.197] WIFI GOT IP
[2023-07-08 15:40:48.235]
[2023-07-08 15:40:48.235] OK
[2023-07-08 15:40:48.235] Waiting up to 50 seconds for connection <--EspressifESP8266
[2023-07-08 15:40:48.251] AT+CIPSTATUS
[2023-07-08 15:40:48.251] STATUS:2
[2023-07-08 15:40:48.282]
[2023-07-08 15:40:48.282] OK
[2023-07-08 15:40:48.282] ... WiFi connected after 3238 milliseconds! <--EspressifESP8266
Currently, when testing and the SSID is turned off, the algorithm repeatedly sends Ssid/Pwd
Having no Ssid is a normal fault condition and it should do a reasonable check for it.
There may also be other errors as it seems to be sending
CWJAP_CUR
[2023-07-09 10:01:59.937] Waking up ESP8266 ... <--LoggerBase
[2023-07-09 10:01:59.937] Powering ESP8266 with pin 18 <--LoggerModem
[2023-07-09 10:01:59.937] AT
[2023-07-09 10:02:00.088] AT
[2023-07-09 10:02:00.235] AT
[2023-07-09 10:02:00.384] AT
[2023-07-09 10:02:00.546] AT
[2023-07-09 10:02:00.718] Tested AT command and got no response meaning ESP8266 is probably asleep <--EspressifESP8266
[2023-07-09 10:02:00.718] Running wake function for ESP8266 <--EspressifESP8266
[2023-07-09 10:02:00.718] Waiting for boot-up message from ESP8266 <--EspressifESP8266
[2023-07-09 10:02:00.984]
[2023-07-09 10:02:00.984] Waiting up to 700 ms for ESP8266 to respond to AT commands... <--EspressifESP8266
[2023-07-09 10:02:01.297] AT
[2023-07-09 10:02:01.297] AT
[2023-07-09 10:02:01.297]
[2023-07-09 10:02:01.297] OK
[2023-07-09 10:02:01.330] ... AT OK after 30 milliseconds! <--EspressifESP8266
[2023-07-09 10:02:01.330] AT
[2023-07-09 10:02:01.330] AT
[2023-07-09 10:02:01.330]
[2023-07-09 10:02:01.330] OK
[2023-07-09 10:02:01.330] ATE0
[2023-07-09 10:02:01.330] ATE0
[2023-07-09 10:02:01.330]
[2023-07-09 10:02:01.330] OK
[2023-07-09 10:02:01.330] AT+CIPMUX=1
[2023-07-09 10:02:01.330]
[2023-07-09 10:02:01.330] OK
[2023-07-09 10:02:01.330] AT+CWMODE=1
[2023-07-09 10:02:01.330]
[2023-07-09 10:02:01.330] OK
[2023-07-09 10:02:01.330] ESP8266 should be awake and ready to go. <--EspressifESP8266
[2023-07-09 10:02:01.330] Connecting to the Internet with ESP8266
[2023-07-09 10:02:01.330] AT
[2023-07-09 10:02:01.330]
[2023-07-09 10:02:01.330] OK
[2023-07-09 10:02:01.330] Tested AT command and got OK meaning ESP8266 must be awake <--EspressifESP8266
[2023-07-09 10:02:01.330] Modem was already awake and should be ready. <--EspressifESP8266
[2023-07-09 10:02:01.330]
[2023-07-09 10:02:01.330] Attempting to connect to WiFi network... <--EspressifESP8266
[2023-07-09 10:02:01.330] AT+CIPSTATUS
[2023-07-09 10:02:01.330] STATUS:1
[2023-07-09 10:02:01.330]
[2023-07-09 10:02:01.330] OK
[2023-07-09 10:02:03.229] Sending credentials... <--EspressifESP8266
[2023-07-09 10:02:03.230] AT+CWJAP="WiFiSsid","WiFiPwd"
[2023-07-09 10:02:18.251] +CWJAP:3
[2023-07-09 10:02:18.252]
[2023-07-09 10:02:18.252] ERROR
[2023-07-09 10:02:33.359] AT+CWJAP_CUR="WiFiSsid","WiFiPwd"
[2023-07-09 10:02:33.359]
[2023-07-09 10:02:33.359] ERROR
[2023-07-09 10:03:03.469] AT+CWJAP="WiFiSsid","WiFiPwd"
[2023-07-09 10:03:18.493] +CWJAP:3
[2023-07-09 10:03:18.495]
[2023-07-09 10:03:18.495] ERROR
[2023-07-09 10:03:33.604] AT+CWJAP_CUR="WiFiSsid","WiFiPwd"
..repeated ~ 5 more times
[2023-07-09 10:06:34.314]
[2023-07-09 10:06:34.314] ERROR
[2023-07-09 10:07:04.396] Waiting up to 50 seconds for connection <--EspressifESP8266
[2023-07-09 10:07:04.422] AT+CIPSTATUS
[2023-07-09 10:07:04.422] STATUS:5
[2023-07-09 10:07:04.448]
[2023-07-09 10:07:04.448] OK
[2023-07-09 10:07:04.711] AT+CIPSTATUS
[2023-07-09 10:07:04.728] STATUS:5
[2023-07-09 10:07:04.780]
[2023-07-09 10:07:04.780] OK
[2023-07-09 10:07:05.013] AT+CIPSTATUS
[2023-07-09 10:07:05.071] STATUS:5
[2023-07-09 10:07:05.080]
...
[2023-07-09 10:07:53.898]
[2023-07-09 10:07:53.898] OK
[2023-07-09 10:07:54.140] AT+CIPSTATUS
[2023-07-09 10:07:54.155] STATUS:5
[2023-07-09 10:07:54.188]
[2023-07-09 10:07:54.188] OK
[2023-07-09 10:07:54.452] AT+CIPSTATUS
[2023-07-09 10:07:54.468] STATUS:5
[2023-07-09 10:07:54.483]
[2023-07-09 10:07:54.510] OK
[2023-07-09 10:07:54.778] ... WiFi connection failed <--EspressifESP8266
[2023-07-09 10:07:54.778] Connected Internet Failed
[2023-07-09 10:07:54.778] PLO postLog file DBG2307.log res len 13 <--LoggerBase
[2023-07-09 10:07:54.809] Turning ESP8266 off. <--LoggerModem
[2023-07-09 10:07:54.809] Putting ESP8266 to sleep. <--LoggerModem
[2023-07-09 10:07:54.809] AT
[2023-07-09 10:07:54.809]
[2023-07-09 10:07:54.809] OK
[2023-07-09 10:07:54.809] Tested AT command and got OK meaning ESP8266 must be awake <--EspressifESP8266
[2023-07-09 10:07:54.841] Running given sleep function for ESP8266 <--LoggerModem
[2023-07-09 10:07:54.841] Requesting deep sleep for ESP8266 <--EspressifESP8266
[2023-07-09 10:07:54.842] AT+GSLP=0
[2023-07-09 10:07:54.842]
[2023-07-09 10:07:54.842] OK
[2023-07-09 10:07:54.842] Waiting 500 ms for graceful shutdown. <--LoggerModem
[2023-07-09 10:07:55.278] Turning off power to ESP8266 with pin 18 <--LoggerModem
`
The WiFi Bee ESP32-wroom-32 over 57K baud link works great in a recent series of integration tests. #194
The WiFi Bee ESP32-wroom-32 code repeatedly resends the credentials shown when in AT mode or DEBUG_DEEP
[2023-07-08 15:46:02.515] Sending credentials... <--EspressifESP8266 [2023-07-08 15:46:02.547] AT+CWJAP="WiFiSsid","WiFiPwd"
I would expect the Module to be treated as a device, rather a distributed database.
Treating it as a device recognizes that it goes through processes, power up/down, connect/disconnect - and has a finite life (especially persistent store, discussed as serial flash in the hardware data sheet)
These notes are made in case there is a need to rework the code, though I haven't tried any of the suggestions
a) use the AT+CWSTATE instead of AT+CIPSTATUS (deprecated) b) only initiate credentials once every power up. AT+CWJAP="WiFiSsid","WiFiPwd"
The documentation https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Set/Wi-Fi_AT_Commands.html?highlight=cwjap#cmd-jap suggest the command AT+CWJAP="WiFiSsid","WiFiPwd" this does not save it automatically to NVS area - which is good, as that could end up wearing out the flash.
However resending credentials forces the hardware to go through a re-initialization sequence. It would be better to set it (or Audit) parameters once at system power up, and save it to persistent store. Then every access or power up should have the properties restored.
The manual suggests https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Set/TCP-IP_AT_Commands.html?highlight=cipstatus#cmd-status AT+CIPSTATUS (deprecated): Obtain the TCP/UDP/SSL Connection Status and Information
So device testing may need to be redone when CIPSATUS is removed. Notes : It is recommended to use AT+CWSTATE command to query Wi-Fi state
Currently with the tests, it doesn't send the credentials the first time, but still works in connecting to NIST, perhaps because of previous connection.
and then it connects first time
Currently, when testing and the SSID is turned off, the algorithm repeatedly sends Ssid/Pwd Having no Ssid is a normal fault condition and it should do a reasonable check for it. There may also be other errors as it seems to be sending CWJAP_CUR