#do you mind taking this into a thread? it will keep any more discussion free of the clutter of other

1 messages · Page 1 of 1 (latest)

faint vault
terse shoal
#

yeah sorry

faint vault
#

no worries, just easier to follow

terse shoal
#

I just feel like it has to be the firmware cause I have followed multiple guids to a T and the all gave me the same error

faint vault
#

yeah, the certs are a likely issue, you'd have to try a whole bunch of HTTPS sites to see if any worked, but there's no harm to updating except that it's a little involved

terse shoal
#

yeah im on the step of connecting to it through the com6 port is there an easy was to do it on windows

#

like in terminal how can i find it to run pip3 install

faint vault
#

not sure about Windows, is there a hole in the guide steps?

terse shoal
#

nah i figured it out

#

Now i think i have to reinstall circuitpython

faint vault
#

yes, the passthrough took it over

#

your CIRCUITPY drive should be fine though

#

I've got dinner ready, but will check back a bit later

terse shoal
#

okay I just checked and my wifinina is up to 1.7.4 now but I am still getting sending errors

#

yup im still getting the same error at the same line in get_socket

faint vault
#

hmm... how about backing up and trying some simpler things? Which examples or code has successfully run?

terse shoal
#

I was just able to send and successfully receive data from an http get request

#

I’m taking a break to eat dinner but later I’m going to try an https get request and see what that does

faint vault
#

so far, HTTP always works, but HTTPS never has?

#

cool

terse shoal
#

Yes

#

That’s why I think there is an issue with the port

#

Maybe it is trying to access a socket that doesn’t exist for some reason

faint vault
#

the Google API may have some extra hurdles, but we should be able to get basic HTTPS working, I don't have that board but others do and I have tons of other Airlift configs and HTTPS is no problem

#

I'll be around

terse shoal
#

Okay thanks for your help

faint vault
#

I enjoy a challenge 🙂

terse shoal
#

Nah this has been much more challenging then I would have thought

#

*haha

faint vault
#

it's probably something simple, I've doing Airlift stuff for two years and it generally works fine

terse shoal
#

I just have no idea how sockets work so I’m having a hard time debugging

#

Like is it possible it’s because of the WiFi network I’m using

faint vault
#

it's possible but I don't think it's too likely, Airlift is designed to work in pretty standard ways

#

wifi networks can be wonky, but this doesn't seem to be an intermittent problem, and unless you have some unusual rules in your router, HTTPS/TCP/IP should just work

terse shoal
#

What should my next step to figure this out be I know that the error is in get socket during the loop where it tests of any sockets are free but I have no clue what I can do to fix that especially since it’s in a library function

faint vault
#

I'd suggest trying some more basic examples first... maybe you have, but it would help me to see how it behaves. And turning on debug can give good info

terse shoal
#

I’ll try more simple tests do you know any http post request test I can do

faint vault
#

even a GET would be fine, I doubt this is specific to POST

#

(ignore the angle brackets)

#

I'm trying to find example code in the libraries

#

we should double-check your CircuitPython version and library version and install too

#

I can mirror what you do on my PyPortal and we can compare notes

terse shoal
#

I have tried the post request in the example code and it did not work

#

I just reinstalled version 7 of circuitpython and I installed all the libraries in version 7

faint vault
#

OK, it works for me, so we just need to find out what's different 🙂

#

OK, CircuitPython 7.0.0

terse shoal
#

That entire code snippet works?

faint vault
#

recent date of libraries from the bundle, all placed in the /lib folder?

#

and no libraries scattered at the root level (/), or anywhere else?

#

all .mpy library files, no .py?

terse shoal
#

All libraries are in the lib folder and they are all .mpy

#

What do you mean recent date tho

faint vault
#

important that no libraries are at the root level or in .py format, either case will override the /lib/adafruit...mpy version

terse shoal
#

Ahh I see I think that is all fine

faint vault
terse shoal
#

Yes I am using the version 7.x

faint vault
#

yeah, that example all works fine on my PyPortal

terse shoal
#

That’s the file I downlaodes and have been taking libraries from

#

Hmmm

faint vault
#

ok, good

terse shoal
#

What esp chip is in the pyportal

faint vault
#

just to be triple-sure, can you screenshot a file manager view of your CIRCUITPY root and /lib folder?

#

same ESP32 in PyPortal, essentially the same processor and ESP32, just different pins, screen, etc

