ESP8266/transistor cannot keep power on circuit (door sensor)

Thread Starter

NardJ

Joined May 26, 2015
2
Hi,

I am building a door sensor using a 3-pin switch, an ESP2866-01 (standalone) for communication to a server and a battery as power supply. (I'm using theArduino IDE for ESP 8266 to program the ESP2866 directly without the need to control it using a regular Arduino.)

Requirements of the setup are:
- door open and close events should be send to the server. (Door open is in fact powering on of ESP2866, door close can be detecting by change of switch state.
- power needs to be turned off when (or shortly after) the door is closed and the events are send to server, so the battery will last long.

I have build the attached circuit

The Arduino code is here: http://fritzing.org/media/fritzing-repo/projects/d/door-sensor-esp8266-on-battery/code/forumcode.ino

In the code on power up I set pin 0 to high to keep power on (circumventing the switch in case door is closed before esp can send data over wifi) however this does not seem to work. I suspect something is wrong with the circuit.

Any ideas?

(To be complete, I also have two other problems: an error generated by the reset method 'unknown opcode jmp' but this could be specific for the ESP2866 IDE environment; Also pin 2 is not registering the closing of the door / receiving 5V )


thx, Nard
 

ErnieM

Joined Apr 24, 2011
8,377
Q1 is set as an emiter follower, so it puts out the B-E drop less than goes in. So Vcc drops a bit when you depend on it for power.

But Vcc makes the pin voltage, so that drops too, so then Vcc follows, as does the pin.... it trickles out to zero.

When I has a similar issue I used a low dropout regulator (LDO) with an external enable pin to supply power. A switch and a controller pin were OR'ed together to enable the LDO. A button press would turn on the processor which would then enable the power for as long as needed.

Project link: http://forum.allaboutcircuits.com/threads/lv-switch-timer.74337/
 

Thread Starter

NardJ

Joined May 26, 2015
2
Thx, I think I understand the problem. So is it also possible to move the switch/transistor combo to the high power (9V) part of the circuit?
 

ErnieM

Joined Apr 24, 2011
8,377
It sounds like you are set on using the same LM1117 regulator. This is a 3 terminal device and had no enable input. I would place a high side transistor switch before the regulator as it too will draw current (5-10 mA) when it is on.

Your switch will go to the 9V source (as it is the only thing always on) so you need some network so it can drive the high side switch and also give you the "door open" signal. With a SPDT switch as you indicated these are two different paths for two functions so just a few resistors should do.
 
Top