#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)
yeah sorry
no worries, just easier to follow
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
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
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
not sure about Windows, is there a hole in the guide steps?
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
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
hmm... how about backing up and trying some simpler things? Which examples or code has successfully run?
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
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
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
Okay thanks for your help
I enjoy a challenge 🙂
it's probably something simple, I've doing Airlift stuff for two years and it generally works fine
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
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
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
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
I’ll try more simple tests do you know any http post request test I can do
even a GET would be fine, I doubt this is specific to POST
but one example would be <"http://httpbin.org/post" -H "accept: application/json">
(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
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
OK, it works for me, so we just need to find out what's different 🙂
OK, CircuitPython 7.0.0
That entire code snippet works?
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?
All libraries are in the lib folder and they are all .mpy
What do you mean recent date tho
important that no libraries are at the root level or in .py format, either case will override the /lib/adafruit...mpy version
Ahh I see I think that is all fine
like a recent library bundle https://circuitpython.org/libraries
Yes I am using the version 7.x
yeah, that example all works fine on my PyPortal
ok, good
What esp chip is in the pyportal
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
no worries, I'll be around
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
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
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
sure
OK, pull down the adafruit_requests.py file, there are probably a variety of ways, but I usually go here and click RAW in the upper right, then copy-paste that into a file named the same https://github.com/adafruit/Adafruit_CircuitPython_Requests/blob/main/adafruit_requests.py
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?
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
the .py at the root level will take precedence over the .mpy in the /lib folder, so you can leave that there
good
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
Okay so the os error?
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]
ok, may as well leave it commented out and then also comment out the RuntimeError
rinse, repeat debug=1
What about the memory error on like 440
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.
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
you've changed your line numbering, whuch line is 440 and 651?
ah, ok
maybe a DNS issue
is there anything special about your router or wifi that you think might be relevant? custom rules, special DNS features, etc?
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
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?
I tried my hotspot but it wasn’t connecting
wow, hmmm
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
Yeah so I don’t know if that’s actually the issue I just can’t really test it right now to make sure
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
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']
Okay but are the rest correct?
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
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
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
do you mind if I DM you a question?
Sure
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
i just dont understand how http requests are still working then
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...
I’ll try that
one sec, finding the little code snippet...
Added a reset and now I get a different error actually
This time inside of Esposito socket
*espspi
interesting, question still is why would DNS work for HTTP but fail for HTTPS
can you load that URL in your browser?
I loaded it
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
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)
It is
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)
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
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
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?
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
Let me see what happens with the esp reset when it’s http
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.
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)
Should I do a wait for like 5 seconds then?
may need a delay, hopefully not more than a second, 5 can't hurt
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
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.
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
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)
Ahh I see
Soooooooooooo
I got my hotspot to work
And I hate the WiFi at this school
the example works on the hotspot?
Yes
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"
}```
weird, MAC address is different, other differences between that curl and the CP device are pretty nuanced
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
might have to dig into the Google API docs, could be a header, which you can add in the request.POST call
it looks like the just parse it to the end of the string
so thats what i was trying to do
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
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 🙂
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
i see that way makes a lot of sense
using a hotspot is awful for testing it takes forever to connect
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
sounds good thank you so much for your help hopefully my projects works fully
i have one last quick question
@terse shoal sure, what's up
@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
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.