Enviro grow and Enviro Indoor both cannot sync time


I have a new Enviro Grow and Enviro Indoor that I am trying to set up. On first try following the provisioning web page, I got a red flashing light and no connection to wifi. In the logs I was seeing a problem with synching the time.
So I updated the UF2 file to pimoroni-enviro-v1.22.2-micropython-enviro-v0.2.0.uf2
I ran the setup again, same issue. Here are the logs :

2000-01-01 00:00:13 [info     / 138kB] > Connected successfully!
2000-01-01 00:00:13 [info     / 135kB] > IP:, Subnet:, Gateway:, DNS:
2000-01-01 00:00:13 [info     / 133kB] > Elapsed: 9603ms
2000-01-01 00:00:13 [warning  / 117kB]   - took 9.603 seconds to connect to wifi
2000-01-01 00:00:23 [error    / 126kB]   - failed to fetch time from ntp server
2000-01-01 00:00:23 [error    / 124kB] ! failed to synchronise clock
2000-01-01 00:00:24 [info     / 122kB] > going to sleep
2000-01-01 00:00:24 [debug    / 120kB]   - clearing and disabling previous alarm
2000-01-01 00:00:24 [info     / 117kB]   - setting alarm to wake at 00:15am
2000-01-01 00:00:24 [info     / 115kB]   - shutting down
2000-01-01 00:03:31 [info     / 133kB] > performing startup
2000-01-01 00:03:31 [debug    / 131kB]   - running Enviro 0.0.10, MicroPython v1.22.2, enviro v1.22.2 on 2024-03-06
2000-01-01 00:03:31 [info     / 141kB]   - wake reason: usb_powered
2000-01-01 00:03:31 [debug    / 139kB]   - turn on activity led
2000-01-01 00:03:31 [info     / 137kB] > clock not set, synchronise from ntp server
2000-01-01 00:03:31 [info     / 135kB] > connecting to wifi network 'SilenceOfTheLAN'
2000-01-01 00:03:32 [info     / 131kB] > MAC: 28:cd:c1:05:02:63
2000-01-01 00:03:32 [info     / 129kB] > active: 0, status: 0 (Link is down)
2000-01-01 00:03:32 [info     / 127kB] > Ready for connection!

If I reset the board with the reset button, it goes back to the same error. I get the amber light flashing, and then a red light, and the logs show the same errors.
Both boards get the same error.

I even tried updating the NTP server. I thought it might be because I am using the boards in the US.
So I updated ntp.py with a different server : ntp_host = “us.pool.ntp.org

I also tried writing some regular python to call an NTP server and get the time from my laptop, and that worked fine.
I also tried connecting to my wifi on 2.4 and 5ghz, and also tried disabling 802.11ax Mode on my router. Just incase it is a problem with the protocol. Nothing seems to work!

Any ideas?

Something odd is happening with your WiFi; it’s taking over 9 seconds to connect, and looks like the NTP lookup is taking another ten seconds before timing out too.

How close to the wifi router are you (and what router is it)? The PicoW doesn’t do 5ghz, so it’ll only be trying to connect on the 2.4

I have an Asus RT-AX86U router, and I am about 2 feet away from it.
I originally had the dual band set, so connections would use both 2.4 and 5ghz. But I disabled that, and connected the pico to the 2.4ghz connection.
In my latest logs, I can see that it does connect to wifi :

active: 1, status: 3 (Connect to wifi with an IP address)
Connected successfully!
Elapsed: 9326ms

That does seem to be a long time!

Yeah, there’s something screwy there - does your router have any logfiles? I’m guessing it’s something weird with DHCP (although traditionally, it’s always DNS) - I’m sure you’ve tried already, but power cycling the router is always worth a go in case it’s scrambled it’s internal lists somehow.

WiFi is awesome except when it doesn’t want to play.

Yep, I have tried power cycling. Here are my basic settings on the router :

I am not really a network guy, so I have no idea what I should be looking to change. :(

So I have created a new guest network that has the following settings :

And I have written a script to connect to wifi and grab the time :

import network
import socket
import time
from time import sleep
import machine
import urequests
import usocket
import struct

ssid = 'lanofthefree'
password = 'XXXXX'

def connect():
    #Connect to WLAN
    wlan = network.WLAN(network.STA_IF)
    #wlan.connect(ssid, password)
    if not wlan.isconnected():
        print('connecting to network...')
        wlan.connect(ssid, password)
        while not wlan.isconnected():
            print('Waiting for connection...')
    print('network config:', wlan.ifconfig())
    mac = wlan.config('mac')
    print('MAC {:02x}:{:02x}:{:02x}:{:02x}:{:02x}'.format(mac[0],mac[1],mac[2],mac[3],mac[4]))
    ip = wlan.ifconfig()[0]
    print(f'Connected on {ip}')
    UTC_OFFSET = -4 * 60 * 60
    print("Time from PI :", time.localtime())
    print("Time from PI, adjusted :", time.localtime(time.time() + UTC_OFFSET))
    #ntp_host = "pool.ntp.org"
    #ntp_result = urequests.get("pool.ntp.org")
    #print("NTP result :", ntp_result)
    ntp_host = "pool.ntp.org"
    timestamp = None
        print("Getting time from NTP")
        query = bytearray(48)
        query[0] = 0x1b
        address = usocket.getaddrinfo(ntp_host, 123)[0][-1]
        print("NTP address :", address)
        socket = usocket.socket(usocket.AF_INET, usocket.SOCK_DGRAM)
        socket.sendto(query, address)
        data = socket.recv(48)
        local_epoch = 2208988800 # selected by Chris - blame him. :-D
        timestamp = struct.unpack("!I", data[40:44])[0] - local_epoch
        timestamp = time.gmtime(timestamp)
    except Exception as e:
        print("Exception :", e)
        return None

    print("Timestamp: ", timestamp)
    return ip 

    ip = connect()
except KeyboardInterrupt:

The Enviro Indoor and Grow will still not connect to wifi.
Earlier it was working when I ran this script through Thonny, but its stopped working now. Seems very intermittent.

Figured out why it wasnt connecting to Wifi. The SSID is case sensitive! (Who knew)
It still will not get the time from NTP though. So I am going to try rewriting the call to use a http request instead, see if that works. I’ll report back when I have working code.

Is it still taking ~10 seconds to connect to that guest wifi?