1

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

Nick Bolton
  • 2,043
  • 8
  • 31
  • 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. – Andy aka Jan 08 '23 at 12:54
  • Ah, you know, I thought it was on/off, but actually there might be a long rise/fall time depending on how fast/slow the water rises. I'll do some more testing with the sensor to see if it has a clean edge on the transition (something tells me it might not). – Nick Bolton Jan 08 '23 at 12:56
  • Tested. Thankfully the signal from the sensor is digital. – Nick Bolton Jan 08 '23 at 13:09
  • 1
    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](https://electronics.stackexchange.com/questions/270894/dual-edge-detector/270903#270903)... but I think you have read that!! – Andy aka Jan 08 '23 at 13:20
  • 1
    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. – Kartman Jan 08 '23 at 13:31
  • @Kartman Great solution! Yeah I wondered about doing that, especially the ESP8266 can use about 0.5mA or so while in deep sleep which isn’t negligible on a super low capacity battery. Mine is 250mAh with a solar panel though so should be fine in deep sleep. – Nick Bolton Jan 08 '23 at 15:07
  • @Andyaka You’d use an IC for the XOR circuit, right? – Nick Bolton Jan 08 '23 at 15:09
  • 1
    Yes @NickBolton, you can buy single device XOR gates with a SOT-23 footprint if that helps. – Andy aka Jan 08 '23 at 16:04
  • ESP can wake up from sleep with a pin change interrupt. Not all pins support it, but it should work in your case. – bobflux Jan 08 '23 at 17:14
  • You mean ESP32? The 8266 only has 1 wake pin and needs a pulsed GND signal to wake – Nick Bolton Jan 08 '23 at 17:40
  • 1
    @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. – Nick Bolton Jan 08 '23 at 22:04

1 Answers1

2

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

Nick Bolton
  • 2,043
  • 8
  • 31