Hi,
is it possible to turn off or disconnect the ESP32 Wi-Fi coprocessor of the PyPortal? I don't need it for my project and I would like to save some energy this way. I couldn't find any information related to this.
Thanks in advance!
Disconnect ESP32 Wi-Fi of PyPortal
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- tannewt
- Posts: 3304
- Joined: Thu Oct 06, 2016 8:48 pm
Re: Disconnect ESP32 Wi-Fi of PyPortal
You can use the ESP_RESET pin to hold the ESP in reset. In ESP chips, this actually disables the power regulator so it should be a good way to save energy.
- jhoropopo
- Posts: 9
- Joined: Thu Jun 24, 2021 3:24 pm
Re: Disconnect ESP32 Wi-Fi of PyPortal
Thanks @tannewt for the reply!
Do you mean something like this?
I changed my mind in the meantime and I would like to now use the wifi, but very occasionally only. This means querying some stuff, then wifi off for several hours and then on again. Could I hold the ESP reset for as long as I don't need it, then set it again to False, do my query and back to True again for several hours?
Do you mean something like this?
Code: Select all
esp32_reset = DigitalInOut(board.ESP_RESET)
esp32_reset = Direction.OUTPUT
esp32_reset = True
- tannewt
- Posts: 3304
- Joined: Thu Oct 06, 2016 8:48 pm
Re: Disconnect ESP32 Wi-Fi of PyPortal
Something like that yes. You should be able to reconnect after holding it low for a while.
I highly recommend a power monitor if you don't have one already: https://www.adafruit.com/product/5048 (Hopefully in stock elsewhere.)
I highly recommend a power monitor if you don't have one already: https://www.adafruit.com/product/5048 (Hopefully in stock elsewhere.)
- jhoropopo
- Posts: 9
- Joined: Thu Jun 24, 2021 3:24 pm
Re: Disconnect ESP32 Wi-Fi of PyPortal
Nice! Thanks for the answers and for the power monitor advice!
- jhoropopo
- Posts: 9
- Joined: Thu Jun 24, 2021 3:24 pm
Re: Disconnect ESP32 Wi-Fi of PyPortal
I have been trying to access directly the ESP reset pin of the PyPortal board but so far I was not successful. Just this:
throws this ValueError:
I have been looking into the source code of PortalBase and PyPortal in github to see whether I have some other "entry point" or way to access this variable. I also don't really know what the problem here is, but I guess that this object is already somehow assigned otherwise and therefore the error.
Any help how to solve this is highly appreciated :)
Code: Select all
esp32_reset = DigitalInOut(board.ESP_RESET)
Code: Select all
Traceback (most recent call last):
File "code.py", line 36, in <module>
ValueError: ESP_RESET in use
Any help how to solve this is highly appreciated :)
- tannewt
- Posts: 3304
- Joined: Thu Oct 06, 2016 8:48 pm
Re: Disconnect ESP32 Wi-Fi of PyPortal
I think the reset line use is buried pretty deep in the pyportal objects. You could use the lower level classes or dig into the portal object to find it. To dig, its probably easiest to create PyPortal from the REPL and then use dir() to find the objects it could be on. Sorry its not super accessible, this is a niche thing you are doing. We assumed with pyportal that it'd be connected to power due to the power consumption of the display backlight.
- jhoropopo
- Posts: 9
- Joined: Thu Jun 24, 2021 3:24 pm
Re: Disconnect ESP32 Wi-Fi of PyPortal
Ok, I finally got the solution:
This resets the ESP32. Thanks again for your help!
Code: Select all
pyportal.network._wifi.esp._reset.value = False
- tannewt
- Posts: 3304
- Joined: Thu Oct 06, 2016 8:48 pm
Re: Disconnect ESP32 Wi-Fi of PyPortal
Nice work! Thanks for the update
Please be positive and constructive with your questions and comments.