0

PyPortal Weather Station issue
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

PyPortal Weather Station issue

by Bellatrix on Tue Apr 02, 2019 7:31 pm

I try using the code for weather station. Does the normal boot with the little noise, the two or three images, then goes to wall of text with the following.

Set background to 0
No SD card found: no SD card
Set icon to /weather_background.bmp
Getting time from internet!
Getting time for timezone America/CHicagi
Traceback (most recent call last);
File "code.py", line 52, in <module>
File "code.py", line 48, in <module>
File "adafruit_pyportal.py", line 557, in get_local_time
File "adafruit_pyportal.py", line 553, in get_local_time
ValueError: invalid syntax for integer with base 10

Code done running. Waiting for reload.

my code.py file is as follows
Code: Select all | TOGGLE FULL SIZE
"""
This example queries the Open Weather Maps site API to find out the current
weather for your location... and display it on a screen!
if you can find something that spits out JSON data, we can display it
"""
import sys
import time
import board
from adafruit_pyportal import PyPortal
cwd = ("/"+__file__).rsplit('/', 1)[0] # the current working directory (where this file is)
sys.path.append(cwd)
import openweather_graphics  # pylint: disable=wrong-import-position

# Get wifi details and more from a secrets.py file
try:
    from secrets import secrets
except ImportError:
    print("WiFi secrets are kept in secrets.py, please add them there!")
    raise

# Use cityname, country code where countrycode is ISO3166 format.
# E.g. "New York, US" or "London, GB"
LOCATION = "Austin, US"

# Set up where we'll be fetching data from
DATA_SOURCE = "http://api.openweathermap.org/data/2.5/weather?q="+LOCATION
DATA_SOURCE += "&appid="+secrets['openweather_token']
# You'll need to get a token from openweather.org, looks like 'b6907d289e10d714a6e88b30761fae22'
DATA_LOCATION = []


# Initialize the pyportal object and let us know what data to fetch and where
# to display it
pyportal = PyPortal(url=DATA_SOURCE,
                    json_path=DATA_LOCATION,
                    status_neopixel=board.NEOPIXEL,
                    default_bg=0x000000)

gfx = openweather_graphics.OpenWeather_Graphics(pyportal.splash, am_pm=True, celsius=False)

localtile_refresh = None
weather_refresh = None
while True:
    # only query the online time once per hour (and on first run)
    if (not localtile_refresh) or (time.monotonic() - localtile_refresh) > 3600:
        try:
            print("Getting time from internet!")
            pyportal.get_local_time()
            localtile_refresh = time.monotonic()
        except RuntimeError as e:
            print("Some error occured, retrying! -", e)
            continue

    # only query the weather every 10 minutes (and on first run)
    if (not weather_refresh) or (time.monotonic() - weather_refresh) > 600:
        try:
            value = pyportal.fetch()
            print("Response is", value)
            gfx.display_weather(value)
            weather_refresh = time.monotonic()
        except RuntimeError as e:
            print("Some error occured, retrying! -", e)
            continue

    gfx.update_time()
    time.sleep(30)  # wait 30 seconds before updating anything again


Secrets.py is as follows with wifi and keys excluded
Code: Select all | TOGGLE FULL SIZE
# This file is where you keep secret settings, passwords, and tokens!
# If you put them in the code you risk committing that info or sharing it
# which would be not great. So, instead, keep it all in this one file and
# keep it a secret.

secrets = {
    'ssid' : 'wifi name',             # Keep the two '' quotes around the name
    'password' : 'wifi password',         # Keep the two '' quotes around password
    'timezone' : "America/Chicago",  # http://worldtimeapi.org/timezones
    'aio_username' : 'my username',
    'aio_key' : 'my long key',
    'openweather_token' : 'kinda sorta long key'
    }
Attachments
Untitled.png
Untitled.png (158.64 KiB) Viewed 447 times

Bellatrix
 
Posts: 17
Joined: Fri Nov 08, 2013 1:16 am

Re: PyPortal Weather Station issue

by johnpark on Wed Apr 03, 2019 12:43 pm

In your secrets.py file, do you have you Adafruit IO username and key entered? Those are necessary for the time server to work.
Also, in your traceback it says "Getting time for timezone America/CHicagi" I'm not sure if that's how it reinterprets "Chicago" or if that was a typo in the secrets.py entry?

johnpark
 
Posts: 532
Joined: Wed Mar 25, 2009 2:15 pm

Re: PyPortal Weather Station issue

by Bellatrix on Wed Apr 03, 2019 1:15 pm

In my secrets.py file I have my AIO key, adafruit username, ssid, WiFi password, and weather api key entered. Chigagi, might have been a typo when I was retyping from the portal screen. I'll double check that typo when I get home shortly.

Bellatrix
 
