The Nextion display is a touch-sensitive intelligent display. Essentially, you buy the display and you program it with a free editor serially – which lets you easily place icons, buttons, images, text, gauges and more on the screen. For any of these you can have the unit send serial messages on press, release etc. You have serial control over the display itself and you can have as many “pages” of information as you want.
So for example if I place a text box called “mytext” on page “home” then I can send the serial command home.mytext.txt=”Hello”
Easy. So it can then talk to just about any micro – Raspberry Pi, ESP8266, Arduino etc via a simple 2-way serial link. What’s not so easy is the fact that it is taking them a long time to get the editor and interpreter right and some stuff just doesn’t work – even basic comparisons in it’s internal interpreter. Having discovered that when I first looked at the product, I put the Nextion to one side for a while. You can’t do multiple copy and paste, if you delete a library image you have to change the ID of all other images you’ve used – the list goes on – my suspicion is that one overworked, underpaid guy is doing all the development and it’s the first time he’s done this. I could be wrong.
NOT withstanding the above – the display has tremendous potential and you can work your way around most of the issues.
This week I began to think of the display from another angle. What DOES work is image, button and text placement, serial updating and serial out. So basically if you think of the Nextion as a programmable dumb terminal, then THAT works and works well once you get used to and work around the issues (images stored on the device are stored by number. Get rid of one and all your references are wrong. Just little things like that.
I began to ponder how it would be if I used Node-Red on the Raspberry Pi (or on anything that handles Node-Red and serial, really) to do the work – after all, there are no real limits to program complexity on the latter and it works – so use the Nextion for what it is good for!
With that in mind I set about installing the serial node on Node-Red – that went very smoothly (using Raspi-Config initially to turn the serial on). The first hurdle however didn’t take too long – the Pi crashed whenever I tried to use serial in. It turns out that RPi already has it’s own use for the serial – as a terminal. So this has to be disconnected first.
At a terminal I issued the above commands – in other words commenting out the start-up condition that has the Pi using the serial in interrupt– and also killing it now to save having to reboot.
That done, I tried again – there is still some information in the serial buffer at power up which I’ve yet to figure out how to stop – but matters not, it’s easy to clear out the serial buffer during init in Node-Red.
I had to get onto the guys working on Node-Red for help here – and to cut a long story short, a simple function added to the Serial nodes sorts that problem out. Great support is available for Node-Red on Google forums.
So in my case I wanted a simple thermostat display with up and down controls. I have a property which we holiday-rent out in the summer and that is about as much as I’d like end-users to control. On the other hand, when we’re at home I want to do so much more. So I decided that what was needed was a basic stat display page, a login page, a menu page then as many...Read more »