terse shoal
#

I see

#

I can sent you a screenshot in like 10 minutes

faint vault
#

no worries, I'll be around

terse shoal
#

and this is inside of the library

faint vault
#

good, as expected, that all looks fine

#

can you run the example code linked above, but with this tweak: esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset, debug=1) and see if it helps pinpoint where it goes south

#

here's what mine looks like after it completes the HTTP at adafruit and tries the first HTTPS URL

terse shoal
#

im going to retry it adding the debug = 1

#

but on first attempt it failed at the https get request

#

so its an issue with https vs http

faint vault
#

looking at Requests now...

#

we may want to make some edits in Requests... are you game to download a .py version of the library and try some things?

#

there are some errors that can occur that essentially get ignored, but it could be useful to see if they are the ones getting triggered

terse shoal
#

sure

faint vault
#

once you have that as a text file, named adafruit_requests.py, you can put it at the root level on CIRCUITPY and it will override the .mpy in the /lib folder

#

you have an editor that works for you to edit live files on CIRCUITPY? or do you edit on your computer then paste/drag them over?

terse shoal
#

i can do live basically

#

when i save it auto reruns

#

do i need to delete the adafruit requests file from my library or will it not be used

#

and I am at that step

faint vault
#

the .py at the root level will take precedence over the .mpy in the /lib folder, so you can leave that there

terse shoal
#

good

faint vault
#

OK, open the new .py file in your editor and go down to around line 430

#

bear with me, this is a little bit of a shot in the dark... we're basically going to un-ignore a few errors and see if one of them causes an exception

terse shoal
#

Okay so the os error?

faint vault
#

so here, line 430:``` except OSError:
continue
except RuntimeError:
continue

#

[these are usually routine errors that get fixed on a retry, but maybe not in this case]

terse shoal
#

Nothing changed from Oder or

#

*os error

faint vault
#

ok, may as well leave it commented out and then also comment out the RuntimeError

#

rinse, repeat debug=1

terse shoal
#

What about the memory error on like 440

faint vault
#

yeah, those two next

#

I doubt it's those latter two though or another exception would trigger I think

#

but can't hurt to unignore All. Teh. Things.

terse shoal
#

First two didn’t change anything

#

Neither did memory error

#

The second oserror is the issue I think

#

so the socket.host is returning an error

#

i think

faint vault
#

you've changed your line numbering, whuch line is 440 and 651?

#

ah, ok

#

maybe a DNS issue

terse shoal
faint vault
#

is there anything special about your router or wifi that you think might be relevant? custom rules, special DNS features, etc?

terse shoal
#

It university WiFi so I had to add the MAC address of my dev board to my account so it could connect

#

It definitely could have special rules

faint vault
#

wow, that's gonna be tough... do you have a cellphone that you can tether to its wifi to try a different path?

#

or close-by coffee shop wifi? 😉

#

or your own wifi Access point that you could wire into the uni network?

terse shoal
#

I tried my hotspot but it wasn’t connecting

faint vault
#

wow, hmmm

terse shoal
#

Let me see where else I could connect

#

This is requirements of our WiFi

faint vault
#

the fact that we have so very similar HW and SW does lean to it being an external issue (network)

#

I don't see how any of those rules is enforceable in an automated way, but who knows

#

CircuitPython in this case is doing very standard wifi Station, DNS, and HTTPS. I can't imagine why they would block anything once your MAC is accepted by the wifi network

terse shoal
#

Yeah so I don’t know if that’s actually the issue I just can’t really test it right now to make sure

faint vault
#

right, OK, another thing to see if anything stand out as unusual...

#

can you paste this into your code.py early but after all the wifi/esp/socket setup:``` print("RSSI: ", esp.rssi)
print("SSID: ", str(esp.ssid, 'utf-8'))
print("BSSID: {5:02X}:{4:02X}:{3:02X}:{2:02X}:{1:02X}:{0:02X}".format(*esp.bssid))
print("IP: ", esp.pretty_ip(esp.ip_address))
print("Netmask: %d.%d.%d.%d" % (esp.network_data['netmask'][0], esp.network_data['netmask'][1], esp.network_data['netmask'][2], esp.network_data['netmask'][3]))
print("Gateway: %d.%d.%d.%d" % (esp.network_data['gateway'][0], esp.network_data['gateway'][1], esp.network_data['gateway'][2], esp.network_data['gateway'][3]))
print("LAN ping: %dms" % esp.ping(esp.network_data['gateway']))
print("WAN ping: %dms" % esp.ping(secrets['host']))

