Hi,
I’m trying to put together a super low energy usage application, where it would wake up every few minutes to take a quick reading from a sensor and then go back to sleep, then after so many reading it would fully wake and connect to send the data.
The taking a reading should take around 100ms and am hoping to wake,read and go back to sleep in under 300ms, however it’s taking 4-9seconds due to ESP32 being initialized, even when I’ve specified it to be off. Is there a SYSTEM_FEATURE or similar to tell the firmware to not even begin to initialize the wifi module?
Below is a log of what I’m seeing. After 0000000532 the logging is capturing interaction with the Wifi Module. Even when the code setup has WiFi.off() as its first line.
0000000272 [lu] INFO: Scanning I2C bus
0000000324 [lu] INFO: Processing :1
0000000376 [lu] INFO: Processing :2
0000000428 [lu] INFO: Processing :3
0000000480 [lu] INFO: Processing :4
0000000532 [lu] INFO: Processing :5
0000001563 [ncp.at] TRACE: > AT
0000001564 [ncp.at] TRACE: < OK
0000002564 [hal] TRACE: NCP ready to accept AT commands
0000002564 [ncp.at] TRACE: > AT+CMUX=0
0000002566 [ncp.at] TRACE: < OK
0000002568 [gsm0710muxer] INFO: Starting GSM07.10 muxer
0000002580 [gsm0710muxer] INFO: Openning mux channel 0
0000002580 [gsm0710muxer] INFO: GSM07.10 muxer thread started
0000002603 [lu] INFO: Processing :6
0000002652 [gsm0710muxer] INFO: Resuming channel 0
0000002652 [gsm0710muxer] INFO: Openning mux channel 1
0000002654 [lu] INFO: Processing :7
0000002722 [lu] INFO: Processing :8
0000002753 [gsm0710muxer] INFO: Resuming channel 1
0000002753 [gsm0710muxer] INFO: Resuming channel 1
0000002754 [ncp.at] TRACE: > AT
0000002774 [lu] INFO: Processing :9
0000002806 [ncp.at] TRACE: < OK
0000002806 [ncp.at] TRACE: > AT+CWDHCP=0,3
0000002826 [lu] INFO: Processing :10
0000002856 [ncp.at] TRACE: < OK
0000002856 [hal] TRACE: NCP state changed: 1
0000002856 [net.esp32ncp] TRACE: NCP event 1
0000002857 [ncp.at] TRACE: > AT+GETMAC=0
0000002878 [lu] INFO: Processing :11
0000002906 [ncp.at] TRACE: < +GETMAC: "30:ae:a4:d1:f7:cc"
0000002906 [ncp.at] TRACE: < OK
0000002907 [gsm0710muxer] INFO: Stopping GSM07.10 muxer
0000002911 [gsm0710muxer] INFO: Gracefully stopping GSM07.10 muxer
0000002923 [gsm0710muxer] INFO: Closing all muxed channels
0000002933 [gsm0710muxer] INFO: Closing mux channel 1
0000002946 [gsm0710muxer] INFO: Muxed channel 2 already closed
0000002955 [gsm0710muxer] INFO: Muxed channel 3 already closed
0000002968 [gsm0710muxer] INFO: Muxed channel 4 already closed
0000002978 [lu] INFO: Processing :12
0000003041 [lu] INFO: Processing :13
0000003078 [gsm0710muxer] INFO: Sending CLD (multiplexer close down)
0000003093 [lu] INFO: Processing :14
0000003128 [gsm0710muxer] INFO: Received response to CLD or timed out, exiting multiplexed mode
0000003128 [gsm0710muxer] INFO: GSM07.10 muxer thread exiting
0000003154 [gsm0710muxer] INFO: GSM07.10 muxer stopped
0000003155 [hal] TRACE: NCP state changed: 0
0000003155 [net.esp32ncp] TRACE: NCP event 1
0000003168 [lu] INFO: Processing :15
0000003219 [lu] INFO: Processing :16
Code used
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(MANUAL);
Logger lu("lu");
StreamLogHandler* loggingHandler;
void scan_i2c_bus() {
lu("Scanning I2C bus");
String found;
String errors;
for(int address = 1; address < 127; address++ )
{
Wire.beginTransmission(address);
uint8_t error = Wire.endTransmission();
lu("Processing :%d",address);
if (error == 0)
{
found += String::format("[%02x]", address);
}
else if (error==4)
{
errors += String::format("[%02x]", address);
}
}
lu("I2C devices at addr %s", found.c_str());
if (errors.length() > 0) {
lu("I2C errors at addr %s", errors.c_str());
}
lu("Finished scanning I2C bus");
}
void setup() {
WiFi.off();
loggingHandler=new Serial1LogHandler(57600,LOG_LEVEL_ALL,{{ "lu",LOG_LEVEL_ALL}});
Wire.begin();
scan_i2c_bus();
lu("Done Setup");
}
void loop() {
delay(5000);
}