PIR wake on motion. - Some questions.
Posted: Thu Sep 26, 2019 2:30 pm
Hiho,
I ve a problem: My batteries are empty after about 300 wakeups (each about 6-7 seconds to send a message to MQTT).
I use PIR (HC-SR501) to wake the ESP-12E on motion and have my circuty like this:
The only difference is that I used a ESP-12E and a transistor (HT7333) in between ESP-12E and power supply to get 3.3V.
The PIR (HC-SR501) is connected to battery pack 4.5V directly (3 x AA). (This will be changed later because I found out,
that there is a regulator to 3.3V in the PIR to, but that doesn´t matter atm).
While my tests a programmer (FTDI232) was permanent connected to (TX,RX,GND), but was powered by USB the hole time.
The main question is: Why are my batteries empty so fast? Did I something wrong ? What can I do better ?
My code for deepsleep, connection to WiFi and Mqtt where taken from my temp./light/hum. sensor project which
where messued with 24 uA consumption while in deepsleep mode and had (5000 wakeups without problems.
I noticed that the LED of the ESP is still on while in deepsleep. Even if I add to switch it off before sleeping.
Thanx for your help !
I ve a problem: My batteries are empty after about 300 wakeups (each about 6-7 seconds to send a message to MQTT).
I use PIR (HC-SR501) to wake the ESP-12E on motion and have my circuty like this:
The only difference is that I used a ESP-12E and a transistor (HT7333) in between ESP-12E and power supply to get 3.3V.
The PIR (HC-SR501) is connected to battery pack 4.5V directly (3 x AA). (This will be changed later because I found out,
that there is a regulator to 3.3V in the PIR to, but that doesn´t matter atm).
While my tests a programmer (FTDI232) was permanent connected to (TX,RX,GND), but was powered by USB the hole time.
The main question is: Why are my batteries empty so fast? Did I something wrong ? What can I do better ?
My code for deepsleep, connection to WiFi and Mqtt where taken from my temp./light/hum. sensor project which
where messued with 24 uA consumption while in deepsleep mode and had (5000 wakeups without problems.
I noticed that the LED of the ESP is still on while in deepsleep. Even if I add to switch it off before sleeping.
Code: Select all
....
// Thats the "outro" part:
// LED off:
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
StartDeepSleep();
WiFiOff();
void StartDeepSleep()
{
Serial.printf("Starting Deepsleep seconds: ");
Serial.println((int)DEEPSLEEP);
//ESP.deepSleep(CalcSecSleepTime(), WAKE_RFCAL);
ESP.deepSleep(CalcSecSleepTime(), WAKE_RF_DISABLED );
delay(100);
}
uint64_t CalcSecSleepTime()
{
uint64_t accumulator = DEEPSLEEP * 1000000;
return accumulator;
}
void WiFiOff()
{
Serial.println("diconnecting client and WiFi.");
WiFi.forceSleepBegin();
wifi_station_disconnect();
wifi_set_opmode(NULL_MODE);
wifi_set_sleep_type(MODEM_SLEEP_T);
wifi_fpm_open();
delay( 1 );
}
Thanx for your help !