Pyportal Pynt IO and SSL

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
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: Pyportal Pynt IO and SSL

Post by oldblackcrow »

Now I'm getting this:

code.py output:
Traceback (most recent call last):
File "code.py", line 15
SyntaxError: invalid syntax

CODE is as such

Code: Select all

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import board
import busio
from digitalio import DigitalInOut, Direction  # pylint: disable=unused-import
import adafruit_miniesptool

print("ESP32 Nina-FW")

# Override these if you are manually wiring. Otherwise, this will use ESP pins from board.
tx = board.ESP_TX
rx = board.ESP_RX
in = board.ESP_RESET
gpio0pin = board.ESP_GPIO0

uart = busio.UART(tx, rx, baudrate=115200, timeout=1)

esptool = adafruit_miniesptool.miniesptool(
    uart, DigitalInOut(gpio0pin), DigitalInOut(resetpin), flashsize=4 * 1024 * 1024
)
esptool.sync()

print("Synced")
print("Found:", esptool.chip_name)
if esptool.chip_name != "ESP32":
    raise RuntimeError("This example is for ESP32 only")
esptool.baudrate = 912600
print("MAC ADDR: ", [hex(i) for i in esptool.mac_addr])

# Note: Make sure to use the LATEST nina-fw binary release!
esptool.flash_file("NINA_W102-1.7.1.bin", 0x0, "dc81f0433dfba6de33c78b5c5911261d")

esptool.reset()
time.sleep(0.5)

User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: Pyportal Pynt IO and SSL

Post by oldblackcrow »

Ok... so, I changed a line from your changes:

Code: Select all

resetpin = board.ESP_RESET
gpio0pin = board.ESP_GPIO0
Then I got this:

code.py output:
ESP32 Nina-FW
Resetting
Synced
Found: ESP32
MAC ADDR: ['0x24', '0x62', '0xab', '0xb9', '0xc7', '0xfc']

Writing NINA_W102-1.7.1.bin w/filesize: 1159168
Traceback (most recent call last):
File "code.py", line 33, in <module>
File "/lib/adafruit_miniesptool.py", line 430, in flash_file
File "/lib/adafruit_miniesptool.py", line 404, in flash_file
File "/lib/adafruit_miniesptool.py", line 247, in flash_begin
File "/lib/adafruit_miniesptool.py", line 288, in check_command
RuntimeError: Didn't get enough status bytes

Code done running.



Seems we are at least getting closer. The NINA_W102-1.7.1.bin file is in the root directory of the PyPortal Pynt.

It's stating the same thing the Chrome ESPTool, "Didn't get enough status bytes"

User avatar
tannewt
 
Posts: 3304
Joined: Thu Oct 06, 2016 8:48 pm

Re: Pyportal Pynt IO and SSL

Post by tannewt »

Hrm, I'm not sure how to fix that. I think I usually try it a couple times and it works. Did you try it multiple times? Also try completely unplugging it and plugging it back in. Sometimes the ESP gets in a weird state.

User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: Pyportal Pynt IO and SSL

Post by oldblackcrow »

I can't count how many times I've tried ... And different configurations with different settings in windows... And just plane unplugging/plugging in. Gets stuck every time

User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: Pyportal Pynt IO and SSL

Post by oldblackcrow »

tannewt wrote:Hrm, I'm not sure how to fix that.
So, now that we've established there is nothing left to do with this, I will humbly restate my request that either I send in my current PyPortal to be upgraded to the latest ESP32 firmware or that I get a new one with the firmware already updated before shipping out to me.

If you read my OP, the reason I've had to go through all this is to get code working so I can pull information from AdafruitIO. Without this function, the board is useless to me. Thanks again and look forward to hearing back.

User avatar
tannewt
 
Posts: 3304
Joined: Thu Oct 06, 2016 8:48 pm

Re: Pyportal Pynt IO and SSL

Post by tannewt »

oldblackcrow wrote:So, now that we've established there is nothing left to do with this, I will humbly restate my request that either I send in my current PyPortal to be upgraded to the latest ESP32 firmware or that I get a new one with the firmware already updated before shipping out to me.
I've asked someone else who has worked more on this to take a look. I hesitate to RMA it because the hardware seems to be working and any version we replace it with may have an old version of the code anyway. (We don't update the testers that load the original code often.) I think the best option is wait while someone takes a look for us. (They may need to order hardware themselves so it might be a few days.)

User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: Pyportal Pynt IO and SSL

Post by oldblackcrow »

Thank you.

User avatar
MakerMelissa
 
Posts: 375
Joined: Wed Jun 05, 2013 2:10 am

Re: Pyportal Pynt IO and SSL

Post by MakerMelissa »

Hello,

First of all, I took a look over the messages in this thread and see you've been trying to get this working for quite a while and have had several people unable to help you get it back up and running.

