0

CircuitPython connected to Adafruit io Crashing
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

CircuitPython connected to Adafruit io Crashing

by Tom_Henry on Sat Sep 04, 2021 10:11 pm

CircuitPython and Adafruit io: Crashing

I am having a problem with 2 CircuitPython programs crashing after a few hours while connected to Adafruit io. Both of these programs are running on a Raspberry Pi Zero W. One is located in the attic of our house and the other is in our house. I can access both Pi Zeros using the VNC viewer.

For the purposes of this forum I have attached the 2 CircuitPython programs that use slightly different approaches to sending data to Adafruit io. Both programs work error free for a few hours and then crash. Both seem to have the same problem.

They timeout after a few hours. I have the time delay on both where the programs refresh the data every 1 or 2 minutes.

Both programs deliver accurate information to 2 different Adafruit io Dashboards.

I have attached a copy of both CircuitPython programs (pistart2.py and code.py) and a screenshot of one of the Dashboards.

I have copied the first part of the Traceback errors that come after the crashes, see below.

Raspberry Pi Zero W in house

Python Program: pistart2.py

Python 3.7.3 (/usr/bin/python3)
>>> %Run pistart2.py

Here is a sample of the output being printed from the Pi Zero in our house.

The output from the attic sensors is very similar.

Today is Saturday 9/4/2021
The time is 12:01:41

Temperature: 87.4 F
Humidity: 34.3 %
Pressure: 14.6 psi
Altitude = 29.56 meters

Particles 0.3: 4806
Particles 0.5: 1474
Particles 1.0: 334
Particles 2.5: 37
Particles 5.0: 10
Particles 10.0: 8

Crashes after running several hours.

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 57, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution


Raspberry Pi Zero W in attic

Python Program: code.py

Python 3.7.3 (/usr/bin/python3)
>>> %Run code.py

Crashes after several hours.

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 57, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

I am trying to figure out why this is happening.

Does it have something to do with my time delay?

It seems like there could be a problem with Adafruit io because everything works fine for a few hours and then crashes.

I am open to any suggestions that might help these programs run for days instead of just a few hours.

Thank you,

Tom Henry
Attachments
Attic Screenshot.png
Attic Screenshot.png (166.84 KiB) Viewed 80 times
pistart2.py
(5.63 KiB) Not downloaded yet
code.py
(7.78 KiB) Not downloaded yet

Tom_Henry
 
Posts: 118
Joined: Wed Aug 26, 2020 8:19 pm

Re: CircuitPython connected to Adafruit io Crashing

by brubell on Tue Sep 07, 2021 9:04 am

Could be a DNS resolution error. Are you able to try connecting the Pi to another network?

brubell
 
Posts: 1520
Joined: Fri Jul 17, 2015 10:33 pm

Re: CircuitPython connected to Adafruit io Crashing

by Tom_Henry on Tue Sep 07, 2021 12:51 pm

I have a Metro ESP32-S2 Express also crashing after a few hours while connected to Adafruit io.

Not sure what DNS Resolution is but can you recommend an easy to connect to other network that I can try out?

I really like using Adafruit io as I have a good understanding of its various parts and how it works.

I have attached a copy of the CircuitPython code I am using with the Metro ESP32-S2.

Thank you,

Tom Henry
Attachments
code.py
(7.79 KiB) Not downloaded yet

Tom_Henry
 
Posts: 118
Joined: Wed Aug 26, 2020 8:19 pm

Re: CircuitPython connected to Adafruit io Crashing

by Tom_Henry on Wed Sep 08, 2021 10:18 pm

by brubell on Tue Sep 07, 2021 2:04 pm

Could be a DNS resolution error. Are you able to try connecting the Pi to another network?

I was able to connect my PyPortal to another network using a CircuitPython project from John Park called Air Quality Display. As you can see from the attached code.py, it accesses airnowapi.org.

Here is the crash after some ok responses:

Retrieving data...Reply is OK!
Response is 68
Retrieving data...Reply is OK!
Response is 68
Retrieving data...Traceback (most recent call last):
File "code.py", line 61, in <module>
File "code.py", line 45, in <module>
File "adafruit_pyportal/__init__.py", line 306, in fetch
File "adafruit_portalbase/network.py", line 479, in fetch
File "adafruit_requests.py", line 698, in get
File "adafruit_requests.py", line 580, in request
OutOfRetries: Repeated socket failures

Does that help understand what might be causing my crashes?

Thank you,

Tom Henry
Attachments
code.py
(2.4 KiB) Downloaded 1 time

Tom_Henry
 
Posts: 118
Joined: Wed Aug 26, 2020 8:19 pm

Re: CircuitPython connected to Adafruit io Crashing

by brubell on Fri Sep 10, 2021 9:49 am

Not sure, moved to the CircuitPython forum to see if there's someone else who would know.

brubell
 
Posts: 1520
Joined: Fri Jul 17, 2015 10:33 pm

Re: CircuitPython connected to Adafruit io Crashing

by subether on Thu Sep 16, 2021 10:51 pm

I'd like to add that I'm having a similar problem with the magtag and MatrixPortals; the connections are intermittent and do not seem to work all the time.

Code: Select all | TOGGLE FULL SIZE
Getting time for timezone America/Phoenix
Traceback (most recent call last):
  File "code.py", line 106, in <module>
  File "adafruit_portalbase/__init__.py", line 411, in get_local_time
  File "adafruit_portalbase/network.py", line 231, in get_local_time
  File "adafruit_portalbase/network.py", line 214, in get_strftime
  File "adafruit_portalbase/network.py", line 200, in get_strftime
  File "adafruit_requests.py", line 698, in get
  File "adafruit_requests.py", line 556, in request
  File "adafruit_requests.py", line 423, in _get_socket
RuntimeError: Sending request failed


Is there a way within circuitpython to connect to a standard ntp server (Say, pool.ntp.org) to get the time?

subether
 
Posts: 3
Joined: Sat Apr 28, 2018 1:19 am

Re: CircuitPython connected to Adafruit io Crashing

by Tom_Henry on Sat Sep 18, 2021 6:00 pm

Is there a way within circuitpython to connect to a standard ntp server (Say, pool.ntp.org) to get the time?

There is probably as way to get the date and time from the internet but
I have been using Adafruit's PCF8523 Real Time Clock with the STEMMA QT / Qwiic connectors, part # 5189.

It only costs $5. I bought several of them and use them on my CirucuitPython projects for the Raspberry Pi 4 or Zero or Feathers with AirLift WiFi.

You can go to this Adafruit url and it gives you the CircuitPython code you need to add to your program: https://learn.adafruit.com/adafruit-pcf ... cuitpython

The PCF8523 has a small CR1220 battery so once you set the date and time you can move it from project to project and not have to worry about resetting the date and time.

Here is the output I get out of a typical set up with a sensor:
Tom Henry's MS8607 Sensor Data:

Today is Saturday: 9/18/2021
The time is 14:58:08

Pressure: 1011.25 hPa
Pressure: 14.68 psi
Temperature: 24.78 C
Temperature: 75.93 F
Humidity: 51.00 % rH

This came from Adafruit's MS8607 sensor.

Tom Henry

Tom_Henry
 
Posts: 118
Joined: Wed Aug 26, 2020 8:19 pm

Please be positive and constructive with your questions and comments.