Posts: 17
Joined: Fri Nov 08, 2013 1:16 am

Re: PyPortal Weather Station issue

by Bellatrix on Wed Apr 03, 2019 4:41 pm

Double checked my code, CHicagi was a typo on my part when I was making my orignal post, in my code it was correctly spelled as Chicago.

Bellatrix
 
Posts: 17
Joined: Fri Nov 08, 2013 1:16 am

Re: PyPortal Weather Station issue

by johnpark on Wed Apr 03, 2019 4:44 pm

OK, thanks for checking. I've seen that same error when I had forgotten to include my aio_username and aio_key. Could you double check those?

johnpark
 
Posts: 532
Joined: Wed Mar 25, 2009 2:15 pm

Re: PyPortal Weather Station issue

by Bellatrix on Wed Apr 03, 2019 4:45 pm

HAH!!!!!! I'm a snickerdoodle, didn't realize the username for AIO was case sensitive in the code. Changed appropriate Capitalization in username for AIO and now works. Thank you handsome and smart John.

Bellatrix
 
Posts: 17
Joined: Fri Nov 08, 2013 1:16 am

Re: PyPortal Weather Station issue

by johnpark on Wed Apr 03, 2019 5:47 pm

You're very welcome, and highly flattering : ]
Please note, now I really wish we had an error message that said "you're a snickerdoodle!"

Glad it's working now, enjoy.

johnpark
 
Posts: 532
Joined: Wed Mar 25, 2009 2:15 pm

Re: PyPortal Weather Station issue

by Bellatrix on Wed Apr 03, 2019 6:00 pm

Maybe that should be incorporated into the website for the 404 error? "Oh snickerdoodle, seems we have reached adabots 404 error"
And again, thank you.

Bellatrix
 
Posts: 17
Joined: Fri Nov 08, 2013 1:16 am

Re: PyPortal Weather Station issue

by burns3 on Tue May 14, 2019 6:53 am

What might cause the weather station to stop updating? Everything is fine when I first power up, but it eventually stops updating and is stuck on time and weather from hours ago. I’m using the stock code with only location changed and it’s placed right next to my router.

burns3
 
Posts: 19
Joined: Sun Dec 11, 2016 9:48 pm

Re: PyPortal Weather Station issue

by johnpark on Wed May 15, 2019 1:10 pm

Strange. Do you happen to have a different router you can test with?

johnpark
 
Posts: 532
Joined: Wed Mar 25, 2009 2:15 pm

Re: PyPortal Weather Station issue

by burns3 on Wed May 15, 2019 3:09 pm

johnpark wrote:Strange. Do you happen to have a different router you can test with?


I do not

burns3
 
Posts: 19
Joined: Sun Dec 11, 2016 9:48 pm

Re: PyPortal Weather Station issue

by kevinjwalters on Fri May 17, 2019 12:52 pm

The application code enables a feature where the NeoPixel on the back of the PyPortal gives you some application/library based status information, this may help. It's not currently documented but @adafruit_support_carter in the land of Discord reports the colours as:

# blue = connected
# red = not connected
# yellow = fetching data
# green = got data


The quote demo app is blue most of the time for me and every 60 seconds goes yellow for a second or two. I never see green but that could be a very brief flash. It would be interesting in your case it it ends up on red.

kevinjwalters
 
Posts: 432
Joined: Sun Oct 01, 2017 3:15 pm

Re: PyPortal Weather Station issue

by adafruit_support_carter on Fri May 17, 2019 12:56 pm

One of the underlying libraries (ESP32SPI) can get stuck in an infinite loop if the return is not as expected. So, it may also be this:
https://github.com/adafruit/Adafruit_Ci ... /issues/11
or, if you haven't updated the library, you're missing this:
https://github.com/adafruit/Adafruit_Ci ... PI/pull/44

adafruit_support_carter
 
Posts: 12958
Joined: Tue Nov 29, 2016 2:45 pm

Re: PyPortal Weather Station issue

by burns3 on Fri May 17, 2019 4:03 pm

adafruit_support_carter wrote:One of the underlying libraries (ESP32SPI) can get stuck in an infinite loop if the return is not as expected. So, it may also be this:
https://github.com/adafruit/Adafruit_Ci ... /issues/11
or, if you haven't updated the library, you're missing this:
https://github.com/adafruit/Adafruit_Ci ... PI/pull/44


where's 4.x-mpy? It's not on this page.

https://github.com/adafruit/Adafruit_Ci ... g/20190517

burns3
 
Posts: 19
Joined: Sun Dec 11, 2016 9:48 pm

Re: PyPortal Weather Station issue

by adafruit_support_carter on Fri May 17, 2019 7:40 pm

You're right. Not sure why that is. Something must have broken with the build tools and the auto release. I've sent word.

adafruit_support_carter
 
Posts: 12958
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.