Nextion Update

As you may know the home control software can work with Nextion displays and there is a  project on the blog on that subject – I note that one or two people are having issues here so rather than reply without pictures -  here’s a general  update.

Home Control 2016 startupCurrently with the home control software, version 1.531 (see right) and Nextion Editor version 0.36 (it just updated on my automatically)  and I’m doing this on Windows 10.

After powering up the home control board, you MUST for the first time issue the instruction {set_serial:2} to the ESP8266 at which point the board will reboot and part of the start up serial info will show as on the right – “Initialised software serial to 57600 baud” – this indicates that the unit is ready to work with the Nextion display. GPIO4 and 5 are used for this purpose and the Nextion board can be powered directly from ours. Ground, to_nextion, from_nextion, 5v – that is how our board is marked but of course you don’t need to use our board. Incidentally don’t be tempted to use your 5v FTDI to power any but the smallest of Nextion boards – I tried this on the large 7” model and killed the FTDI…you’ll need a separate (common ground) power supply for that and most likely anything over the 4.2” display. Don’t forget to change that set_serial command if you plan to use GPIO4 and 5 for something else as the setting is stored in FLASH.

In a simple test I have a plain Nextion panel with two buttons on it. In the background to the page – in the Nextion Editor – I have a “preinitialize event” which contains nothing more than “bauds=57600” without the quotes – this ensures the Nextion board powers up at 57600 baud for the purpose of sending data back and forth.

The two example buttons are marked “up” and “down” and the “touch press event” for each is as follows..

get "nodered~up"

and

get "nodered~down"

If you look at my documentation  - this is a notation I created that returns the above – for example the first one, to the ESP8266 and converts that into an MQTT message:

topic: nodered

payload: up

That’s it – press the up button and the message “up” is sent to topic “nodered” – could be any message you like – and any payload. You can use this directly to turn things on and off without even passing through Node-Red – OR you you have node-red intercept the incoming MQTT message and do something with it. So pressing a button might have an effect on the Nextion display for example. If you see the Nextion WIFI touch-display project you’ll see you can get WAY more ambitious than just a couple of buttons.

mqtt-spy

And lo – as I press buttons – you see the messages coming into MQTT-SPY (or whatever you use to test your MQTT).

That just leaves output to the Nextion itself from the board.

Again for the purposes of demonstration I add a text box in the Nextion editor – the default name for the first new text box would be “t0” so I rename this to “mytext”.

nextion text box

Not very pretty and normally I would NOT use their buttons etc. but make up my own imagery using PowerPoint or similar – but it’ll do for demo purposes.

Nextion displayNow I have to say, the worst part of this is the Nextion editor – progress is moving slowly with this – when you come to program it – make sure you have the right port address because it is hopeless at searching – and if it gets stuck you end up using task manager to reset it – comes up as PRJ or something – I’d so like to get my hands on the source code to give it a good shake-up.

Anyway, there it is- you end up with a window in this case with default text “newtxt”.

nextion display[5]Fire out the command {to_nextion:"mytext.txt=\"Hello\""}

You can do this serially or via MQTT- as the example from MQTT_spy shows.

This results in “Hello” without quotes appearing in the text box. Why the backslashes – that is to “escape” the quotes so they don’t end up terminating the string above – in other words so the quotes are passed through.

The WORD manual for my software describes the “to_nextion” and “set_serial” commands.

Have fun.

mqtt-spy[7]

Facebooktwittergoogle_pluspinterestlinkedin

