Raspi-Nextion Weather Clock

Introduction: Raspi-Nextion Weather Clock

Seeing so many different clocks built with arduino and raspberry Pi's inspired me. I wanted to make one too.

I started by using an arduino mega with a ESP8266 but found the 8266 wifi to have too many hiccups. I decided to use a spare Pi I had (Raspberry Pi3 Model B) even though I had never used Python. I found some tutorials for using the arduino code on the Pi, but this all seemed to be bandaids.

The Raspi-Nextion Weather Clock uses the Pi running Raspian connected to a Nextion 5" enhanced screen.thru the serial port with the program written in Python.

I also 3D printed (with the help of some friends) the case.

As soon as the program boots - it gets the date & time from Google

It will also get the weather using thingspeak.com

You will need to signup at https://thingspeak.com/apps and use a ThingHTTP

The screen will change as the weather changes - ie: if its sunny out the screen will have a sunny background, if its snowing, the screen will have a snow filled background

The screen will dim at night so you can sleep - this is adjustable in the program as to what time it dims and undims

When its a holiday, you will see a holiday background and the screen will undim later so you can sleep in...

All backgrounds are editable using the nextion software

make custom screen for birthdays, anniversaries, important dates...

Step 1: Parts List

Here is the list of parts and software I used:


1. Raspberry Pi 3 Model B ($50 on Amazon) https://www.amazon.com/CanaKit-Raspberry-Clear-Pow...

1a. You will need a microSD - I had a spare with a usb to microSD adapter

2. Nextion 5" Enhanced Screen ($72 from ITead) https://www.itead.cc/nextion-nx8048k050.html

3. 2 small speakers - optional - I wanted to add 2 bluetooth speakers

4. Bluetooth audio amp - optional - https://www.amazon.com/INSMA-Amplifier-TDA7492P-Re...

5. power supply - optional - if you add the speakers its nice to add a power supply that will supply the Raspberry and the audio amp - https://www.coolerguys.com/products/100-240v-ac-to...

6. I also added the 3D printer files for anyone interested


1 Raspian - https://www.raspberrypi.org/downloads/raspbian/

2. Win32 Disk Imager - used to write raspian to microSD for Raspberry Pi - https://sourceforge.net/projects/win32diskimager/

3. Nextion Editor - for creating custom screen layouts - https://nextion.itead.cc/resources/download/nextio...


1. computer screen to connect to the PI - temporarily

2 usb keyboard and mouse to connect to the pi - temporarily

Step 2: Install Raspbian & Load the Nextion Screen

Once you have downloaded the raspian image, unzip the iso to your pc.

Place the microSD card into a USB adapter and plug in your pc

Perform a quick format on the sd card (fs=fat32)

Load the screen:

1. plug the SD card into your pc and place the attached hmi file on the card

2. install the microSD into the Nextion screen and power up

3. wait for the image to load. When done remove power from the screen and remove the card

4. Perform a quick format on the sd card (fs=fat32)

Load Rapian to microSD:

Start Win32 disk imager and write the image to the microSD

1. choose the letter of your microSD

2. select the raspian image iso file you unzipped

3. Click write

4. Once done you can close Win32 disk imager and unplug the microSD from your pc.

5. Plug the microSD into the raspberry Pi

Step 3: Boot the Raspberry Pi & Connect the Nextion

There are a few configuration changes that need to be made on the Raspberry Pi.

For instance, to use the serial output on the Pi3 Model B, you must disable the bluetooth.

Assemble the PI and plug in your keyboard, mouse, SD card and pc screen using the hdmi output of the PI

1. Once you plug the power into the Pi, it will start to boot. Once booted, you will find you have a nice desktop with everything you need already installed.

1A. Click the wifi icon in the top right corner of the screen and attach the Pi to your wifi and save the settings

2.The serial on GPIO 14 & 15 is disabled because it is used by the bluetooth. To enable the serial interface, you must add the lines below to /boot/config.txt you must do this thru the terminal using sudo nano /boot/config.txt

  • click the terminal icon (black screen icon) on the top of the screen
  • type sudo nano /boot/config.txt
  • using you arrows, scroll to the bottom of the screen and add the lines below to the bottom of the files

#disable bluetooth so nextion can work on serial 0

dtoverlay=pi3-disable-bt enable_uart=1


  • Once these lines are added, next we save and exit
  • press control x to exit
  • press Y to save
  • press [enter] to save file

shutdown & remove pwr from the pi


open the terminal and type pinout

we will be using GPIO 14 & 15 for serial comms to the nextion

You will see which pins on the Raspberrys GPIO are GPIO 14 & 15 on the screen

3. Shutdown the Pi and connect the screen as shown in the attached pic

4. Reboot the Pi

5. Open the terminal and type sudo raspi-config

6. go to Interfacing options, then serial and enable the serial port and disable the shell

7. Tab to finish

8. Reboot one more time

Step 4: Writing Your Python Program

Choose your favorite python IDE and get to coding...

I chose Geany as it was already installed on the Raspian image. Its also very easy to use and testing the program couldnt be easier. All you have to do is click the paper plane icon at the top of the Geany screen and it starts the program

I have attached my program as an example. This will help show you how to access the serial port and the different functions of the Nextion screen. Feel free to edit as you see fit

Step 5: Start Program When Raspberry Boots...

By this time, you should be able to run the program on your screen

If you want to be able to run your raspberry pi clock program without the keyboard, mouse and pc screen follow the steps below.

1.add this line to top of your program --> #!/usr/bin/python