#

we can see that you have a normal IP address, etc

#

but HTTP works, so this will probably all be fine

terse shoal
#

I don’t have a hosts secret

#

What do I put that as

faint vault
#

right, sorry, you can delete that line, that's just something I do

#

you can put in 1.1.1.1 or 8.8.8.8 or something rather than secrets['host']

terse shoal
#

Okay but are the rest correct?

faint vault
#

yeah, should be fine, sometimes the ping comes back at max, but if you do it a few times, it will probably be 0.020 or something

#

Now, technically, you are violating the rules you posted above. I don't want you to get in trouble

terse shoal
#

How do?

#

*so

faint vault
#

well, supported OS? I suspect not. Latest version? yes. Password for all accounts? No. anti-malware? no.

#

I think it's worthwhile at some point here when convenient to see if the device can connect to one or more other networks

terse shoal
#

I definitely want to try on other networks but don’t worry about those rules

#

I was just seeing if one of those would cause this error

faint vault
#

do you mind if I DM you a question?

terse shoal
#

Sure

faint vault
#

I'm not sure what else to do at this point

#

another network seems most promising

#

You can rename (or delete, though you may want to keep it around for further debugging) the adafruit_requests.py at the root level to go back to the /lib/...mpy version

terse shoal
#

i just dont understand how http requests are still working then

faint vault
#

I don't either, I'm a bit baffled

#

I assume through all this, you've hardware reset the Metro a few times

#

I think the libraries reset the ESP32 in some of the cases we've seen too... you can do that in code with esp.reset() ...maybe worth a try to put that in code between the HTTP and HTTPS parts of the example

#

and one other sanity check...

terse shoal
#

I’ll try that

faint vault
#

one sec, finding the little code snippet...

terse shoal
#

Added a reset and now I get a different error actually

#

This time inside of Esposito socket

#

*espspi

faint vault
#

interesting, question still is why would DNS work for HTTP but fail for HTTPS

#

can you load that URL in your browser?

terse shoal
#

I loaded it

faint vault
#

OK, and I assume if you do the same URL but HTTP, it works: JSON_GET_URL = "http://httpbin.org/get"

#

was there a step when updating the firmware to check it at the end, like somewhere in code: esp.firmware_version

terse shoal
#

It’s 1.7.4

#

And yes that url http works

faint vault
#

