Full details, source code and write-up at www.plastibots.com.
This is a continuation from my prior WIoT weather station. I decided to upgrade to a Nextion TFT LCD due to issues I was having with SPI comms between the Adafruit Huzzah ESP8266 and the RA8875 Controller. After some research I discovered that this is a common issue with the ESP8266 and SPI communications.
I came across the Nextion display over a year or so ago during their Indiegogo campaign. I decided to pass 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 uses simple serial commands to communicate between the MCU and the display – which is perfect for my needs. They also use a HMI editor (below) that allows you to layout all the elements on the TFT, and setup the display using pages etc. Refresh rates are fast as well. An example of the simplicity. To change the icon of one of the days, you issue “pDay1Icon=6” from the MCU.
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. With that, onto details about my WIoT-2 project. As with my prior project the intent was the following:
- Display current and forecast weather information. This time around, I used th Weather Underground API to pull both current and forecast data in JSON format. (OpenWeatherMap.org, and DarkSky.net as well)
- Display weather data that I generate outside my house via another ESP unit. It polls temp, humidity and battery info (it’s solar powered) – Integrated with Blynk
- Poll and display the temperature of our hot tub – Integrated with Blynk
- Poll and display the status of our garage doors (open/closed) – will be integrated in the future – Also integrated with Blynk
- Allow our kids to interact with the unit – sends us notifications – Integrated with 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
- I also added a picture viewer which shows family photos (for those times when people are bored standing at the door waiting for others…)
- 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. I’ll also post code below.
- Blynk Library – I use the app to control and monitor the hot tub, garage and others components.
- 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 – 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. 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.
Comments