Chat freely about anything...

User avatar
By nohepe
#62913 Hello,

In my project I would like to create low power consumption sensor, that react to external event. I can use ESP-12 and ESP-01 (If this is possible on 01) but they behave in same way I suppose. I use NodeMCU firmware. I would like to set up folowing setups:

ESP12 + PIR sensor
ESP12 + magnetic reed sensor
ESP12 + button

ESP will by powered from battery. Battery will be connected via voltage regulator. My intent is to send ESP to deep sleep for maximal amount of time (71 minutes or so). During those 71 minutes, I would like to wake module up, if event occur.

In that case, I perhaps need to connect RST to GPIO16(time interrupt) and also to output of my sensor. I do not know whether I can connect that RST directly to PIR, reed switch or button.

In case of button, my first intent is to connect button directly to regulated 3.3V source and RST pin, if button is pressed, then 3.3V signal will be send to RST pin and ESP should wake up.
Im little bit worried wheter this can work, since one button press can generate more short signals(physical contact problem) - is that problem for ESP? I think that it can receive many signals in short interval - will it reset MCU after every signal? This can cause many restarts under one second - which I think can damage ESP? If so, is there some circut that can regulate those signals from button to exact one correct signal?

This "multiple signal problem" also applies to PIR and magnetic reed sensor.

I am not sure also whether power regulator is ideal solution? If I connect for instance button or magnetic reed to that regulator, does that consume energy also if button/magn contact is disconnected?

Thank you and please ask if something is unclear.
User avatar
By giraffe81
#62923 I did something similar to this, but not quite as complex. My example might help you to get some of the way to achieving this.

From what I understand the ESP doesn't support wake up from external trigger, the only way is to reset it. From what you wrote I think you have already established this, however you have talked about pulling RST high in order to reset the module where as you actually need to pull to ground.

I wanted my ESP to be in a sleep state until an external button was pressed. For this I connected the base of a NPN transistor to GPIO16 as pin 16 goes high once in deep sleep. Then I connected RST to the collector, and the emitter to my push switch and then to ground. Doing this ensures that the push switch doesn't reset the device when it is awake as I used the same button to control the ESP when in use. I don't have the code to hand but I believe you can make it sleep forever by passing -1 to the ESP sleep function.

You should be able connect your PIR or reed switch in the same configuration I have so it will reset the device if in deep sleep. However this would cause issues if you also had GPIO16 connected to RST in order to perform timed wake ups. You probably have a pullup on RST, this current would flow via your GPIO16 connection to the base of the transistor meaning your PIR would always reset the ESP not just when in deep sleep.
User avatar
By nohepe
#62927
giraffe81 wrote:From what I understand the ESP doesn't support wake up from external trigger, the only way is to reset it. From what you wrote I think you have already established this, however you have talked about pulling RST high in order to reset the module where as you actually need to pull to ground.


That RST pin is I would say "oficial way to wake up device while it is in deep sleep". This is quote from oficial NodeMCU reference:

This function can only be used in the condition that esp8266 PIN32(RST) and PIN8(XPD_DCDC aka GPIO16) are connected together. Using sleep(0) will set no wake up timer, connect a GPIO to pin RST, the chip will wake up by a falling-edge on pin RST.


But it is not important how we call that "wake up" or "reset". Important thing for me is that we can omit slep time period and set it to 0 as you did. Then it can be in deep sleep forewer and wake up only if signal is sent to RST(down). Can you confirm that?

I wanted my ESP to be in a sleep state until an external button was pressed. For this I connected the base of a NPN transistor to GPIO16 as pin 16 goes high once in deep sleep. Then I connected RST to the collector, and the emitter to my push switch and then to ground. Doing this ensures that the push switch doesn't reset the device when it is awake as I used the same button to control the ESP when in use. I don't have the code to hand but I believe you can make it sleep forever by passing -1 to the ESP sleep function.


This can help me alot! I would like to omi time wake ups then.

Can you please share some schematics, how you connected the circuit? Which components did you use? Since I am novice in electo - related stuff I would really appreciate it.

Thank you
User avatar
By giraffe81
#62938 I too am a novice so I am sure someone else will chip in with more info. I used a 2n3904 transistor, but you could use something similar. The schematic for this is as follows:

Image

Yes, I have my ESP in perminant deep sleep. A button press wakes it up, I then start a new timer which sends it back to sleep if no interaction happens for 30 seconds. Hope this helps