8000 ESP32S2 time.sleep(60) fails but time.sleep(15) works · Issue #4061 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content
ESP32S2 time.sleep(60) fails but time.sleep(15) works #4061
Closed
@jerryneedell

Description

@jerryneedell

May be related to adafruit/Adafruit_CircuitPython_Requests#63

On a SAOLA WROVER
If I run the code below with time.sleep(15) it executes normally
but with time.sleep(60)
it executes normally for the first pass
throws and error ENOTCONN on the second pass but recovers
then fails on the thirds and subsequent passes

Am I doing something wrong?
has time.sleep() changed?


Adafruit CircuitPython 6.2.0-beta.0-3-g97f5d218a on 2021-01-24; Saola 1 w/Wrover with ESP32S2
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

code.py output:
<Network> Needell Airport -57 6
<Network> Needell Airport -41 1
<Network> central2.4 -76 7
<Network> 31A -77 7
<Network> PC -89 10
None
ip 10.0.0.111
Counter: 0
Sending to Adafruit IO...
Data sent!
Counter: 1
Sending to Adafruit IO...
Error sendind data - try again  [Errno 128] ENOTCONN
Counter: 1
Sending to Adafruit IO...
Data sent!
Counter: 2
Sending to Adafruit IO...
Error sendind data - try again  [Errno 128] ENOTCONN
Counter: 2
Sending to Adafruit IO...
Error sendind data - try again  Repeated socket failures
Counter: 2
Sending to Adafruit IO...
Error sendind data - try again  Repeated socket failures
Counter: 2
Sending to Adafruit IO...

here is the code

import ipaddress
import wifi
import socketpool
import time
import adafruit_requests
import ssl
from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError
import board
import busio
import digitalio

try:
    from secrets import secrets
except ImportError:
    print("WiFi secrets are kept in secrets.py, please add them there!")
    raise

for network in wifi.radio.start_scanning_networks():
    print(network, network.ssid, network.rssi, network.channel)

wifi.radio.stop_scanning_networks()

print(wifi.radio.connect(secrets["ssid"], secrets["password"]))

print("ip", wifi.radio.ipv4_address)

pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, ssl.create_default_context())


aio_username = secrets["aio_username"]
aio_key = secrets["aio_key"]

# Initialize an Adafruit IO HTTP API object
io = IO_HTTP(aio_username, aio_key, requests)

try:
    feed = io.get_feed("test")
except AdafruitIO_RequestError:
    # If no feed exists, create one
    feed = io.create_new_feed("test")

counter = 0
while True:
    data = "%d" % (counter)
    try:
        print("Counter: {0}".format(counter))
        print("Sending to Adafruit IO...")
        io.send_data(feed["key"], counter)
        print("Data sent!")
        counter += 1
    except Exception as e:
        print("Error sendind data - try again ", e)
        continue
    time.sleep(60)

Metadata

Metadata

Assignees

Labels

espressifapplies to multiple Espressif chipsnetwork

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0