1
\$\begingroup\$

My goal is to reset an ESP8266 in deep sleep (pull RST low) when the value of my float sensor changes (which detects the water level in a tank), so that I can report the value change to the IoT platform. It's a low power design, so the MCU should sleep as much as possible.

Edit: At first it seemed like the sensor value was on/off, but on second thoughts, it could be analog. I'll do some testing and update.

I created a dual edge monostable trigger which wakes the MCU when the value changes. Is this the best approach for low power, or is there a better solution?

Can the monostable I came up with be improved? I designed a circuit which I can make out of junkbox parts, but it doesn't need to be, I'm happy to use an IC or MCU feature instead. I'm also happy to use a different MCU.

schematic

simulate this circuit – Schematic created using CircuitLab

Note: Clock signal and Q10 simulates the sensor value changing; purely for simulation and not actually part of the real circuit.

Monostable inputs Monostable output

Edit: I see from an answer on a similar question that PIC micros have something called "interrupt on change". I see that ESP8266 has GPIO interrupts, but it looks like only a specific pin can be used to wake from deep sleep. It looks like the ESP32 can wake from different GPIOs, but can it wake on either falling or rising edge? Also, from the same answer I see that I might have created an "edge to glitch converter"... is my circuit a good or a bad example of such a design?

Edit: Below image is the float sensor. Unfortunately, I'm not sure where the datasheet is, but I'll do some testing to see if it's digital or analog.

Float sensor

Edit: After testing, I see that the sensor produces a digital signal, as I had hoped.

Float sensor signal

\$\endgroup\$
11
  • \$\begingroup\$ What do you mean by this: when the value of my float sensor changes <-- it sounds like an analogue value you are describing but, it looks like you are treating it as an on/off digital value. \$\endgroup\$
    – Andy aka
    Commented Jan 8, 2023 at 12:54
  • 1
    \$\begingroup\$ OK, that makes it simpler. If you are happy with your circuit then go for it. Of course, if you had an exclusive OR gate as per this... but I think you have read that!! \$\endgroup\$
    – Andy aka
    Commented Jan 8, 2023 at 13:20
  • 1
    \$\begingroup\$ The commercial low power door/window Wifi switches I’ve seen use a small low power microcontroller to switch power to the esp8266 via a high side mosfet There’s probably a good reason why they do this. \$\endgroup\$
    – Kartman
    Commented Jan 8, 2023 at 13:31
  • 1
    \$\begingroup\$ Yes @NickBolton, you can buy single device XOR gates with a SOT-23 footprint if that helps. \$\endgroup\$
    – Andy aka
    Commented Jan 8, 2023 at 16:04
  • 1
    \$\begingroup\$ @Andyaka Thanks, yes it looks like the XOR with delay would be a much better solution than my junkbox monostable circuit. The XOR delay uses less components and produces a great signal. My monostable circuit doesn't produce a very clean signal, which I'm sure could be fixed but would require even more components. The XOR on the other hand produces a perfect signal! Pretty sure I actually have an XOR gate DIP too. \$\endgroup\$ Commented Jan 8, 2023 at 22:04

1 Answer 1

2
\$\begingroup\$

Edit: I turned this into a GitHub project.

Revision 1

I refined the circuit after testing with the MCU. The pull up for the float sensor was consuming a little more power than I wanted, so I had to tweak the design to work with a 100k pull up.

Also, it turns out, Q1 alone was not enough to pull the MCU RST pin low. When in deep sleep (and D0 is connected to RST), the pin is pulled high with a fairly strong internal resistor, maybe 1k? So, the weak current on Q1 base was not enough to pull RST low. So, I added an amplifying NPN (Q11 below).

schematic

simulate this circuit – Schematic created using CircuitLab

R25 and R23 are actually 500k in the real circuit. I can't seem to get the simulation to work with those values, but 1M and 5M seem to yield a nice graph.

Graph

Graph

Revision 2

I realised that I now have 3 BJTs, and a potentially unnecessary diode, so I rearranged the circuit to remove the diode. I had to change R28 to 1k (otherwise the falling edge trigger wouldn't be strong enough to pull RST low), but the graph still looks good and it apparently manages to pull the RST pin low. I haven't tried the 2nd revision as a real circuit yet though.

schematic

simulate this circuit

After this 2nd revision, I noticed something. My circuit is starting to look very similar to Olin Lathrop's dual edge monostable.

Of course, an exclusive XOR gate and delay circuit would probably be the simpler approach. As Andy aka mentions in the comments...

you can buy single device XOR gates with a SOT-23 footprint

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.