Text Box:  Back
 

 


8-Segment display with Rpi Pico WH (Inside/Outside temp display, date+time) – 03/07/2025

 

I purchased 2 Raspberry Pi Pico WH (Wireless + Headers) and two 4-digit 8-segment displays from core-electronics. Links: Item 1, Item 2

Note: Rpi is an abbreviation for Raspberry Pi

 

4-digit 8-segment display:

4-digit 8-segment Display Module for Raspberry Pi Pico 4-digit 8-segment Display Module for Raspberry Pi Pico4-digit 8-segment Display Module for Raspberry Pi Pico4-digit 8-segment Display Module for Raspberry Pi Pico

Rpi Pico WH:

Raspberry Pi Pico WH (Wireless WiFi, with Headers)

Here are the 2 codes that I made for this:

---

1. Temperature inside vs temperature outside

 

It gets the indoor temperature from the Rpi’s inbuilt temperature sensor, and the outdoor temperature from the BOM (Bureau of Meteorology – http://bom.gov.au).

 

The Rpi connects to a .php file on my web server, which gets the live temperature from the BOM and returns only the first 2 digits of degrees to be displayed.

Note that it is configured for Sydney, so you might need to modify line 6 of the php code to match your location.

In the micropython code, you will need to modify line 41, 42 and 45. This is to configure your Wi-Fi credentials as well as the url for your .php file.

 

Download micropython code (copy the contents of the .txt file into thonny)

Download php code (the php code is stored as .txt)

 

 

2. Time and date clock

Img 1=Time      Img 2=Date

 

This code is much simpler, not requiring a php-compatable web-server.

It simply connects to a time server (pool.ntp.org) and keeps track & displays the time and date.

It uses the Rpi’s RTC (inbuilt Real-Time-Clock), however as this can fall out of sync, it connects back to the time server to get the updated time & date every 24 hours.

 

The code is in Sydney time by default, but you can modify this by changing line 65:

 

    hour = (hour + 10) % 24

 

change the + 10 to whatever timezone you are in.

 

In the micropython code, you will need to modify lines 18 & 19. This is to configure your Wi-Fi credentials.

 

It switches between the time and date every 5 seconds. The date is in DD.MM format. The time is in 24-hour format (HH.MM).

 

Download micropython code

 

Setup instructions:

1.    Connect micro-usb to usb-a cable from Rpi to PC, while holding BOOTSEL button on the Rpi

2.    Open the Rpi “drive” which should appear in file explorer

3.    Copy this .uf2 file onto the Rpi (Or download the latest version of the .uf2 file from https://micropython.org/download/RPI_PICO_W/)

4.    Wait until it copies, and the Rpi should disconnect from file explorer.

5.    Disconnect the usb cable going to the Rpi

6.    Connect the Rpi to the LED-display board, ensuring that the Rpi’s usb port matches with the usb label on the LED-display.

7.    Connect the Rpi back to your PC

8.    Open Thonny or install it if you don’t have it already (https://thonny.org/)

9.    Click the bottom-right of Thonny and select the Rpi Pico 

10.  Paste the contents of the .txt file from the previous section of this webpage into Thonny

11.   Save the code (CTRL+S or “File -> Save”) as main.py on the Raspberry Pi Pico

12.  The code should now automatically run when the Rpi is plugged into any power source!

 

 

Thank you for reading till the end! I hope you enjoyed it :)