help with the PyPortal Pet Planter with Adafruit IO and my T

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.
Locked
User avatar
PonyXpress
 
Posts: 50
Joined: Fri Jul 01, 2022 10:51 am

help with the PyPortal Pet Planter with Adafruit IO and my T

Post by PonyXpress »

I'm a newbe so be gentle :)

I need some help with my project the "PyPortal Pet Planter with Adafruit IO" and my Titano. I've tried to follow the instructions and I have made some progress, but I have a few issues to sort out.

The Titano boots, I see the roots, temp, and moisture on the display. Good so far....But after a couple of minutes I get some errors about loops.

I also noticed that my Feeds and Dashboard are not receiving any data from my Titano, and the https://io.adafruit.com/ site shows my device is Offline. The Serial output shows that it connects to my wifi and to Adafruit IO. Maybe it's not running long enough to post data.

Here is the output from my Serial connection. It will run for a few minutes, stop with loop errors, and then restart after a few minutes, and just keep doing that for a few times and then just stops at the loop error screen and I have to Reset it.


Adafruit CircuitPython 7.3.1 on 2022-06-22; Adafruit PyPortal Titano with samd51j20
>>>
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
drawing background..
loading fonts...
loading icons...
Connected to WiFi!
Connecting to Adafruit IO...
Connected to Adafruit IO!
Connected!
reading soil sensor...
Temperature: 70F
filling disp..
disp filled..
temp: 69 moisture: 330
reading soil sensor...
Temperature: 70F
filling disp..
disp filled..
temp: 70 moisture: 330
reading soil sensor...
Temperature: 70F
filling disp..
disp filled..
temp: 69 moisture: 330
reading soil sensor...
Temperature: 70F
filling disp..
disp filled..
temp: 69 moisture: 330
reading soil sensor...
Temperature: 69F
filling disp..
disp filled..
temp: 69 moisture: 330
Traceback (most recent call last):
File "code.py", line 271, in <module>
File "adafruit_io/adafruit_io.py", line 239, in loop
File "adafruit_minimqtt/adafruit_minimqtt.py", line 802, in loop
File "adafruit_minimqtt/adafruit_minimqtt.py", line 556, in ping
File "adafruit_esp32spi/adafruit_esp32spi_socket.py", line 86, in send
File "adafruit_esp32spi/adafruit_esp32spi.py", line 766, in socket_write
ConnectionError: Failed to send 2 bytes (sent 0)

Code done running.

Press any key to enter the REPL. Use CTRL-D to reload.


Any ideas?

User avatar
mikeysklar
 
Posts: 14165
Joined: Mon Aug 01, 2016 8:10 pm

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by mikeysklar »

It looks like you have most of the project going. So good job so far.

The disconnect issue is probably the place to start.
ConnectionError: Failed to send 2 bytes (sent 0)
How far is your PyPortal Titano from the WiFi?

Are you running the default code with the exception of the secrets.py file specifics?

Have you setup all the AIO feeds / dashboard / charts?

User avatar
PonyXpress
 
Posts: 50
Joined: Fri Jul 01, 2022 10:51 am

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by PonyXpress »

Thank you!

As you can see from my serial output, it says it connects to the network and then it says it is connected to Adafruit. But it doesn't stay running long enough (I guess) to phone home. That assumes the connection error isn't blocking it.

I tried to follow the instructions from this site https://learn.adafruit.com/pyportal-pet ... t-io-setup

Wireless signal is not the issue, confirmed with several other wireless devices. I'm currently working at my desk, so my router/AP is only 6 feet away from the Titano.

As best as I recall, this what I loaded:

wippersnapper.pyportal_tinyusb.1.0.0-beta.38.uf2
adafruit-circuitpython-pyportal_titano-en_US-7.3.1.uf2

And then copied the files and folders to Titano:

adafruit-circuitpython-bundle-7.x-mpy-20220510\lib

and then

I had to create the secrets file and it connected when I created my Adafruit account. At that time in the process, it said my device was Online. I setup my Feeds and Dashboard.

And then

pyportal_pet_planter.zip I copied all the files inside the folder \CircuitPython 7.x