29 thoughts on “Nextion Update

  1. Sorry to be a little off topic, but I have been playing with the script, I ran it as is and lost the GUI, so I looked at the script and commented out
    #sudo apt-get remove --purge node* npm
    #sudo apt-get autoremove (times 3)
    and the also for the sections removing wolfram and Libreoffice.
    Manually removed Node-Red and NodeJs
    and after reboot GUI is still there... The node* is the one which I think has the biggest potential to be the problem.
    Now I just have to figure out how to make Node-red play the game for me...
    Great stuff!

    1. You are right about node* I killed the * and forgot to update the script. Fixed now.

      If anyone wants wolfram then of course - comment out - I've never heard of anyone using it and it uses an obscene amount of storage. I had no need for office - the assumption being that someone who's going to use this to control stuff is unlikely to be wordprocessing etc on it - but again - people can leave in or take out what they want.

      Node-Red like a lot of things - at first - you'll be scratching your head - but after a while it all becomes clear what a great job the guys have done.

      1. It is really amazing, I was able to get it going pretty quickly to do some basic things, but figuring out how to create the functions is a bit more intensive.
        But monitoring MQTT traffic, very quick and easy..

  2. Hi Guys,

    I'm failing at step 2. I have installed the Nextion editor, added a font as that was missing, added the 2 buttons. Add the press events and uploaded.

    Without connection to an esp8266 i just looked at the serial coming out of the display.

    I get "pnodered~down???" for pressing down and "pnodered~up???" for pressing up. which i assume is wrong as i get nothing in the mqtt spy.

    Any Ideas ?

    Paul

    1. You will be seeing strange characters because that's what the board puts out - starting and ending control characters - read the Nextion docs (for what they are worth) - if you look at them in hex rather than decimal they might make more sense. In my recent blog I went through this from scratch to ensure that it does work (well, there was always the chance I might've changed something inadvertently) - and it does. Did you use the bauds command in the right place - is the data coming out at 56k?

      1. Hi Pete,

        Yes I did, put bauds=57600 in the preinitialise event and yes and using your great serial terminal app, I get what i posted above. @56k

        I'll keep poking as i'm sure it should be working. however i'm also seeing no serial data coming out of pin 4&5

        I'll try a different board.

        Regards

        Paul

        1. Ok, I've found the problem.

          It's not with Pete's code, which i didn't think it would anyway. It's the eps8266 modules that i have that don't like the software serial.

          To test this. I wired a bare eps8266 12e to a bread board and flashed 1.4.8, then did OTA to 1.5.4 enabled software serial and out comes data.

          Do the same with the module (LoLin New NodeMcu V3) and nothing. Swap pin 4 and 5 just in case and nothing.

          Regards

          Paul

  3. Hey Peter

    If you had your time over again - is the nextion worth it or would you look at a cheap android tablet for display of a custom Web page/mit app inventor and just push everything back to node-red?

    1. Hi

      Had this conversation several times.. So firstly - really cheap Android tablets are pretty awful and some are not even reliable - I've a pile sitting waiting for the day I find a use for them - usually can't upgrade etc.

      Secondly - unless you're already doing this - figuring out HOW to do this is probably a bigger learning curve than learning to use the Nextions.

      So the short answer - it all depends on your current skill set, your ability to NOT buy a duffer when looking at the really cheap end of the scale - and then there is power consumption to consider and you have to know how to stop the tablet turning off and.....

      I'm happy to use the little Nextions 🙂

      1. Hmm,

        I might head down to our local Stationery wholesaler - they sell a reasonable brand of tablet and check out the specs on their Android 7 inch tablets.

        Easy to stop the screen turning off - Developer mode, tasker to dim it right down when not in use.

        My thoughts are a responsive HTML 5 website - populated through node-red data and pushing back button presses etc to Node-red - would give you device independence to a certain extent - mounted on the wall in a small fancy picture frame - could still have a local ESP8266 for Temp measurements etc

        Something like this

        http://www.officeworks.com.au/shop/officeworks/p/lenovo-tab-3-a7-10-7-tablet-syla7tab3

        1. If you want to develop a page of course yes, I would have thought that node-red-desktop would do for many applications - buttons, dials etc, straight into Node-Red. And if it doesn't do the job - at least we know the guys to pester to get changes made.

  4. Hi Peter! This is msevyt from youtube. So to follow up on the rounded corners and white areas debate....You say you draw the before/after "button-pressing" look of the entire screen, how do you then configure the buttons in the editor so that they are transparent? and that just that part of the screen in question changes?

    Thanks.

    1. Hi mseyyt.. you really need to read and experiment with the Nextion editor... I can't do a tutorial here. Suffice it to say they have a command - meant to reserve resources that lets you define any rectangular area and make it use the original image - or replace just that bit with the same bit in another image - that way you can open up alternative states (more than one of course) for any part of the underlying image. It actually is a lot more powerful than you might imagine. There is no transparency... just the illusion of it and it works.

  5. Great blog! I stumbled across the Nextion display while trying to find a ~2.4" display with touch that would play with the ESP8266/32 devices with the available drivers, what I found didn't make me feel fuzzy. A Google got me here and a few dollars more purchased the 2.8" Enhanced Nextion NX3224K028 - I wanted the 16MB instead of the 4MB, the 8 I/O lines, 1Kbyte EEprom, and all that for only $4 more. It seems the pricing above 2.8" leaves me to just buy older Android devices for front ends, yes you can stop Android from sleeping with an application but you'll need it wired to a power source, and it is many times more complex dealing with coding for the Android device than the Nextion, from what I can tell.
    Thanks for all your efforts! Liked the Eagle PCB, I converted it to Diptrace so I could add a ESP32.

  6. The Hextion Enhanced arrived and I'm not happy: They included a micro USB board with two pins +5 and GND, you plug a power supply into the micro USB adapter then plug the Nextion red and black wires into the USB module. That works but when you add a FTDI USB to Serial TTL module how do you connect the FTDI ground to the USB ground? All they needed to do was add a three pin header to the USB module with two pins being GND. I ended up adding extra ground pins to my FTDI board and then plugging the Nextion black wire GND into one of the FTDI GND pins and a jumper from another FTDI GND to the Micro USB module GND pin. I am beginning to believe they really don't know what they are doing, ESP8266 74800 baud, ITECH not using standard serial protocols, building stuff that can't work and all of them telling you something works until you prove it doesn't mean while wasting hours.

  7. Hi Peter, great blog!

    I am just starting my son-off journey and also came across these nextion devices - i am interested why you haven't looked at using the TX/RX ports on the sonoff device to connect to the nextion display? is that possible rather than a separate ESP based device?

    1. I think because Sonoffs are meant as mains control - not as general purpose computers. Their power supply is no-where near powerful enough to power a Nextion - and if you start adding power supplies it kind of defeats the object. The Sonoffs are good at being a cheap mains relay with possible temperature/humidity sensor and I'm happy to leave them as just that.

  8. Hi Pete,
    I was managing with nextion display. I succeed in getting command from and to display via nodered, but I'm having an issue about sending data to display.
    In the beginning I was thinking I made a mistake in syntax. I also made a lot of trial also using the {to_nextion} command via serial port of esp8266 to understand what was happening.
    The point is that any touch event from the display is immediately provided to esp, instead I have to repeat many time the to_nextion command before the screen change in the way I want. Many times can be 4-5 times up to 10, also there are some lucky shots and it happens at the first time. The speed is 57600. I check the output of the ESP and it's seems to me that I have the correct output any time i send the command. What's your opinion? have you experimented something similar?

    1. I had some more trial with Mqtt Spy either.
      It seem that the command to_nextion arrives to (or it is executed) from the nextion only if I send a quick burst of 3-5 message in raw. I meant only if I click very quickly on the mouse button to send the script.
      There is any way to see from serial port when or if a message arrives to the esp?

      1. Again, I'm going on with test and I saw that the ESP return me an OK in the serial interface when I send the to_nextion command, and it happens every time I click the mouse button publishing the command via mqttspy. So the issue is on the esp/nextion interface or maybe in some hidden or not evident feature of the nextion display.

        1. I had the last additional information checking the data that came out from the esp GPIO TXT with digital IO probe.
          If I send one time message like {to_nextion:"t0.txt.....} I see the message 80.txt=... if I send the message two times let's say with a pause of half second between them, again I see two times the decoded message 80.txt=...
          Instead if I click very fast the first of the two messages is still 80.txt=... instead the secnd one is t0.txt=.... correct.
          How to overcome this issue? it doesn't seems to me an hw related problem becasue the malformation of the signal occurred in a specific way and it is reproduceble. I attached the comparison of the two digital signal

          1. Of course, I apologize for putting all this consideration on your threads. If you want delete all of them.
            I solved just decreasing the serial speed to 38400 (set_serial:3) and everything works like a charme.
            In any case I will try with other ESP I have to see if some sort of eletronic problem or maybe is related to the softuart.
            Thank you Pete!

  9. Has anyone tried sending a £ sign to Nextion Display? I have tried generating several different fonts using several different iso-8859 standards. The closest I can get to success is a £ sign preceded with a  .
    E.g. £1234.00. this is using iso-8859-1.
    Any idea’s ?
    Thanks Chris.

Leave a Reply

Your email address will not be published. Required fields are marked *