Wireless With Display
Welcome to Wireless Display Status!
In this lab you will connect a display to your Pico W and show network information on the screen. You will see your IP address and Media Access Control (MAC) address without needing a computer!
In this lab you will add a 128x64 Organic Light-Emitting Diode (OLED) display to your Pico W. The display will show:
- The WiFi network name you are connected to
- How long it took to connect (in milliseconds)
- Your Pico W's MAC address
- Your Pico W's IP address
- A counter showing how many seconds the device has been running
The display we use is a 2.42" Diymore OLED display. You can learn how to set it up in the Display Graphics section.
The Full Program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
What each line does:
ssd1306.SSD1306_SPI(...)— creates the OLED display object using SPI communicationoled.poweron()— turns on the OLED backlight and displaywlan.config('mac')— reads the MAC address as 6 raw byteshex(mac_bytes[digit])[2:4]— converts one byte to a hexadecimal string and removes the0xprefixoled.fill(0)— clears the screen to black (0 = off)oled.text(text, x, y, color)— draws text at position (x, y); color 1 = whiteoled.show()— sends all the pixel data from memory to the physical displayticks_diff(ticks_ms(), start)— calculates elapsed milliseconds sincestartled.toggle()— switches the LED from on to off, or off to onwlan.ifconfig()[0]— returns the Internet Protocol (IP) address assigned to your Pico W
Monty's Tip
The uptime counter helps you know how long your Pico W has been running without a restart. If the counter resets unexpectedly, it means the device crashed or was unplugged.
Key Idea
The display_startup function runs while you are waiting for WiFi. The display_status function runs after you connect. Showing progress on the screen is much more helpful than just watching a blinking LED!
Congratulations!
You have built a self-contained wireless display! Your Pico W now shows its own network status without needing a computer. You have completed the wireless and IoT section — amazing work!
