This is a continuation from my prior WIoT weather station.  I struggled with the name as it does much more than just weather…  I suppose I should have called it IoT “thing”….  Anyway, what is WIoT-2?  Well, it’s lots of things…  I use it as a cloud-connected (IoT) info center of sorts mounted near our front door.  It is a culmination of information my wife or I often look for either on our way out of the house, or when we come home.  It displays current/forecast weather from WeatherUnderground, weather outside the house (from this), date, time, our local waste collection schedule, currency rates, the status of our garage doors (from this), our hot tub temperature (from this) , and even allows our kids to check-in when the get home.    Read on to find out more about how I built it.  Sources are available further down if you want to build it yourself.

Interface Update:  February 2018


Earlier Version of WIoT-2

Pop-Up Window

Earlier Version


Nextion TFT Display: 

I came across the Nextion display over a year or so ago during their Indiegogo campaign.  I passed it by as there was not enough information at the time.   In hindsight I regret that decision.  Itead hit the nail on the head with this display as far as I am concerned.  It connects to your MCU (Arduino / ESP8266 etc) using a standard 4-wire serial connection.  It uses simple serial commands to communicate between the MCU and the display – which is perfect for my needs (and I think most makers like myself).   It uses their custom HMI editor (below) which allows you to layout all graphic elements/buttons on the TFT.  You can also setup multiple page views to make a very robust visual interface.  Refresh and image load rates are fast as well.  The concept of using their HMI and how you put graphics and text elements is a lot like object oriented programming, so it was easy to pick up.  For those of you using RA8875/1305s and others, you don’t know what you are missing.  After spending countless hours coding a prior project using the RA8875 controller, the Nextion is a walk in the park and makes graphical layout and interaction much easier than any other I have dealt with.  Anyway, enough on this. I’ve done a more fulsome write-up as to why I like this display so much.  There are many other advanced features of the Nextion that I won’t get into here as this is not the purpose of this post.

editor capture


What does WIoT-2 do you ask?

  • Display current and forecast weather information.  This time around, I used the Weather Underground API ( coming soon) to pull both current and forecast data in JSON format.
  • Display weather data generated outside the house via another ESP unit.  It polls temp, humidity and battery info (it’s solar powered) – Integrated with Blynk
  • Has option to change weather to other locations.
  • Displays temperature and humidity from inside the house. Watch out Nest!!!  I’m also working on getting my Ecobee to provide stats and pull them through some means.
  • Poll and display the temperature of the hot tub – Integrated with Blynk
  • Poll and display the status of garage doors (open/closed) – Also integrated with Blynk
  • Allow our kids to interact with the unit – sends notifications via Blynk
  • Polls waste collection calendar information to show us which waste items are being collected on a weekly basis.
  • Show the current date and time – uses Blynk RTC widget
  • Shows up-to-date currency conversions CAD>USD, CAD>GBP.
  • Master control center for net-connected power outlets in my house (coming soon with SONOFF integration)


Main display at front door

MCU unit on backside of wall. Contains NodeMCU, power supply and connectors.

NodeMCU controller unit on backside of wall

Garage door status icons

Garage door status added.  Allows monitoring and control of doors.

Option to selection weather reporting location

Option to change weather reporting location


Pin-Outs & Connections:

One of the best things about this project is how easy it is to put together.  The connection to the screen uses standard serial (PWR,GND, RX, TX).  Then connections to my sensors (PIR 3 wires), Temp/Humidity Sensor (3 wires).  Easy peasy!

I’m using the NodeMCU, so your connections may be different.   This project takes advantage of both Serial ports. Serial is used for comms between the PC and NodeMCU, Serial1 is used for comms between the MCU and Nextion.  Well, not exactly.   The Node’s Serial RX line is shared on both sides.  More on that in a bit.    The connections are Node RX to Nextion TX, and Node D4 to Nextion RX.  The sketch uses hardware serial using Serial1 (TXD1) to transmit to the Nextion, while return data comes over Serial RX.  It sounds more complicated than it is…  In the sketch, both Serial and Serial1 have been created.  The only trick is that you cant have the Nextion powered when uploading sketches to the Node.  I solved this by inserting a latching switch on the Nextion 5V power supply.

Important:  Don’t fall into this trap!  If you are powering your MCU and Nextion by different pwr sources their GND connections must be common (connected)!   Also ensure your power supply has sufficient current to power the Nextion, your MCU and sensors.  My go-to is a 5V 3A power supply which always does the trick for me.  Also, don’t underestimate the MCU demands on current when it’s using WiFi.  The Node jumps to ~500mA when getting data.  Here are the connections between the MCU and Nextion:   NodeMCU RX >> Nextion TX.  NodMCU D4 (TX1) goes to Nextion RX.

