Odd errors?

Been trying to run a weather station for some time now but am getting the following errors.

connecting to wifi network 'MyNetwork'
! failed to connect to wireless network MyNetwork
2023-12-29 18:43:07 [error / 132kB] - cannot upload readings, wifi connection failed
2023-12-29 18:43:07 [error / 129kB] ! reading upload failed

My WIFI network is working perfectly and all my other devices connect 100%. SSID and password have been checked to be correct many times.
This from earlier in the log:

connecting to wifi network 'MyNetwork'
2023-12-29 18:15:06 [info / 134kB] - ip address: 192.168.0.44
2023-12-29 18:15:07 [info / 127kB] > uploading cached readings to Adafruit.io: XYZ

So then it connected fine but it will not later?

The other error is

uploading cached readings to Adafruit.io: XYZ
2023-12-29 18:42:56 [info / 112kB] - uploaded 2023-12-29T18_26_33Z.json
2023-12-29 18:42:57 [info / 91kB] - uploaded 2023-12-29T18_30_05Z.json
2023-12-29 18:42:58 [info / 114kB] - uploaded 2023-12-29T18_32_04Z.json
2023-12-29 18:42:59 [info / 98kB] - cannot upload '2023-12-29T18_32_46Z.json' - rate limited
2023-12-29 18:42:59 [info / 95kB] > going to sleep for 1 minute(s)

What is “rate limited” and why would I get that error? reading_frequency = 15 and upload_frequency = 3

The “connection failed” is just WiFi being WiFi; I suspect it’s a combination of certain WiFi routers and the fact that applications like the weather station spend a lot of time dropping / reconnecting. Generally, it’s a transient error and you’ll get a good connection the next time it attempts it.

The “rate limited” sounds like you’re hitting the limits on your (free?) Adafruit.io account (which, again, will be a bit of a transient error but if you consistently hit it, you may have just outgrown the free offering)

Thanks for your response, but it won’t generally connect to my router at all. If it does actually connect once it just fails to connect again and again after that.
I’ve been struggling on and off for months to get this to work but am getting to the point I’d like to just bin it.
It’s either just sits on:
2024-01-02 12:16:52 [info / 121kB] > connecting to wifi network 'MyNetwork'
and will go no further or (on trying a different router):

2024-01-02 12:30:07 [error    / 119kB] ! failed to connect to wireless network MyNetwork
2024-01-02 12:30:07 [error    / 116kB]   - cannot upload readings, wifi connection failed
2024-01-02 12:30:07 [error    / 114kB] ! reading upload failed

I’ve tried everything I can think of with the 2 routers I have but maybe the Pico Pi is just not compatible with any of them in which case I’m not buying another new router just for the Pico.
I’m so tired of this…I had such high hopes…

Ahh, ok - my bad, I misread your first post as being an ‘occasional’ problem, rather than a wider “it won’t talk to my WiFi”…

So, a few possible things to explore - are you using 2.4GHz or 5GHz? IIRC the Picow is … happier with one or the other, so if you have the options within your router it might be worth trying that.

Next up, how close is your router? The Picow (obviously) doesn’t exactly have much of an arial, so a location that’s on the edge of reception for your phone might be a non-starter for the Pico.

The timestamps on some of your messages feel a bit off too; “going to sleep” at 18:42:59 but then trying to reconnect to your WiFi less than 8 seconds later seems odd. Is it powered via USB, or battery?

I’m using 2.4GHz, I hadn’t even thought of trying 5GHz (and didn’t know the PicoW had 5GHz). Will investigate.

Router is 10m (30ft) away and not blocked by anything so I presume it should be able to connect from that distance. Will try again from very close.

It’s powered by battery but when those timestamps were made I had pressed the poke button to take a reading and upload it.

On USB and very close to the router, I deleted the old log and reset the board, it flashed the red LED so I reset again and this is the log output:

