Only power sensor when not in deep sleep

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
kwiley
Posts: 140
Joined: Wed May 16, 2018 5:53 pm
Contact:

Only power sensor when not in deep sleep

Post by kwiley » Thu Jun 20, 2019 7:31 pm

I'd like to only power my sensor (soil moisture) when the ESP8266 (ESP-01S) is awake, which will be very infrequently, perhaps a few seconds per day. I have been successful in using the TX GPIO to drive a FET to control the sensor, but I'd like to recover that GPIO for other purposes (the TX/RX GPIOs could run an I2C LCD, while GPIO0 reads the sensor value and GPIO2 drives the on-board LED for across-the-room visual feedback). It would be acceptable for my application to have the sensor always powered when the ESP is awake, and to then use deep sleep to put both the chip and the sensor to sleep most of the time. Is there an easy way to do this? I'm believe RST is always high while awake and low while in deep sleep. Could I connect RST directly to the FET's gate? I'm already using RST to send the wake-up interrupt (I had to solder the connection on the ESP-01S for this), but I'm not sure if I can also use RST in the way I'm describing. Would wiring RST to the FET make the sensor only receive power while the chip is awake? Aside from RST, is there another way to achieve the goal I'm describing here?

Thanks.

ThomasChr
Posts: 121
Joined: Sat Nov 25, 2017 7:50 am

Re: Only power sensor when not in deep sleep

Post by ThomasChr » Thu Jun 20, 2019 8:14 pm

Why don‘t you use a simple GPIO Pin with a relay? On startup the Pin goes high and the relay (driven through a transistor) switches Power to the Sensor. On deepsleep the Pin goes into high impedance and the relay switches off. Maybe you can also use a FET directly instead of the relay.

kwiley
Posts: 140
Joined: Wed May 16, 2018 5:53 pm
Contact:

Re: Only power sensor when not in deep sleep

Post by kwiley » Thu Jun 20, 2019 9:09 pm

I was trying to avoid an extra pin. I'm already using the TX pin to power the FET in the same as the relay you propose (to my limited understanding, I'm an electronics novice, more software oriented). The ESP-01S offers two native GPIOs (one hard-coded to the on-board LED) and two additional GPIOs so long as you don't need serial comms to your computer. So I'd like:
  • GPIO 0 - sensor input
  • GPIO 2 - LED indicator of sensor binary status
  • TX GPIO - I2C clock or data to LCD
  • RX GPIO - I2C data or clock to LCD
I'm out of GPIOs at that point, so I can't use an additional line to power the sensor. I can easily power the sensor directly off the original power supply, but then it will receive power all the time. I only want it to receive power while the chip is awake. I currently do that by using TX to gate the FET to power the sensor, but as you can see above, that wouldn't work once I add the LCD and need two lines for the I2C comms.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Only power sensor when not in deep sleep

Post by jimmo » Fri Jun 21, 2019 12:09 am

You could add an i2c port expander for more pins.

Or just get an ESP module with more pins... save yourself the hassle and complexity.

ThomasChr
Posts: 121
Joined: Sat Nov 25, 2017 7:50 am

Re: Only power sensor when not in deep sleep

Post by ThomasChr » Fri Jun 21, 2019 5:38 am

Jep, get an ESP Module with more Pins. ESP32 modules are not expensive!

kwiley
Posts: 140
Joined: Wed May 16, 2018 5:53 pm
Contact:

Re: Only power sensor when not in deep sleep

Post by kwiley » Fri Jun 21, 2019 7:39 am

I haven't found anything else as small as the ESP-01S with an integrated wifi antenna. Do you think there is an equivalent alternative, either ESP8266 or ESP32?

ThomasChr
Posts: 121
Joined: Sat Nov 25, 2017 7:50 am

Re: Only power sensor when not in deep sleep

Post by ThomasChr » Fri Jun 21, 2019 7:44 am

I think this is one of the smallest formfactors for the ESP32: Directly the module WROVER from Espressif!
https://www.aliexpress.com/item/33006996531.html
Bonus: It's got 4 MB of PSRAM. Thats a lot of memory for micropython.

On the negative side: It needs a regulated power source of about 3 / 3.3 Volts and a pullup on reset. But that's all what's really needed externally.

kwiley
Posts: 140
Joined: Wed May 16, 2018 5:53 pm
Contact:

Re: Only power sensor when not in deep sleep

Post by kwiley » Fri Jun 21, 2019 2:23 pm

That is pretty cool, but to be clear, that's a surface-mount (or snap-mount, I'm not sure of the technical term) device, which means it needs an entire support infrastructure before it can be used. Presumably there is a board with a snap-in slot built exactly for that to fit into, but then I'm back to my original question: how big is the surrounding board that it fits into.

But you do have me curious. I'll see if I can find the board that's supposed to pair up with. That's pretty tantalizing. I'm willing to believe that the ESP8266 is essentially outdated by the ESP32, if I can just find the right device.

Thanks.

Christian Walther
Posts: 169
Joined: Fri Aug 19, 2016 11:55 am

Re: Only power sensor when not in deep sleep

Post by Christian Walther » Fri Jun 21, 2019 6:19 pm

Only slightly larger than an ESP-01 module, this is the smallest full-featured ESP8266 (actually, ESP8285 = ESP8266 + 1 MB flash) board I have: https://www.tindie.com/products/onehors ... ent-board/

For the ESP32, I would check out the TinyPICO: https://www.crowdsupply.com/unexpected-maker/tinypico

kwiley
Posts: 140
Joined: Wed May 16, 2018 5:53 pm
Contact:

Re: Only power sensor when not in deep sleep

Post by kwiley » Sun Jun 23, 2019 2:48 pm

Yeah. Thanks for pointing me that way. I admit, I'm interesting in cheaper options, but your comment pushed me in a whole direction. I was totally unfamiliar with the ESP8285 and the numerous boards built around it.

Post Reply