Lab 06: Check Your WiFi
The clock sets itself from the internet, so it needs two settings files filled in correctly. This lab checks both, then joins your WiFi network. Everything is printed in Thonny's shell, so it works even before the display is wired.
Welcome to Lab 06
A clock that sets itself is never wrong, but first it has to get
online. This lab finds any typo in your settings before it can
confuse the clock. Let's make time tick!
What You Will Learn
- what goes in
secrets.pyandconfig.py - how a Pico W joins a WiFi network
- what signal strength numbers mean
Before You Run It
- Copy
secrets-template.pyto a new file calledsecrets.py. - Type your WiFi network's name in
wifi_ssidand its password inwifi_pass. - Check
CITY,TIMEZONE_HOURS, andUSE_US_DSTinconfig.py.
Keep secrets secret
secrets.py holds your WiFi password, so never post it or share it.
The kit is set up so it is never uploaded to the internet with the
rest of the code. Keep the password only in that one file.
Run It
Open 06-test-wifi.py and click Run. A good run looks like this (the
network name, address, and numbers here are made-up examples):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Anything that is wrong is printed as a PROBLEM line that says what to fix.
Signal Strength
-59 dBm measures how strong your network's signal is. The numbers are
negative, and closer to zero is stronger: −50 is strong, −80 is weak.
If the signal is weak, move the clock closer to the router.
If It Doesn't Work
- "network not found". The Pico W only uses 2.4 GHz WiFi. If your router has a separate 5 GHz network name, use the 2.4 GHz one.
- "wrong password". Passwords are case-sensitive. Check capital
letters and spaces in
secrets.py. - "there is no secrets.py on the Pico". Make the file and upload it.
You're Online!
Your settings are checked and your Pico W joined the network. Now it
can ask the internet for the time.
Next: Lab 07: Get the Time