Blynk Integration:

The project also uses Blynk extensively to allow me to view the status and control the various devices I have throughout my house from my phone and tablets.  I also use it to debug the devices to ensure they are still sending data at their defined intervals.  You don’t have to use Blynk.  In my case it simply extends functionality of WIoT and also serves as an alternate controller.  For example, I use Blynk to open/close my garage doors when I have my phone.  I can also do it using WIoT2.

Outside data is also logged to Blynk. Temp, Humidity and Battery are tracked.  Data also reported to WIoT. The Hot Tub controller monitors the temperature and allows the RGBW NeoPixels to be set.  Data also reported to WIoT. The Garage Door Monitor allows for monitoring and controller both garage doors.  Data also reported to WIoT.

Outside Data Logging Unit

Outside Data Logging Unit

Hot Tub Temp and LED Controller

Hot Tub Temp and LED Controller

Garage Door Controller / Monitor

Garage Door Controller / Monitor


Libraries & Resources:

  • Nextion Library – Note there is an official Nextion library as well, but this one was sufficient for my needs given it allowed for me to send and receive information from the Nextion.  Be sure to read the notes and links (link, link) provided as they give great samples.  Note: You can use software or hardware serial.  I used hardware serial in my code.  If doing this you have to comment out a line in Nextion.h   //#define USE_SOFTWARE_SERIAL //Comment this line for use HardwareSerial
  • Blynk Library –  I use the app to control and monitor the hot tub, garage and others components.
  • Time – you will also need Paul Stoffregen’s time library for Blynk:
  • Arduino IDE – I used 1.6.13, but others should work fine as well.
  • Node MCU firmware – comes as part of the ESP package.  Google is your friend if you need help. Just google setting up NodeMCU in Arduino.
  • Arduino JSON for parsing the JSON data.
  • Nextion forums –  (a big shoutout to Patrick and Steve for being so helpful in getting me up and running).
  • Arduino Source Code & Nextion HMI file – see bottom of page.


I had my first challenge with the NodeMCU when trying to both display debug messages using the standard Arduino Serial window and trying to communicate with the Nextion.  After some digging and help from Steve and Patrick on the Nextion forums, I was able to get both Serial debugging and comms with the Nextion.  It uses a simple trick in that the Nextion uses the NodeMCU’s D4 pin (Serial 1 TX) to send comms and Serial RX to receive.  For those with a keen eye, you can see that this is a problem when uploading sketches – which is easily solved by either disconnecting the pin, or powering down the Nextion display during sketch uploads.

Tips n Tricks:

Changing IDs in the HMI Editor:  If you haven’t come across this, you will!  For the Nextion HMI Editor, once you dump pictures in there, picture order counts as they are all identified by their ID and that ID shifts if you try to shuffle pictures around.  Hopefully you don’t have to, but it may be necessary.  Using the code sample below to demonstrate, I discovered that the below approach messed up each time I add or shuffle picture objects in the editor.  Instead of using the ID of an object, I have the HMI send a print call when any button click sends content back to the MCU.  This way, I can check for more realistic values in the call-backs.  i.e. I can send “print b1” when button 1 is pressed.  You can use whatever text you want, and you can have separate calls when buttons are pressed or released.