There was some other issue where one template for the secrets file was to call everything "io_username, io_password" and so on. the website instructions said to use the one there, and it called everything "aio_username, etc. etc." The aio one is working so that is the format of my secrets file. My wifi ssid, password, Adafruit username and that big ass long KEY is in there.

I was getting an error on boot up saying it didn't find the secrets.py file. So I made a copy of the secrets.json file and named it secrets.py and it then went past that point in the boot up. I had to make one other change in the secrets file. Line 193 in the code.py file calls for "aio username" from the secrets file. My secrets file was calling that just "user", so I changed it to "username" and that error went away.

I attached a screenshot of my Titano drive.
Titano drive
Titano drive
Titano_storage.JPG (29.08 KiB) Viewed 470 times
I attached a picture of the display. It will show that screen until the code stops running, about 2 minutes. It then shows the same content as the output from the Serial connection, loop errors
display
display
SmartPlanter.JPG (42.89 KiB) Viewed 470 times
In my original post here, I said that it restarts after the code stops running. That is not correct. What is displayed on the Serial output is the code running, and repeating a set of instructions. I think that is a good thing, as it's reading the temp sensors, updating the display with current information. It will cycle like that a few times before the code stops running. I have to reset it to get it going again.

One other piece of information. After creating an Adafruit account and getting connected, the instructions offered up some Test runs with Test Feeds and a bunch of other stuff that I skipped. I went to the Code Setup section for the project. I hope I didn't skip anything important. It was the instructions on this page, I skipped the Example Code section,
https://learn.adafruit.com/pyportal-pet ... et-connect

Thanks much for your assistance!

User avatar
PonyXpress
 
Posts: 50
Joined: Fri Jul 01, 2022 10:51 am

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by PonyXpress »

I forgot to ask, how do I troubleshoot the Connection Error - Failed to Send ?

I also would like to know what url is it trying to connect to? I need to make sure my Pi-Hole isn't blocking it.

Thank you

User avatar
mikeysklar
 
Posts: 14165
Joined: Mon Aug 01, 2016 8:10 pm

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by mikeysklar »

It would be going back to the Adafruit IO test feeds section and make sure that data is getting pushed successfully to AIO.

The CircuitPython libraries you are using are almost two months old. Can you try using the 20220702 drop? Your 7.3.1 release is good no need to change that just the lib/ libraries.

https://github.com/adafruit/Adafruit_Ci ... 220702.zip

Your code is failing at line 271 which is inside io.loop() which means there is an issue with connecting to Adafruit IO which more than likely is related to a library or authentication issues.

Code: Select all

while True:
    # Explicitly pump the message loop
    # to keep the connection active
    try:
        io.loop()
    except (ValueError, RuntimeError) as e:
        print("Failed to get data, retrying...\n", e)
        wifi.reset()
        continue

User avatar
PonyXpress
 
Posts: 50
Joined: Fri Jul 01, 2022 10:51 am

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by PonyXpress »

Well things are now much worse and I have no idea what happened. It was working as I explained in my last post, but crashing about every 2 min. I made zero changes.

I saw your post and decided to try the new lib files. When I plugged it in, it will not boot and just keeps looping the boot. Again, I made zero changes since yesterday.

I decided to run through the instructions again, but nothing helps. No code seems to want to work now.
crashing.JPG
crashing.JPG (84.55 KiB) Viewed 456 times

User avatar
PonyXpress
 
Posts: 50
Joined: Fri Jul 01, 2022 10:51 am

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by PonyXpress »

That issue turned out to be power. For some reason my gaming tower pc is no longer providing enough power. When I plug into the wall, it started working again. I moved it to my test pc and it works there too. I'll have to sort out the usb power issue later on the gaming pc.

I downloaded the new lib files and copied the lib forder to the Titano, tested again. Same result, crashes after about 2 min with the same errors.

I will go back to the "Connect to the Internet" section and try that again.

User avatar
PonyXpress
 
Posts: 50
Joined: Fri Jul 01, 2022 10:51 am

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by PonyXpress »