I developed the WebSerial ESPTool and while developing it, it was mainly tested with the ESP32-S2, but was supposed to work with the ESP32 as well. I just tried a PyPortal Pynt using the WebSerial ESPTool and am also getting a "didn't get enough status bytes" error. I have an issue opened here: https://github.com/adafruit/Adafruit_We ... l/issues/4. While I was at it, I tried it with a regular PyPortal and got the same error. I can take a look at this tomorrow and hopefully if I can get it working with the WiFi coprocessor firmware updates here pretty quickly.

Melissa

User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: Pyportal Pynt IO and SSL

Post by oldblackcrow »

Thank you MakerMelissa. I really do appreciate everyone's help on this and I'm glad you're on the job. Hope to hear good things soon.

User avatar
MakerMelissa
 
Posts: 375
Joined: Wed Jun 05, 2013 2:10 am

Re: Pyportal Pynt IO and SSL

Post by MakerMelissa »

Hi,

I was able to successfully program mine using the passthru UF2 file and the WebSerial ESPTool. It looks like the issue is that the speed needs to be 115200 for the WebSerial ESPTool to work. At the slower speed, it takes like 5-10 minutes to program it. I ran the Internet connect script successfully just to verify. Hopefully this finally fixes the issue.

Melissa

User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: Pyportal Pynt IO and SSL

Post by oldblackcrow »

Unfortunately, that does not do it. I changed the speed to 115200 on all the attempts with no avail... Then I changed it to slower and faster speeds just to experiment but still no go. It always fails at the same point in the process... About 70% in to it. This goes for the python code provided above as well as the web serial esptool. I'm sure I mentioned that in previous posts.

User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: Pyportal Pynt IO and SSL

Post by oldblackcrow »

It finally worked! Thank you for your help!

However, here are some particulars that should be mentioned in the instructions... maybe this didn't apply to you, but it happened consistently with me.

1. The Web version of the ESPTool did not work at all. No matter what I did, it would only get to 70% and then fail (see previous posts).
2. The Python code supplied also did not work if I ran it with Mu. Once I closed Mu and just re-booted the PyPortal, the code worked fine. This was unclear for me because I assumed that Mu must me open during the update process.

However, now that it works, we can move on to my original OP to get my AdafruitIO data showing up on my PyPortal.

User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: Pyportal Pynt IO and SSL

Post by oldblackcrow »

Ok... Back to my OP:

So, I'm still getting a JSON error. Here is the code I'm trying to use (my Secrets file has all correct info):

Code: Select all

import time
import board
import busio
from digitalio import DigitalInOut
import neopixel
from adafruit_esp32spi import adafruit_esp32spi
from adafruit_esp32spi import adafruit_esp32spi_wifimanager

print("ESP32 SPI webclient test")

# 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

# If you are using a board with pre-defined ESP32 Pins:
esp32_cs = DigitalInOut(board.ESP_CS)
esp32_ready = DigitalInOut(board.ESP_BUSY)
esp32_reset = DigitalInOut(board.ESP_RESET)

spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
"""Use below for Most Boards"""
status_light = neopixel.NeoPixel(
    board.NEOPIXEL, 1, brightness=0.2
)  # Uncomment for Most Boards

wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, secrets, status_light)

counter = 0

while True:
    try:
        print("Posting data...", end="")
        data = counter
        feed = "test"
        payload = {"value": data}
        response = wifi.post(
            "https://io.adafruit.com/oldblackcrow/"
            + secrets["aio_username"]
            + "/feeds/"
            + feed
            + "/rx",
            json=payload,
            headers={"X-AIO-KEY": secrets["aio_key"]},
        )
        print(response.json())
        response.close()
        counter = counter + 1
        print("OK")
    except (ValueError, RuntimeError) as e:
        print("Failed to get data, retrying\n", e)
        wifi.reset()
        continue
    response = None
    time.sleep(15)
This is what I'm getting in Mu:

code.py output:
ESP32 SPI webclient test
Posting data...Failed to get data, retrying
syntax error in JSON

User avatar
MakerMelissa
 
Posts: 375
Joined: Wed Jun 05, 2013 2:10 am

Re: Pyportal Pynt IO and SSL

Post by MakerMelissa »

Excellent news and thank you for letting us know what you did to get it to finally work. I'll have to try the online version on some other systems later as perhaps it's only working on some computers.

As for Adafruit IO, I'm going to take another look over your posts first, so I make sure I'm up to date on everything.

User avatar
MakerMelissa
 
Posts: 375
Joined: Wed Jun 05, 2013 2:10 am

Re: Pyportal Pynt IO and SSL

Post by MakerMelissa »

Ok, I just tried your code (updated to my user account) and am getting the same error, so I'm going to hack on it a bit and see if I can get it to work.

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

Return to “Adafruit CircuitPython”