2000-01-01 00:04:52 [info     / 138kB] > performing startup
2000-01-01 00:04:52 [debug    / 135kB]   - running Enviro 0.0.10, MicroPython 856e08b1931b88271816a2f60648f6ff332235b2, enviro v1.20.4 on 2023-08-04
2000-01-01 00:04:52 [info     / 126kB]   - wake reason: usb_powered
2000-01-01 00:04:52 [debug    / 124kB]   - turn on activity led
2000-01-01 00:04:52 [info     / 122kB] > clock not set, synchronise from ntp server
2000-01-01 00:04:52 [info     / 120kB] > connecting to wifi network 'MyNetwork'
2000-01-01 00:04:55 [info     / 107kB]   - ip address:  192.168.0.171
2000-01-01 00:05:05 [error    /  98kB]   - failed to fetch time from ntp server
2000-01-01 00:05:05 [error    /  96kB] ! failed to synchronise clock
2000-01-01 00:05:06 [info     /  94kB] > going to sleep
2000-01-01 00:05:06 [debug    /  92kB]   - clearing and disabling previous alarm
2000-01-01 00:05:06 [info     /  89kB]   - setting alarm to wake at 00:10am
2000-01-01 00:05:06 [info     /  87kB]   - shutting down
2000-01-01 00:05:06 [debug    / 133kB]   - on usb power (so can't shutdown). Halt and wait for alarm or user reset instead

2000-01-01 00:08:13 [info     / 138kB] > performing startup
2000-01-01 00:08:13 [debug    / 135kB]   - running Enviro 0.0.10, MicroPython 856e08b1931b88271816a2f60648f6ff332235b2, enviro v1.20.4 on 2023-08-04
2000-01-01 00:08:13 [info     / 126kB]   - wake reason: usb_powered
2000-01-01 00:08:13 [debug    / 124kB]   - turn on activity led
2000-01-01 00:08:13 [info     / 122kB] > clock not set, synchronise from ntp server
2000-01-01 00:08:13 [info     / 120kB] > connecting to wifi network 'MyNetwork'
2000-01-01 00:08:16 [error    / 106kB] ! failed to connect to wireless network MyNetwork
2000-01-01 00:08:17 [error    / 133kB] ! failed to synchronise clock
2000-01-01 00:08:17 [info     / 131kB] > going to sleep
2000-01-01 00:08:17 [debug    / 129kB]   - clearing and disabling previous alarm
2000-01-01 00:08:17 [info     / 127kB]   - setting alarm to wake at 00:10am
2000-01-01 00:08:17 [info     / 125kB]   - shutting down
2000-01-01 00:08:17 [debug    / 122kB]   - on usb power (so can't shutdown). Halt and wait for alarm or user reset instead

So it did connect initially, couldn’t synchronize the clock (have not seen this before), then the second time it tried to connect it was unsuccessful.

Ahh, the 5GHz thing might have been a red herring because you’re right, I don’t think it supports it (I might be thinking of instances where people had been trying to connect to 5GHz-only routers)

I notice on your latest runs you’re getting a much higher IP address assigned (.44 up to .171), which makes me wonder if all the connection attempts are causing your router to fill up it’s DHCP tables or something daft like that. Do you know what model your router is, there may well be a way to tell it to always assign the same address to the Picow’s MAC address to stabilize that.

Otherwise, we’ve ruled out most of the obvious things I can think of to check…

I would say no, not necessarily. My experience is that 5m is sometimes already too much for the Pico W.

What you could do is to try to tweak the network connection code. Now I don’t run this Pimoroni MicroPython stuff, but with my own code (CircuitPython) I always do retries if the connection fails and it turns out that most of the time I need a second try - the chip seems to give up too early. The CircuitPython code does allow me to set timeouts, but they don’t seem to have any effect. Maybe it is the same on MicroPython.

Also now getting the following errors when my Enviro Weather tries to upload to Adafruit IO.

2024-02-11 07:35:47 [info / 108kB] > uploading cached readings to Adafruit.io: USER
2024-02-11 07:36:05 [debug / 116kB] - an exception occurred when uploading. Traceback (most recent call last):
File “enviro/destinations/adafruit_io.py”, line 31, in upload_reading
File “urequests.py”, line 184, in post
File “urequests.py”, line 91, in request
OSError: [Errno 103] ECONNABORTED

2024-02-11 07:36:05 [error / 114kB] ! failed to upload ‘2024-02-11T07_08_53Z.json’ to adafruit_io

Is this my error, an Adafruit error or something wrong with the code?

ECONNABORTED is telling you that the connection was initially established, but aborted before complete - in the absence of other information it’s hard to say much more, but it’s either

(a) your own network is dropping the WiFi connection, or your broadband
(b) Adafruit’s server falling over for some reason
(c) the internet between you and Adafruit falling over for some reason

All of these are likely to be temporary problems that should sort themselves out.

While it’s certainly possible to be something wrong with the code, if you haven’t changed anything I’m not aware of it showing up elsewhere.