I want to build several battery powered sensors with an ESP-01s. However, I face an issue with the deepsleep.
Let me try to explain:
I want to periodically read some sensor values (e.g. every 10min). Until recently I didn't know about webrepl and I did everything with uPyCraft which was properly working (GPIO16 properly connected to RST).
Now I decided to use webrepl (no need for USB adapter and I don't have to disassemble my sensors in case I want to change something). But if needed, I still want to be able to easily access my board. My idea was to use GPIO3 as in input. If it is high, the board will do the sensor reading and goes to deepsleep afterwards. If it is low, it won't go to deepsleep and I am able to reprogram.
The issue now is, that in general I am able to put the board to deepsleep for an defined amount of time. It will power up again, but then I am not able to connect to it anymore. Also the sensor reading is not happening. On the first start of the board however, it properly reads the values.
I added the relevant part of the main.py below. Reading GPIO3 input properly works on start of the board, I verified the value. Do you have any idea, what could go wrong, that I'm not able to connect to the board after deepsleep?
Code: Select all
import machine
from machine import Pin
def deep_sleep(msecs):
rtc = machine.RTC()
rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)
rtc.alarm(rtc.ALARM0, msecs)
machine.deepsleep()
p3 = Pin(3, Pin.IN)
v = p3.value()
# sensor reading happenes here
if v == 1:
deep_sleep(5000)