How to use a low-signaling sensor to trigger wake interrupt
Posted: Wed May 20, 2020 2:00 am
I would have posted this in the ESP8266 forum, but it's really more of an electronics question, and probably a really basic one at that, given that I'm a software person with minimal electronics wherewithal.
The ESP8266 and its support boards (such as the ESP-01S) can go into deep sleep and then awaken in various ways, such as an alarm at a later time, or in the case of this post, on an interrupt on a particular pin. The ESP8266 has a reset pin that is held high even in deep sleep. If you connect it to ground, the board immediately resets (if it is awake) or immediately boots up (if it is asleep). So if a trigger sensor, such as an IR proximity sensor with an incorporated binary threshold (as opposed to using the sensor's smooth analog distance reading) sudden triggers, it can be used to ground the reset pin and boot the chip.
But the IR sensor I'm working with (one of the common ones you see everywhere, https://www.aliexpress.com/item/32321964595.html) has off-high/on-low logic. While output is high, indicating no proximity, I need the reset pin to be left alone. When the signal goes low, I need the reset pin to suddenly go low. At first, this seemed perfect to me. I would just feed the signal output directly into the reset pin. While the signal was high, the reset would hold high. When the signal went low, the reset would go low and trigger a wakeup. But this doesn't work. I suspect it is the difference between a high/low "signal" and a high/low direct connection to the primary ground of the main power circuit. Is the low signal not the same ground circuit as the chip's main power circuit? I would have thought so since I'm powering the sensor from the board's power supply, but it doesn't work. A multimeter confirms this signal voltage but the reset fails to occur, so I'm perplexed. I know that directly grounding the reset pin with a wire or a simple momentary switch works exactly as expected, but utilizing the sensor's output in this straightforward fashion fails to reset the chip, so I'm misunderstanding something probably really basic here.
At any rate, I figured I'd switch it with a transistor instead. I have a 2n7000 NPN transistor that I attempted to use as a switch, with the source/drain connecting the reset pin to ground and the gate connecting to the signal, but since the signal's logic is inverted, it obviously doesn't work right. The transistor is presumably on when it should be off and vs/va due to the sensor's inverted signal logic. I presume it would do exactly what I want it to do if the sensor was off-low/on-high, right?
I'm probably making this all needlessly complicated. What is the right way to have a sensor of this type pull the reset pin to ground to trigger the chip to wake up? I would prefer a solution that doesn't involve ordering and waiting for new parts (I'm suspicious of the possibility that the solution to my problem is the opposing transistor type, but I don't have any lying around).
Curiously, if I send the control signal straight into the CHPD pin instead, to effectively turn the board off, that works perfectly, but the reset pin doesn't do the same thing.
Thanks.
The ESP8266 and its support boards (such as the ESP-01S) can go into deep sleep and then awaken in various ways, such as an alarm at a later time, or in the case of this post, on an interrupt on a particular pin. The ESP8266 has a reset pin that is held high even in deep sleep. If you connect it to ground, the board immediately resets (if it is awake) or immediately boots up (if it is asleep). So if a trigger sensor, such as an IR proximity sensor with an incorporated binary threshold (as opposed to using the sensor's smooth analog distance reading) sudden triggers, it can be used to ground the reset pin and boot the chip.
But the IR sensor I'm working with (one of the common ones you see everywhere, https://www.aliexpress.com/item/32321964595.html) has off-high/on-low logic. While output is high, indicating no proximity, I need the reset pin to be left alone. When the signal goes low, I need the reset pin to suddenly go low. At first, this seemed perfect to me. I would just feed the signal output directly into the reset pin. While the signal was high, the reset would hold high. When the signal went low, the reset would go low and trigger a wakeup. But this doesn't work. I suspect it is the difference between a high/low "signal" and a high/low direct connection to the primary ground of the main power circuit. Is the low signal not the same ground circuit as the chip's main power circuit? I would have thought so since I'm powering the sensor from the board's power supply, but it doesn't work. A multimeter confirms this signal voltage but the reset fails to occur, so I'm perplexed. I know that directly grounding the reset pin with a wire or a simple momentary switch works exactly as expected, but utilizing the sensor's output in this straightforward fashion fails to reset the chip, so I'm misunderstanding something probably really basic here.
At any rate, I figured I'd switch it with a transistor instead. I have a 2n7000 NPN transistor that I attempted to use as a switch, with the source/drain connecting the reset pin to ground and the gate connecting to the signal, but since the signal's logic is inverted, it obviously doesn't work right. The transistor is presumably on when it should be off and vs/va due to the sensor's inverted signal logic. I presume it would do exactly what I want it to do if the sensor was off-low/on-high, right?
I'm probably making this all needlessly complicated. What is the right way to have a sensor of this type pull the reset pin to ground to trigger the chip to wake up? I would prefer a solution that doesn't involve ordering and waiting for new parts (I'm suspicious of the possibility that the solution to my problem is the opposing transistor type, but I don't have any lying around).
Curiously, if I send the control signal straight into the CHPD pin instead, to effectively turn the board off, that works perfectly, but the reset pin doesn't do the same thing.
Thanks.