Basic questions about PyPortal display

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Basic questions about PyPortal display

Post by dastels »

Did you try the gc.collect()?

Another question is how much data is getting returned from the GET?

Dave

User avatar
ghulse
 
Posts: 97
Joined: Tue Nov 30, 2021 10:49 am

Re: Basic questions about PyPortal display

Post by ghulse »

dastels wrote: Thu Feb 02, 2023 8:00 pm Did you try the gc.collect()?

Another question is how much data is getting returned from the GET?
Yes, I have gc.collect() in there just before the time.sleep.

As to your second question, oof! A lot of data as it turns out.

This particular url has data for about 20 buoys.

Code: Select all

r = requests.get(noaa_url)
text = r.text
The error specifies the text = r.text line. So maybe I need to modify this to just grab the first 100 characters or so. (The data for the Cambridge buoy comes first). Otherwise, I need to use a different url that shows only the Cambridge buoy data. Which is what someone was suggesting on the NOAA Nbuoy on MagTag thread:

viewtopic.php?p=958619&hilit=boaa+buoy#p958619

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Basic questions about PyPortal display

Post by dastels »

That'll do it. If you can reduce the amount to data being returned, it will definitely help.

Dave

User avatar
ghulse
 
Posts: 97
Joined: Tue Nov 30, 2021 10:49 am

Re: Basic questions about PyPortal display

Post by ghulse »

This new NOAA data feed provides the time in UTC format. Is there an easy way to convert this to local time?

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Basic questions about PyPortal display

Post by dastels »

The PyPortal class has a get_local_time method that takes a string indicating your city/country as a parameter, e.g. Your city and country, e.g. "America/New_York".

Dave

User avatar
ghulse
 
Posts: 97
Joined: Tue Nov 30, 2021 10:49 am

Re: Basic questions about PyPortal display

Post by ghulse »

The NOAA url returns the time of last data collected, not current time. (It’s usually about 45 minutes before current time). Would I be able to feed this time to the PyPortal class for conversion to local time? (Before I dive down this rabbit hole)

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Basic questions about PyPortal display

Post by dastels »

I wonder....

what if you fetch the current time in UTC, as well as in local time, compute the difference and use that to offset the UTC time from the data. See io.adafruit.com/<your Adafruit IO usename>services/time

Dave

User avatar
ghulse
 
Posts: 97
Joined: Tue Nov 30, 2021 10:49 am

Re: Basic questions about PyPortal display

Post by ghulse »

I solved all my problems by finding a different rss feed—one that contains only the Cambridge buoy data. The time is already in eastern time zone, so I don't have to try to figure out how to convert UTC. Then I tweaked the code so the display so it is somewhat readable. This updates every five minutes and no crashes for more than 24 hours. Thanks for all the help.

noaa_display.jpg
noaa_display.jpg (139.92 KiB) Viewed 62 times

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Basic questions about PyPortal display

Post by dastels »

Awesome!

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”