Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

Pyportal google event calendar
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Pyportal google event calendar

by Kidkill on Sat Mar 06, 2021 11:45 pm

Hello. I'm trying to put together the pyportal google calendar project and have run into an issue. Following along the instructions I get passed everything, I've gotten the IO feed setup and tested, the google token working, and try to run the final code when I receive this error:

Code: Select all | TOGGLE FULL SIZE
code.py output:
Connecting to AP...
Connected to P**************    RSSI: -59
fetching local time...
Getting time for timezone Etc/UTC
Traceback (most recent call last):
  File "code.py", line 260, in <module>
  File "code.py", line 103, in get_current_time
  File "adafruit_portalbase/__init__.py", line 400, in get_local_time
  File "adafruit_portalbase/network.py", line 213, in get_local_time
  File "adafruit_portalbase/network.py", line 195, in get_local_time
AttributeError: 'NoneType' object has no attribute 'get'


The only change to code.py downloaded from adafruit is the instructed CALENDAR_ID = "YOUR_CAL_ID"
Any help would be appreciated thanks!

Kidkill
 
Posts: 57
Joined: Mon Mar 18, 2019 7:21 pm

Re: Pyportal google event calendar

by dastels on Sun Mar 07, 2021 9:58 am

The first thing I'd do is make sure you are running the latest CircuitPython with the latest module bundle. Remove everything in the CIRCUITPY/lib directory, empty trash, and recopy over what you need from the bundle.

Dave

dastels
 
Posts: 6105
Joined: Tue Oct 20, 2015 3:22 pm

Re: Pyportal google event calendar

by Kidkill on Mon Mar 15, 2021 11:41 am

Hi Dave,
I've started over fresh, deleted everything, made sure everything was the latest, followed the instructions exactly. I'm getting the same error.

[code][Connected to P************* RSSI: -54
No SD card found: no SD card
fetching local time...
Getting time for timezone Etc/UTC
Traceback (most recent call last):
File "code.py", line 260, in <module>
File "code.py", line 103, in get_current_time
File "adafruit_portalbase/__init__.py", line 400, in get_local_time
File "adafruit_portalbase/network.py", line 213, in get_local_time
File "adafruit_portalbase/network.py", line 195, in get_local_time
AttributeError: 'NoneType' object has no attribute 'get'

Code done running./code]

Kidkill
 
Posts: 57
Joined: Mon Mar 18, 2019 7:21 pm

Re: Pyportal google event calendar

by dastels on Mon Mar 15, 2021 12:54 pm

It seems like it's not connecting to your access point. and the requests object isn't getting set... although the output messages show a connection being made.

it's quite possible that the way to use the network code has changed slightly since that project was written (and subsequently not updated to match).

I'll see if I can replicate it.

Dave

dastels
 
Posts: 6105
Joined: Tue Oct 20, 2015 3:22 pm

Re: Pyportal google event calendar

by dastels on Mon Mar 15, 2021 3:00 pm

OK, I'm at the point. I'll start poking now.

Dave

dastels
 
Posts: 6105
Joined: Tue Oct 20, 2015 3:22 pm

Re: Pyportal google event calendar

by dastels on Mon Mar 15, 2021 4:40 pm

There seems to be a real disconnect between code.py and the current libraries.

Try this (works for me):

In code.py delete this (starting at line 71 in mine):
Code: Select all | TOGGLE FULL SIZE
print("Connecting to AP...")
while not esp.is_connected:
    try:
        esp.connect_AP(secrets["ssid"], secrets["password"])
    except RuntimeError as e:
        print("could not connect to AP, retrying: ", e)
        continue
print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi)

and immediately after:
Code: Select all | TOGGLE FULL SIZE
pyportal = PyPortal(esp=esp, external_spi=spi)

add the line:
Code: Select all | TOGGLE FULL SIZE
pyportal.network.connect()


Dave

dastels
 
Posts: 6105
Joined: Tue Oct 20, 2015 3:22 pm

Re: Pyportal google event calendar

by dastels on Mon Mar 15, 2021 4:41 pm

It connects, gets time, calls to the google api. That fails but it might be because I never use google calendar.

Dave

dastels
 
Posts: 6105
Joined: Tue Oct 20, 2015 3:22 pm

Re: Pyportal google event calendar

by Kidkill on Mon Mar 15, 2021 8:53 pm

Starting at line 71, the code.py file now reads:

