Troubleshooters Needed ESP8266 MailBox Notify

Hi all,
I am trying to make a snail mail notifier using an ESP01 module, a reed switch, and a 3.3v battery.
I am having trouble getting it working at all.

I assumed that enabling and disabling CH_PD a.k.a. CH_EN pin on the ESP8266 ESP01 would save more power than Deep Sleep mode. Is that correct?

The way my code is supposed to work is simply when reed switch momentarily conducts when the mailbox is opened, it enables ch_pd just long enough to run the first bit of code that toggles gpio2 high, which then keeps the module ON until the module connects to WiFi, sends a message through the blynk app, then toggles GPIO2 low, which pulls CH_EN low, powering off the module until the reed switch is tripped again when the mail arrives the next day.

Here’s my code:

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "300d08bbff5c48eb885ac66c6c0daff4";
void setup() {
pinMode(2, OUTPUT); //Reed switch pulls ch_pd aka ch_en pin HIGH briefly
digitalWrite(2, HIGH); //Stay on by keeping ch_pd HIGH
Blynk.begin(auth, "donowifi", "password"); 
Blynk.notify("Mail is here!"); 
digitalWrite(2, LOW); //Shutdown by pulling ch_pd LOW
}
void loop() {
yield();
}

Here’s my circuit:

Use ESP.deepsleep(0); then a reed switch attached between the required reboot pins.

On a NodeMCU/WeMos style, its between D0 and RST pin.

I’ve used deepsleep successfully, but I am trying to do it the way shown above because disabling the chip uses half of the power than using deep sleep does. Thanks for the tip, but what is your analysis of the circuit diagram and code above?

I have no experience with the ESP-01… just the later dev boards.

Deepsleep with an external trigger would use 20-60uA and would run on a cell battery for a number of years… im sure you would be replacing the battery more often than that :slight_smile:

If you come up with another way, please share it!

I think there is a limit of minutes to put ESP in a deep sleep state (about 60-70min)

He is trying to power down ESP and trigger only when needed like that
http://www.esp8266.com/viewtopic.php?f=11&t=4458&sid=1aa991ad53123f9b0f3c8b9763624803

or that

May I know what is your problem exactly?

@triops124 have a look at this example, specifically the wiring.

It does what you want but with a pir. Hope it can help.
http://www.esp8266.com/viewtopic.php?f=11&t=4458&hilit=sleep+and+wake+on+gpio2+low

Thanks for the help everyone!
I got it working intermittently by simply adding: delay(4000); just before digitalWrite(2, LOW);
I have no idea why adding a delay fixed the issue! I wish I knew why!

It would probably work just fine and not intermittently if I soldered the circuit instead of just twisting jumper wires together.

That being said, I watched a video on YouTube by Andreas Spiess, and he found (contrary to the esp8266 spec sheet) that chip disabled mode uses more battery power than deep sleep mode. It was helpful that he mentioned desoldering the red LED on the module saves considerable power during deep sleep.

Here is Andreas’ video: ESP8266 IFTTT Button

And so I will instead be using deep sleep mode instead with
| CH_PD & Vin --> battery VCC |
| GND --> Metal ball tilt switch --> battery ground. |
(All soldered together securely.)

I made a tilt/bump switch from a couple of steel balls, a straw, and some dupont arduino jumper wires, and it seems to be working just fine with the diagram below:

, The gist of the theory is that metal ball tilt switches, unlike mercury tilt switches, do not have solid electrical connections when bumped, even when upright. I’m taking advantage of that characteristic and using bumps to disrupt the power connection to the ESP01 module, causing it to restart without using the RESET pin.

Here is the new code:

// Metal Ball Tilt switch on Mailbox Door between CH_PD / VIN & battery VCC
//GND to battery GROUND
#define BLYNK_PRINT Serial  
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "AuthToken";

void setup()  
{
  Blynk.begin(auth, "WiFiSSID", "WiFiPassword");
}
void loop() {  // This entire part can also be in the setup() function  
  while (Blynk.connect() == false) {
    // Wait until connected
  }
  BLYNK_LOG("Switch Open");
  Blynk.email("me@example.com", "From Blynk", "Mail has arrived!");
  Blynk.notify("Mail is here!");
  BLYNK_LOG("Going to Sleep");
  ESP.deepSleep(0);
}

Have a nice day,

Triops.

1 Like