I have been working on making homemade motion sensors that send an email message when triggered. There are many example instructables and other examples of doing this. I recently needed to do this with a battery operated PIR motion sensor and an ESP-01. The ESP-01 is very functional and has all the capabilities required so why not use the minimum and least expensive necessary? Added to the mix was another separate and remote ESP-01 module that triggered a buzzer when the motion sensor was triggered.
The code and eventual circuit layout has been gathered from numerous sources across the web and I don’t think I can identify them specifically. The idea of sending emails via gmail came from an instructable and other sources and the final code is an amalgam from those sources. Getting deep sleep to work led me on many paths that often proved fruitless. Funny thing is, once a path proves fruitful, you stop looking for more paths. So I say thanks to all those who have contributed to my success and are yet unknown.
I had the same issue getting the PIR sensor to work at triggering the ESP-01 deep sleep. Many paths until there was one that worked.
Needless to say, there were some interesting hurdles or perhaps more relevant, a better understanding of the electronics that I required. You keep learning until something works and then you don’t have to learn any more.
The ESP-01 does deep sleep as well as any other ESP8266 module as long as you don’t require timed sleep. If you want the module to wake after a set amount of elapsed time, The ESP-01 is not the module to use. But that is not what I wanted. Elapsed time is pointless when using a PIR. I wanted the ESP-01 to waken only when triggered by motion sensed by the PIR. If there is no motion sensed for hours or days, the ESP-01 stays asleep using minimal battery power.
You will see many circuits that use GPIO16 connected to the ESP8266 Reset because GPIO16 is the wake signal. This is true, but it is the wake signal from timed sleep. We can ignore this PIN, which is good because it is not available on the ESP-01.
Basically, all we need is to get the signal from the PIR to trigger the ESP-01 Reset pin. The first difficulty you will surmise is that Reset is triggered on a LOW signal and the PIR sends a HIGH signal when triggered. Reset also needs to be HIGH or floating on boot. So to keep this short, after trying some different circuits I settled on using an NPN transistor with a pull-up resistor to keep the RESET pin HIGH during boot. The output from the PIR is minimal but it provides enough base current turn the transistor on.
As you will see in the circuit diagram below, the ESP-01 was awakened from deep sleep every time the PIR sensed motion.
But there was another problem. The Reset of the ESP-01 only happened after the PIR stopped sensing motion and returned to a low signal turning off the transistor and returning the Reset pin to HIGH because of the pullup resistor. This would mean that the email would not be sent, nor would the buzzer be activated until AFTER the PIR stopped sensing motion. I wanted the trigger to happen as soon as motion was sensed.
What I determined from this behaviour is that the ESP-01 actually triggers on the rising edge of the signal. Holding the Reset pin to ground does not actually trigger the ESP-01 from deep sleep but the moment the voltage rises to the HIGH signal, then the reset happens.
My very simple response to this behaviour was to add a capacitor to the line between the PIR output and the transistor base. This caused the transistor to only turn on while the capacitor was charging. Once charged, there was no further current and the transistor turned off. The 5k resistor allows the current to drain to ground. I tested this with an LED in place of the ESP-01 and could see the LED flash on for a fraction of a second before turning off. This little pulse was enough to pull the Reset pin to ground momentarily and long enough to trigger the Reset out of deep sleep.”

Link