I went back to the part where the instructions have you test connecting to the Internet, ran that code and it worked perfectly. My screen output matched the instruction example of what I should see. It says right on the screen that it connected to my AP, then Adafruit, ping Google, etc. all worked.

What else can I check?
wifitest.JPG
wifitest.JPG (76.52 KiB) Viewed 449 times

User avatar
mikeysklar
 
Posts: 14165
Joined: Mon Aug 01, 2016 8:10 pm

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by mikeysklar »

Glad you sorted out the power issue. Best to use a powered USB 2.x hub on your gaming machine as this display + WiFi enabled controller will large amount of current.

Since you know the connectivity is good with your WiFi and the code.py runs correctly for two minutes the part to focus on is logging data to AIO.

Is anything making it to your AIO dashboard?

In your secrets file does it say aio_user or aio_username? I see the code uses aio_user, but the secrets file shows aio_username.

Code: Select all

# Initialize a new MQTT Client object
mqtt_client = MQTT.MQTT(broker="io.adafruit.com",
                        username=secrets["aio_user"],
                        password=secrets["aio_key"])

User avatar
PonyXpress
 
Posts: 50
Joined: Fri Jul 01, 2022 10:51 am

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by PonyXpress »

Thanks again for your help. No, nothing reaches my dashboard and it shows nothing for the last Feed, meaning it has never received any Feed data.

I was getting an error early on and it was because the code wanted aio_username and my secretes file was using only aio_user. I updated my secrete file to use aio_username and the error went away. Also, when I tested the "Connect to the Internet" code.py that worked, it was using my same Secrets file. :) Unless, that test doesn't require or use the Secrets file.

Here is what my file looks like, without my actual user name and key, etc.

secrets = {
'ssid' : 'my wifi',
'password' : 'my password',
'timezone' : "America/New_York",
'aio_username' : 'my user name',
'aio_key' : 'aio_mykey',
}

While it seems to work until the communication and loop errors, nothing ever makes it to the dashboard. The communication error, sent 0 should read sent 2, so there is something weird with that in my smart pet planter code.py.

I have uploaded a copy of my code.py. Maybe I'm missing something.
code.py
(9.84 KiB) Downloaded 10 times
I'm really looking forward to sorting this out. I want to buy another titano and build another project.

Thanks!

Steve

User avatar
mikeysklar
 
Posts: 14165
Joined: Mon Aug 01, 2016 8:10 pm

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by mikeysklar »

Thank Steve,

Can you post a screenshot of your empty AIO dashboard. I want to confirm the feeds were setup since you are connecting which means your username and AIO key are good.

https://learn.adafruit.com/pyportal-pet ... ds-3053187

User avatar
PonyXpress
 
Posts: 50
Joined: Fri Jul 01, 2022 10:51 am

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by PonyXpress »

yes sir!
dash.JPG
dash.JPG (104.72 KiB) Viewed 411 times
devices.JPG
devices.JPG (98.61 KiB) Viewed 411 times
feeds.JPG
feeds.JPG (103.86 KiB) Viewed 411 times
Thank you!

User avatar
PonyXpress
 
Posts: 50
Joined: Fri Jul 01, 2022 10:51 am

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by PonyXpress »

Hello,

Can you tell me the exact url or address that the adafruit device is trying to communicate with? While the "Internet Connect" code.py worked, I want to make sure that my Pi Hole ad blocker isn't part of the problem. I can whitelist the address to cover that base.

Was there anything wrong with my code.py file I uploaded?

Does my secretes file look ok?

What else can I try?

User avatar
mikeysklar
 
Posts: 14165
Joined: Mon Aug 01, 2016 8:10 pm

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by mikeysklar »

Your AIO setup looks correct. Assuming your AIO key and username match your secrets file the only obvious obstacle would be the Pi Hole on your network. Can you take that out of the equation by either disabling it or whitelisting?

User avatar
adafruit2
 
Posts: 22187
Joined: Fri Mar 11, 2005 7:36 pm

Re: help with the PyPortal Pet Planter with Adafruit IO and

Post by adafruit2 »

paste your repl output - where is it failing?

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

Return to “Adafruit CircuitPython”