Code: Select all | TOGGLE FULL SIZE

# Create the PyPortal object
pyportal = PyPortal(esp=esp, external_spi=spi)
pyportal.network.connect()
r = rtc.RTC()


The error now reads:

Code: Select all | TOGGLE FULL SIZE
code.py output:
No SD card found: no SD card
Connecting to AP P**************
Could not connect to internet ('Failed to connect to ssid', b'P**************')
Retrying in 3 seconds...
Connecting to AP P************
fetching local time...
Getting time for timezone Etc/UTC
Traceback (most recent call last):
  File "code.py", line 254, in <module>
  File "code.py", line 97, in get_current_time
  File "adafruit_portalbase/__init__.py", line 400, in get_local_time
  File "adafruit_portalbase/network.py", line 213, in get_local_time
  File "adafruit_portalbase/network.py", line 195, in get_local_time
  File "adafruit_requests.py", line 681, in get
  File "adafruit_requests.py", line 562, in request
  File "adafruit_requests.py", line 429, in _get_socket
RuntimeError: Sending request failed

Code done running.

Kidkill
 
Posts: 57
Joined: Mon Mar 18, 2019 7:21 pm

Re: Pyportal google event calendar

by dastels on Mon Mar 15, 2021 9:24 pm

I'm not getting that. It happens consistantly? Sounds like maybe a network issue.

Dave

dastels
 
Posts: 6105
Joined: Tue Oct 20, 2015 3:22 pm

Re: Pyportal google event calendar

by Kidkill on Mon Mar 15, 2021 10:56 pm

Yes, consistently. When I run the code in the connect to WIFI section of the tutorial it connects to the internet just fine and I can see the activity in the Adafruit IO feed. When I run this code, the adafruit feed doesn't respond at all.

Kidkill
 
Posts: 57
Joined: Mon Mar 18, 2019 7:21 pm

Re: Pyportal google event calendar

by dastels on Tue Mar 16, 2021 9:18 am

I suspect your secrets file. Double check its contents.

Dave

dastels
 
Posts: 6105
Joined: Tue Oct 20, 2015 3:22 pm

Re: Pyportal google event calendar

by Kidkill on Tue Mar 16, 2021 11:18 am

Well, like I said, the wifi connects just fine using the test code. What would be different in the secrets.py file for the final code?

Kidkill
 
Posts: 57
Joined: Mon Mar 18, 2019 7:21 pm

Re: Pyportal google event calendar

by dastels on Tue Mar 16, 2021 11:34 am

OK, if it's the same secrets file... Does your test code get the time?

Dave

dastels
 
Posts: 6105
Joined: Tue Oct 20, 2015 3:22 pm

Re: Pyportal google event calendar

by Kidkill on Tue Mar 16, 2021 5:51 pm

Here's the output from esp32spi_simpletest.py with the unchanged secrets.py file:

Code: Select all | TOGGLE FULL SIZE
Connecting to AP...
Connected to PonderosaHouse    RSSI: -55
My IP address is 10.0.0.136
IP lookup adafruit.com: 104.20.38.240
Ping google.com: 20 ms
Fetching text from http://wifitest.adafruit.com/testwifi/index.html
----------------------------------------
This is a test of Adafruit WiFi!
If you can read this, its working :)

----------------------------------------

Fetching json from http://api.coindesk.com/v1/bpi/currentprice/USD.json
----------------------------------------
{'time': {'updated': 'Mar 16, 2021 21:45:00 UTC', 'updatedISO': '2021-03-16T21:45:00+00:00', 'updateduk': 'Mar 16, 2021 at 21:45 GMT'}, 'disclaimer': 'This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org', 'bpi': {'USD': {'code': 'USD', 'description': 'United States Dollar', 'rate_float': 56403.4, 'rate': '56,403.4517'}}}
----------------------------------------
Done!

Code done running.

Kidkill
 
Posts: 57
Joined: Mon Mar 18, 2019 7:21 pm

Re: Pyportal google event calendar

by Kidkill on Tue Mar 16, 2021 6:32 pm

Well. I was looking around and tried something. In the tutorial under Code Setup, Secrets File Setup, it says to change your timezone to "Etc/UTC" I changed that back to my local America/Denver and there ya go. It seems to be working.

Kidkill
 
Posts: 57
Joined: Mon Mar 18, 2019 7:21 pm

Please be positive and constructive with your questions and comments.