total sanity check (my open ellipses from above... can you go either in code put print(adafruit_esp32spi.__version__) or in the REPL:from adafruit_esp32spi import adafruit_esp32spi adafruit_esp32spi.__version__

#

(should be 3.5.11)

terse shoal
#

It is

faint vault
#

wow, everything checks out on the board and software, it sure seems to point to the network. I don't know what else I could be missing

#

very peculiar ...is this an assignment with a deadline, or more hobby

#

do you have any other microcontrollers?

#

(with networking)

terse shoal
#

It’s my senior design project so some deadlines yeah

#

And no the other issue is that we are actually designing our own pcb and we decided to make ours similar to the airlift lite cuz it’s got all of the capabilities we need

faint vault
#

ah, nice

#

maybe one of us will get an epiphany in the middle of the night (or not). Sorry I can;'t think of anything else to try right now except another network (or two)

#

is there anyone to ping this problem off of there who may be experiencing something similar?

#

or housing IT? gah! rules

terse shoal
#

That’s the issue we are the only group trying to use an api so besides our ta not many people can help with it

#

I can definitely try the network

#

I just need to go to a friends place that set up their own router

#

Do I need to do anything after I call esp.reset for it to be usable?

faint vault
#

can you try a couple more times to see if the "failed to request hostname" error persists?

#

it's really weird that it fails there for HTTPS but not for HTTP, DNS should be independent of the request protocol

terse shoal
#

Let me see what happens with the esp reset when it’s http

faint vault
#

No, esp.reset is a standalone thing that just puts the ESP32 in a good fresh state, it's a useful thing to do when errors accumulate that aren't recoverable with retries.

terse shoal
#

Yeah I get that error even when it’s Http not https

#

Which is weird

faint vault
#

There could be a small delay needed after reset to let things settle out. (Not typically a problem except for the built-in esp.get_time function)

terse shoal
#

Should I do a wait for like 5 seconds then?

faint vault
#

may need a delay, hopefully not more than a second, 5 can't hurt

terse shoal
#

the delay did not change

#

anything

#

Not sure if the reset even helps with the other issue because it never hits that part of get socket

faint vault
#

yeah, it was just an avenue to explore. In practice, the ESP32, or wifi in general, can have issues, and usually retries will get it going. But sometimes ESP32 needs a kick (reset) to clean it up.

terse shoal
#

So I just looked up the error code that is getting raised and it’s saying it’s because there isn’t enough storage

#

Enomem is what it’s called

faint vault
#

yeah, but that gets raised for any RunTime error... it may be the usual case but it's not guaranteed to indicate a memory error (just to keep in mind)

terse shoal
#

Ahh I see

#

Soooooooooooo

#

I got my hotspot to work

#

And I hate the WiFi at this school

faint vault
#

the example works on the hotspot?

terse shoal
#

Yes

faint vault
#

coooool

#

that's some confirmation

#

the network is doing something very unexpected

terse shoal
#

Yep

#

Not sure what it doesn’t like about that port but it’s not a fan

faint vault
#

multiple criteria at play, browser is fine... for grins, what about...

#

can you humor me on one thing? doing curl in the command line:

#

curl --http1.1 -iL -A "User-Agent: Adafruit CircuitPython" https://httpbin.org/get
...this should closely replicate what Requests is doing: HTTP/1.1, custom User-Agent

#

it's encrypted, so user agent should be irrelevant, but perhaps the network is finicky about HTTP/1.1

#

...should come back with something like:```HTTP/1.1 200 OK
Date: Tue, 02 Nov 2021 02:39:24 GMT
Content-Type: application/json
Content-Length: 277
Connection: keep-alive
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true

{
"args": {},
"headers": {
"Accept": "/",
"Host": "httpbin.org",
"User-Agent": "User-Agent: Adafruit CircuitPython",
"X-Amzn-Trace-Id": "Root=1-6180a4dc-20b4a1741bba104f3e86e40f"
},
"origin": "209.RE.DA.CT",
"url": "https://httpbin.org/get"
}```

terse shoal
#

ill try it

#

it worked in my command line

faint vault
#

weird, MAC address is different, other differences between that curl and the CP device are pretty nuanced

terse shoal
#

yeah im not sure

#

also do you happen to know the right format to add an api key to a post url

#

im finally getting to test with the google api and Im getting an error

faint vault
#

might have to dig into the Google API docs, could be a header, which you can add in the request.POST call

terse shoal
#

it looks like the just parse it to the end of the string

#

so thats what i was trying to do

faint vault
terse shoal
#

yes

#

can i just do that or is there a better format I should follow

#

Im keeping the key in my secrets so i want to do it like that instead of just having it at the end of the string

faint vault
#

you can just do that, you may ultimately want the key in secrets like the wifi credentials, keeps you from accidentally sharing it if you post your code

#

yup 🙂

terse shoal
#

this right ot do i need it in quotes

faint vault
#

yeah, you'll have to compose it from string parts

#

e.g.,

#

"".join(("https://.../?key=", secrets['key']))

#

(that form with join is a memory-friendly way to combine strings)

#

there are tons of ways though

terse shoal
#

i see that way makes a lot of sense

#

using a hotspot is awful for testing it takes forever to connect

faint vault
#

yeah, I'd be interested to know if you ever figure out why the network doesn't like it

#

sounds like things are rolling, good luck with the project!, come back to the #help-with-circuitpython channel any time with more questions

#

and if you'd like to share your project when it's done, I'm sure folks would be interested... #show-and-tell, or anywhere really

terse shoal
#

sounds good thank you so much for your help hopefully my projects works fully

#

i have one last quick question

faint vault
#

@terse shoal sure, what's up

terse shoal
#

@faint vault sorry I ended up calling it for the night and going to bed. My question is if you have any experience using jlink to program microcontrollers. I dont have any experience with this and I am trynig to find information on the best way to do this so that once our pcb is here we can program our microcontroller to act similar to the dev board we are using

faint vault
#

I don't, but others on this server and elsewhere do. I'd suggest posting a new question. From what I've read around here, it's fairly straightforward, largely some learning curve on the setup.