2. make your program executable by using the chmod command in the terminal.

  • click the folder icon at the top of the Raspian screen and navigate to the folder where your program is. Mine is on the desktop in a folder named py
  • Right click on the folder (i will right click on the py folder and choose open terminal)
  • Type the command sudo chmod +x followed by the path to the program and click [enter]
  • sudo chmod +x /home/pi/Desktop/py/NameOfProgram.py
  • close the terminal when done

3. Now navigate to the /etc folder

4. Right click on the etc folder and choose open ternal

5. In terminal type--> sudo nano rc.local

6. Using your arrows, scroll to the bottom of the page, to the line above exit 0

7. Add a path to your executable program --> /home/pi/Desktop/py/NameOfProgram.py

8. Click control + x to exit, Y to save and click [enter]

8a. [EDIT] - You must also make the rc.local file executable by now typing sudo chmod a+X rc.local

9. Reboot the pi by typing reboot in the terminal and when it reboots the program should auto-start :)

Step 6: Optional Bluetooth Speakers

The bluetooth audio amp was needed as we disabled bluetooth to use the serial port

If using the suggested power supply, you will need to break out the wires and use the 5V for the Raspberry and the 12V for the bluetooth audio amp.

Connect the power and speakers according to the attached pic.

The speakers I used were taken from an old failed bluetooth bathroom fan/speaker setup

Step 7: Using ThingSpeak

You will need to signup at https://thingspeak.com/apps and use a ThingHTTP

I started one for the temp and another for the weather condition ie: sunny. foggy, snow...

When setting up the ThingHttp, you will need a URL to send a get request to

I use - https://www.wunderground.com/weather/us/in/Indianapolis

The method is Get

HTTP ver - 1.0

The parse string is a little tricky

1. Go to the weather underground site for your city

2. In google chrome, press F12 (go to step 3 or 3a)

3. On the right side of the screen, look for and click the icon for "select an element in the page to inspect"

3a. Or highlight and right click on the text you want to get and select "Inspect" (skip to step 5)

4. Now highlight the temp

5. On the right you will see a line get highlighted - Right click on this line, go to copy and select Copy XPath

6. Save this as your parse string in your thingHTTP setup

7. Save the thingHTTP and you will be given a link to use for the program with your API Key

8. Setup your link just as I have in the program.

9. You can test requests easily with a program called Insomnia, but thats a whole other tutorial..

First Time Author

Participated in the
First Time Author

3 People Made This Project!


  • Rice & Grains Challenge

    Rice & Grains Challenge
  • Puzzles Challenge

    Puzzles Challenge
  • CNC and 3D Printing Contest

    CNC and 3D Printing Contest



Question 3 months ago

In your instructions you state to upload the HMI file to the display vis SD Card.
I think you want to upload the the TFT file to the display, which is compiled version of the HMI file. May misleading for some that don't know how Nextion works or am I missing something?
  • .HMI file (this file can be imported into the Nextion Editor to edit the GUI);
  • background image used in the user interface should also be in the project folder;
  • .TFT file (this file should be uploaded to the Nextion display, this is the file that the display runs);

Answer 2 months ago

You are correct.
Thanks for pointing out this mistake, it can be confusing.


5 months ago

buena publicación, me gustaría ver la programación en python que realizó para entender ya que soy nuevo en la parte de raspberry con nextion


Reply 2 months ago

Did you use the download button in step 1?

¿Utilizó el botón de descarga en el paso 1?


Reply 5 months ago

el programa python se adjunta a la publicación. creo que tienes que visitar el sitio para descargar el archivo adjunto


Reply 5 months ago

solo me permite descargar un archivo pdf con la informacion que ya se esta publicando mas no el programa en si del python, crees poder facilitarme por aqui o por otro medio de antemano muchas gracias


Question 1 year ago

Hello! been doing good work with the project lately, when suddenly, this Monday, my Raspberry Pi stopped recognizing Nextion Screen. I tried different ways, including, but not limited to: Buying new screen and Raspberry PI, updating Raspbian, redoing the whole project from zero. Nothing worked, even though no changes were done since it worked last time. Any help would really be nice!


Reply 1 year ago

Please let me know what model screen and raspberry Pi you have. If you want to send me your program, that will help. I can even upload to a RPi and try it here.


Reply 1 year ago

Ok, I did not see anything that stands out.
If you change your RPI code so that your python code never starts, does the display work?
You can even just rename your python program and restart the Pi to see if the display comes on.
Have you tried connecting an external display to the PI?


Question 2 years ago on Introduction

Can you please instruct me why my Pi does not accept Unicode in the serial instructions?
You suggest port.write "page0" . My serial port definition is ttys0 and using pi 3

Best regards,


Answer 1 year ago

Hi, did you manage to fix it? I looked all over and managed to find nothing to fix it on my side
+ for whatever reason RPi won't see connection in serial


Reply 1 year ago

Can you send me your program? - Id be happy to take a look..


Reply 1 year ago

I am also not sure, but it may have changed on weather website, since it sends not only a number now, but other info too


Reply 1 year ago

Try using something like "temp = temp[:-3]" when getting the temp
This will get all characters and cut off the last three. Try cutting the string to keep only the characters you want


Reply 1 year ago

Thanks for a tip! Most of the stuff works now, only temp, cond and WDesc returns b'MyData'
is there any way to get rid of b' '?


Reply 1 year ago

sure, try using this format
after temp (or cond or WDesc) is loaded with the data do this
temp = temp[1:]
cond = cond[1:]
WDesc = WDesc[1:]
this will remove only the first character


Reply 1 year ago

thanks for the tip
for me temp = temp.decode ('utf-8')
and cond = cond.decode ('utf-8')
after formatting them fixed the issue