HarringayMakerSpace / ESP-Now

ESP-Now Examples
303 stars 48 forks source link

espnow-sensor-timing.ino running on an ESP-01 does not dependably enter low power mode. #16

Closed st2000 closed 5 years ago

st2000 commented 5 years ago

espnow-sensor-timing.ino running on an ESP-01 with ESP8266 pin 8 connected to ESP-01 PCB Reset pin does not dependably enter low power mode. the ESP-01 appears to draw 0.351mA while the ESP8266 is asleep (there is a power LED still connected). The espnow-sensor-timing.ino wakes up the ESP-01 according to the random time-out value as expected. However, occasionally the current will remain high at about 67mA.

st2000 commented 5 years ago

This code change appears help. I changed this code:

esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER); esp_now_add_peer(remoteMac, ESP_NOW_ROLE_SLAVE, WIFI_CHANNEL, NULL, 0); esp_now_register_send_cb([](uint8_t* mac, uint8_t sendStatus) { Serial.printf("send_cb, send done, status = %i\n", sendStatus); gotoSleep(); }); uint8_t bs[sizeof(sensorData)]; memcpy(bs, &sensorData, sizeof(sensorData)); esp_now_send(NULL, bs, sizeof(sensorData)); // NULL means send to all peers }

...to this code:

esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER); esp_now_add_peer(remoteMac, ESP_NOW_ROLE_SLAVE, WIFI_CHANNEL, NULL, 0); esp_now_register_send_cb([](uint8_t* mac, uint8_t sendStatus) { Serial.printf("send_cb, send done, status = %i\n", sendStatus); gotoSleep(); }); gotoSleep(); /// Extra code which appears to make application work. uint8_t bs[sizeof(sensorData)]; memcpy(bs, &sensorData, sizeof(sensorData)); esp_now_send(NULL, bs, sizeof(sensorData)); // NULL means send to all peers } (edited)

...why the extra call to gotoSleep(); helps I do not understand. But I don't see long periods of high current draw (~70mA instead of < 1mA). And I don't see what appeared to be segmentation faults and hex dumps while monitoring the serial port.

st2000 commented 5 years ago

The problems seen have been traced back to a low current power supply. The assumption: When the WIFI radio was tuned on the voltage dropped which corrupted code execution and caused random problems including long periods of unexpectedly high current draw.