Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By kolalde
#41691 Very cool. I had a similar problem, needing to tell the difference between reset from deep sleep and an external trigger. I like your approach, mine included another switch.

Can I get some pointers on the use of the HCT132 and the RC circuit? How does closing the TP1/2 lines result in a momentary pulse? I can follow the logic gates through to pulling reset low, but what makes it momentary? If the alarm condition persists how often is reset pulsed?

I think I understand the delay introduced to pull pins 4 and 5 high (http://ladyada.net/library/rccalc.html), but not really. What discharges the cap?
User avatar
By kolalde
#41773 I think I understand now, here's what I did.

Created the circuit. I left out the ESP and just used a HCT132 (actually had one on hand), and included two leds, one where GPIO14 would be and another to watch the reset line. I also pulled pin13 high to disable reset due to ESP waking up (test circuit drawing attached).

To answer my questions:
- power the circuit, pin1&2 are high, pin8 (RESET) is high, so the ESP would boot.
- When TP1 is connected to GND, pulling HCT1&2 low. Pin3 goes high and lights the LED1, usually read by GPIO14. Pin8 is now low, holding the ESP in reset.
- the 1M resistor slowly drains the 220uF cap that was charged when HCT pins1&2 were pulled to ground. Seems to take roughly 4.5 minutes. I'd guess this is to ensure the water sensor is really triggered, or does it reduce current draw, or? Once it drops to logic 0, HCT pins 4&5 are low which results in pin8 high, letting the ESP boot. Pin3 is still high, as is my LED1 and GPIO14, so the ESP can see the alarm state (different than just waking up out of sleep).

Cool.

I don't know the characteristics of the water sensor, but what happens if it bounces over a couple seconds? Again, no clue, but I'm guessing the HCT132 takes care of signal bounce in the under ms range, but if it bounces before the cap is drained, it just looks like it woke from deep sleep, right? No harm, batt check and email a little early.

BTW, I also learned a clone Saleae logic analyzer has a unfortunate feature. The test leads actually output around 3.3v around 3ma. I'm guessing its weak enough to not get in the way of I2C or TTL serial analysis, what I've successfully used the device for, but gets in the way if it charges a cap that you don't want charged...
You do not have the required permissions to view the files attached to this post.
User avatar
By gulaschcowboy
#41829 Hi, the code is exactly what i was looking for my low power, battery driven bee scale. But it didn't work for me, as the RTC didn't kept the values over the reset cycles. In another post I found, that the RTC values need to be aligned. So i changed

Code: Select allbyte buf[10];

to
Code: Select allbyte buf[10] __attribute__((aligned(4)));


I'm not a real coder, so don't ask me what it does, but now it works for me (tm)

HTH
Alex
User avatar
By RainerOchs
#42038
kolalde wrote:- the 1M resistor slowly drains the 220uF cap that was charged when HCT pins1&2 were pulled to ground. Seems to take roughly 4.5 minutes.


My design uses a 100nF (not uF) with a 4M7 Resistor what makes a time constant of about half a second. This is enough for the ESP to reset.

Bouncing: Due to the time constant, bouncing below this is filtered out. When a event is triggered and the email-sending process starts it may be re-triggered by bouncing. In this case the actual sending is interrupted and started again. As it needs considerable time until the mail is sent, this rarely is a problem.
If this however results in a problem it is easy to filter this out in software.
Rainer