Part of the app watches for incoming messages from the Nextion that look like this “65 0 2e 1 ff ff ff”“. Where 2e represents the component ID being clicked/or sending a message from the display.  You can see the message output in the HMI.  One of the issues is if you are making changes and removing images/components, the HMI re-numbers the ID’s.  This is a problem if you write code to interpret them.  Solution – wait until you are done your project design and have the HMI correct before writing statements to interpret messaging.   If you have to edit it later, that is fine. Just make sure you check all output values and ensure they updated in the matching receive statements in the sketch. Code sample:

 String message = listen2Nextion(); //check for message
  if (message != "") { // if a message is received...
    //Serial.println(message); //...print it out
    //if (debug) {Serial.print(F("*****Nextion Msg: "));}
    //if (debug) {Serial.println(message);}
    Serial.print(F("*****Nextion Msg: ")); Serial.println(message);

    //Refresh the data.
    if (message == "b1") 
    if (message == "dYes")  //photo icon clicked - run photo show
      myNextion.sendCommand("dim=60");  //brighten the screen
      myNextion.sendCommand("page photo");

Adding New Images / Image Layer Ordering:    As I have modified this project regularly since inception, I have also added new images.  The issue is the Editor does not have a robust system for moving images up/down layers to put them in front or behind others.   There’s a trick to this however.   First off, you can replace existing pictures with new ones.  So, if you are doing a refresh of an existing image, use the replace feature as it maintains the image ID and does not mess up the others.  This is important if your code refers to pictures by their ID # like this code does (for the weather icons).  Now, if you go to add a new picture, it will appear on top of all the others.   There are up and down arrows at the top left of the Editor that allow you to move objects to the top or bottom of the object display order.  No – you can’t do it layer-by-layer, but hopefully they will fix that at some point.  Instead, you can use an approach to move the new picture to the bottom, and move others over top of it (if that is what you are looking for).  WIoT2 is complicated as I use a background picture that covers the entire screen, so I have to move the new image I added to the bottom, then select the background image and do the same, then any images I want on top of the new picture I simply selected them all and clicked the up arrow.  This would be much better if  I did a video, wouldn’t it? 🙂


Nextion Baud Rate:   You can view the default baud by referring to the ‘baud’ command in the Nextion Instruction Set.  Good news is you can also change it by issuing the bauds command with the baud rate you want to use.  Don’t forget to update the baud rate in your sketch for Serial1 (i.e. Serial1.begin(9600);).    Default from factory is 9600.  I changed mine to 115200.

Using Nextion Editor and an ESP in Debug Mode:  I discovered this late in the game, but the Nextion Editor has a feature in Debug view that allows you to simulate in a live environment connected directly to your MCU.  Doing this is pretty straight forward.  In my situation, I have WIoT2 mounted to a wall, so updating it is a pain.  To solve this, I have a 2nd NodeMCU unit. I modify the Arduino code and upload to the MCU.  The Serial pointer has to change to use the USB serial connection (in the sample code below). After updating the NodeMCU, connect it to USB and your computer.  In the Nextion Editor, open your HMI file in Debug view, select the COM port your MCU is connected to and the correct baud rate and you are in business.  Your MCU will feed the HMI real data as if it were directly connected to your display.  You can watch the virtual display update.  When everything looks good, you can build the HMI file and upload it to the physical screen.   The only drawback is if you use sensors and do not have back-ups to add to your spare MCU.  For me it did not cause issues, but something to think about.



Inside view of MCU case and unit


Nextion HMI Template View – Early Version


Want to Build it Yourself?   Source Code Arduino Sketch / Nextion HMI:

I’ve decided to take a different approach on sharing for this project.  I have spent well over 100 hours and nearly a year developing this project.  A lot of hard work has gone into the Arduino source (65+ versions) as well as the Nextion HMI.  For a small PayPal donation of $5 or more (c’mon, it’s a Starbucks coffee… :-), I will share the Arduino sketch and the related Nextion Editor HMI file.

Update July 2018: Weather Underground, which WIoT originally used for weather data, no longer offers free weather data API access (existing members are ok).  As such, I am currently porting WIoT over to – who do offer a free data plan.  I’ll be offering an updated version in the coming weeks which will also include the new HMI.  If you have any questions, drop me a line.

What you can expect:

  •  Arduino sketch (libraries are your responsibility – links above).
    • This code contains various functions and tricks working with strings and char arrays.  It’s a result of many hours researching how to do specific tasks.
    • Connecting to Weather Underground and parsing JSON data
    • Blynk connectivity including interfacing with 2 other IoT devices.
    • Communicating with the Nextion display.
    • I now use this code as reference for my projects due to the variety of working with string/char array data and manipulation of them.
  • Nextion HMI file (developed in Nextion Editor v0.53)
    • You get the HMI file that interfaces with the sketch.  This version is for the 5″ regular Nextion TFT LCD. However, it should work with other Nextion units (i.e. Enhanced).   I’ve provided links above to where you can buy one at a good price and reliable seller. I use them all the time.
    • This does not include source graphics as many are copyright and some are custom.  You will only get the HMI with graphics/fonts embedded.  It’s up to you to create your own graphics if you want to change what is in there.  Also, if you don’t get the 5″, expect to have to modify the layout to fit other screen sizes.


  • Setting Expectations
    • Due to the popularity of this project and those interested in this source code, I’ve create a How-To below.
    • If you use this in a project, please give credit where due to those who wrote the libraries as well as  You must retain the information at the top of the sketch, and you may not sell this code to others or use it for commercial purposes or for profit.  It is up to you to investigate usage responsibilities for the respective included libraries.
    • You will have to make changes to the Nextion library for your Serial connection. Here: (scroll up).
    • You will also need to ensure the Serial1 value is set to the right baud of your Nextion.  Refer to the ‘baud’ command in the Nextion Instruction Set, find the Nextion’s baud rate, and then set the value in the sketch.  i.e.  Serial1.begin(9600);.  Default is 9600
    • You will get a stable version of the HMI and sketch.  I am constantly updating this project, and this blog, so the pictures above may demonstrate new features that may not be included.
    • Note – the sketch is built for a NodeMCU v1.0 ESP8266.  It should work with other MCUs, but you are on your own if you go that route.  Just keep in mind , it uses the ESPs 2 hardware serial lines.  One for serial debugging and the other (Serial 1) for Nextion comms.
    • Do not expect this code will be plug-and-play. It integrates a number of things such as Blynk-connected projects,  the Nextion and sensors.  Blynk is easy to setup and comes with lots of examples.
    • Sketch and Nextion HMI will be sent within 24 hrs  or less of receiving notification from PayPal.
    • Donation will appear to dast****
    • The intent of this code is NOT to provide you with a plug-and-play solution.  However, it will work if you buy all the same hardware and follow the configuration steps in this blog and below.  The intent here was to share useful functions and ideas that you can use in your own code.  If you choose to try to re-create WIoT-2, that is great, but please don’t expect free support.  I am happy to provide some basic guidance, but this project requires an intermediate skill level.  The intention of this donation is to get access to a wide variety of useful functions.  This donation is for code, not support 😉 There are plenty of resources online – Google is your friend! 🙂  Again, look below for a How-To on getting up and running and remember, where’s the fun in a ready-made solution anyway!? 🙂



WIoT-2 How To

Due to popular demand, I’ve added some notes to help you create WIoT-2.  It is not as complicated as it looks.  It only requires a few pin connections and changes to a few lines of code.  I just like to be verbose in my descriptions! 😉

  1. Parts: At a minimum, you will need a NodeMCU Mini and I suggest a 5″ Nextion TFT (links are above).   You will also need a 5V 1A (min) power supply.  I suggest a PIR sensor would be useful, but you don’t need it to make this work. It is only used for  dimming the screen.  You’ll also need to get a bezel or print one of your own (links above for the STL for the one I printed).  You will also need a MicroSD card.
  2. Nextion: Download the Nextion Editor.  Using the Nextion Editor, open the HMI file provided, compile it.  Then select File>Open Build Folder and copy the .tft file to a MicroSD card.  Then take the MicroSD card, insert it into the Nextion, then power the unit up. Watch the screen as it updates progress.  Allow it to load the file, then power it down and remove the SD card.  Note: you can use the HMI on other sized (base) Nextion displays, but you will have to modify the HMI file / graphics to fit, as it will throw errors.  BTW – if you don’t have your Nextion yet, you can still connect your MCU to the Editor in debug mode to view it working. How cool is that!?
  3. Accounts:  You will need a WeatherUnderground API account as well as download the Blynk software (iOS or Android).  For Blynk, you need to create a new project and get an auth key.  See #5 for where these are entered.  Alternate APIs (may require modification to code)
  4. Blynk (optional):  The Blynk app itself is not included as part of this project as it would not apply since you would also have to create 3 other hardware devices!  However, it’s used for basic features and comms (i.e. RTC).   In the code, I have my Hot Tub monitor, Outside Temperature and Garage Monitor projects all integrated and sending info to this project.  In your case, you can simply ignore it and remove the Blynk related code later once you are comfortable with the project.  At the minimum, you will need the RTC Clock and Notification widgets added in your Blynk project as they are used in WIoT.  You could simply create a blank Blynk app, add a RTC and Notification widget and use it’s auth code.
  5. NodeMCU and Arduino Sketch:
    • Connect the NodeMCU to your Arduino environment and ensure you have a connection.  Note the NodeMCU uses the CH340 USB drivers for Windows.  I suggest running the sample blink sketch to test your connection.  I encourage you NOT to try jumping right into this project. First make sure each component is working separately.
    • Download and install the libraries listed at the top of this post.   You will have to make changes to the Nextion library for your Serial connection.  Read the details above (scroll up).
    • The NodeMCU will communicate to the Nextion using UART1 which is Serial1 in the sketch.
    • Sketch:  Ensure the Serial1 value is set to the right baud of your Nextion.  Refer to the ‘baud’ command in the Nextion Instruction Set, find the Nextion’s baud rate, and then set the value in the sketch.  i.e.  Serial1.begin(9600);  Default from the factory should be 9600.
    • Ensure this line is un-commented:  #define nextion Serial1  //use this when live on MCU + Nextion TFT LCD Hardware.
    • Optional:  Connect the PIR sensor to +5V and GND.  Connect the PIR data line to A0 on the NodeMCU.
    • You can refer to lines 51-57 to set timeouts for the various data parsing activities.  For example, weather is refreshed every 900000 ms (15 minutes).
    • A few lines down, you need to set your WiFI SSID and password.
    • You also need to enter the Blynk Auth code here:  char auth[] = “YourBlynkAuthCode”;   You can email this to yourself from the Blynk app you created.
    • Further down you need to enter your WU API key: const char WU_API_KEY[] = “YourWUAPIKey”;  You need to sign up at Weather Underground to get an API key. It’s free for a # of txns per day (which works for most people).
    • The default weather location is set for Burlington Ontario:  char WU_LOCATION[] = “pws:IONTARIO1260”;   You can find alternate values on the WeatherUnderground site and enter it here.   I believe they are all pws:[NAMEOFSITE] but you should confirm on the WU site.
    • The section covering waste collection is a bit complicated, so I’m not providing guidance on it as it won’t apply to you as it is specific to local Burlington waste collection. You may want remove the related code later once you get things working. I suggest keeping it there for now as it will work as is. Then remove it later when you have a stable setup.
    • Now’s a good time to save save save and version your code!!!  I also suggest you save a new version with each successful iteration you have.
    • This should be enough to get you up and running.  Upload the sketch, then connect your NodeMCU to the Nextion using the pin-outs referenced near the top of this post.
    • Have fun and good luck and welcome to your own WIoT Thing!
    • Note:  This is not a commercial product and neither my code or notes within this blog post carry any warranty.  It is your responsibility to ensure you have purchased safe, certified parts, that you know what you are doing, and that you have ensured the hardware are safe from shock, fire etc.  This is not intended for commercial use.  There is no guarantee on this code, or it’s safety, or the safety of this code and hardware used.   It is also your responsibility to ensure this is safely mounted and uses a certified power supply.  This was also built using low voltage components. As many folks like to integrate IoT into high voltage applications, please make sure you know what you are doing.  High voltage systems can easily kill you.
  6. So you have it working now and you want to tweak things?
    • You can refer to the void processNextionMessages() function.   The purpose of this is to listen to print messages sent back from touches etc on the Nextion and process them.  You can see the names are pretty clear and their functions.    You can also use this to change the other weather locations that can be changed on the fly.
    • Once you have this stabilized, you may want to remove the code related to the hot tub, outside weather and the garage door monitor components.  I suggest doing this methodically and saving new versions as you go.
    • As noted a few times prior. Don’t spend hours writing code hoping you have it right, only to find it fail and you have no idea where the failure is.  Take it in steps. Get a feature working, and save a new version.  Then move on.  Once you have it all working. Save again!  Then, if you are not creating the other projects (i.e. the Hot Tub piece, the Garage piece) you can start to comment out related code, test, then save when it works.  Repeat.  This is a large project, so take it methodically.
  7. Troubleshooting / FAQ:
    • Getting nothing on the Nextion:
      • Did you ensure the right serial speed was set as noted above?
      • If you are powering both devices separately, their grounds must be common.  I suggest 1 5V power source with >1 Amp supply.
      • Your power supply may not be able to supply sufficient current.  At least 1 amp is needed.  Don’t expect your computer’s USB port to power both the MCU and the Nextion as it typically supports 500mA max.
      • If the Nextion screen is blank, try loading one of the default sample .tft files and apply 5V and GND. You should see it show. If not, something is wrong with your Nextion.
    • Nextion is not updating with recent data:
      • Again. Ensure the correct serial setting as noted above.
      • Ensure you have followed all steps above.  Particularly the #define Serial1 note.
      • Try debugging the sketch. Disconnect the Nextion power, change debug = true, in the sketch, download it, and run the open the Serial console. Follow the results to see if the data is being parsed correctly.  I’ve got verbose debugging in there which should allow you to see all the output being generated.
    • I let out the black smoke:
      • Let’s hope you didn’t go there…  You’ve provided too much voltage to the device, or you’ve shorted a pin.  If you choose a device other than the NodeMCU, it may be only able to support 3.7V max. ie. a raw ESP8266.  Not much I can do to help other than comfort you that we have all been there at least once…  I often order > 1 unit to ensure I have backups.