Nextion WIFI Touch Display

tmp4E3Nextion BezelThis award-winning project ** is a development of previous (home control 2016) work on the Nextion touch serial displays and offers a WIFI-controlled (MQTT) touch display which can be used with the full range of Nextion displays from the little 320*240 display you see here, up to the 7” model.  A word of thanks to everyone who voted for us in the esp8266.com 1st annual competition – the design was beaten to top place by the excellent ESP8266 Basic interpreter and rightly so as that is a great addition to the ESP8266 programming arsenal.

The background to this project is the ESP8266 software we developed for general use over many month, which loosely started off as a MQTT demonstration and grew over time to become general purpose ESP8266 software written in C to make good use of the various IO pins of the ESP8266 and MQTT as a communication protocol.  The peculiarities of the Nextion display is that it is normally communicated with serially. The serial lines of the ESP8266 are really needed for programming and debugging and also put out some debug info on power-up at 78k so that was really a non-starter and so a software UART was added to the code to provide a second serial line at 56Kbaud to control the Nextion.

There is a video of this example display here. The example image shown above right is merely a prototype as we await Rear View of the WIFI serial boarddelivery of a new 3D printer at which time we’ll put together a better front bezel. In this case I need a thermostat for a holiday rental installation and used this here merely as an example of what a serial WIFI display could be used for. The techniques I’ve used are applicable to a wide range of products.

The board mounts onto the back of any of the various displays with simple double-sided adhesive foam and as you’ll see in this example connects to the Nextion serial connector.

So the basis here is that we have an MQTT controlled touch display with haptic feedback and visual indication of button change of state.

Nextion DisplayIn this example there are only two states for each button i.e. on and off and as the Nextion Editor cannot handle rounded transparent PNG images we use another way., The editor has a feature called “crop image” in which you can select an overall backdrop image but on demand replace any rectangular area with a window through to another image. So all that is required in this case are 2 images as shown below, one featuring everything turned off – the other with everything turned on.  I should point out that at the time of writing a major update to the Nextion editor is in the works! More on that in a future article.

Compared to trying to match background colours to simulate transparent PNG files, this method works extremely well. Of course you don’t have to use PowerPoint but I find it produces the best results for the least work.

Powerpoints for Nextion Powerpoints for Nextion

If you look at the two slides/images above you’ll see the difference and how a series of rectangular windows to the second image could give the impression that we have both on and off states for individual buttons – and even pressed states in the case of the up/down buttons.

Nextion EditorOf course – using our code is probably well over-kill and may not suit your purposes – really all you need do is ensure you have a software UART on the ESP which is able to run at up to 56kbaud – you could use a slower baud rate as long as you don’t wish to fire TOO much information at the Nextion display (though it the most likely area of issue would be returned data – you should have a software UART that is running under interrupts).

We keep our instructions to and from the Nextion displays down to a minimum of complexity. In the image on the right you’ll see how this all looks inside the Nextion Editor.

On the right we define hotspots for touch sensitivity – which COVER the various buttons and those hotspots can be defined not only to return a value when pressed but also to change to make use of the “crop image” feature of the Nextion – to show part of ANOTHER image when required – and that is the second image of the two above.

For the likes of the up and down buttons – a touch press event in the editor like get “nodered~down” suffices to send out a message back – I’ve used a tilde to separate topic and payload in the message to be sent back out so that in this case it will be sending an MQTT message topic:”nodered” and payload:”down” – so you could send messages to Node-Red to communicate with controllers – OR you could control them directly by using the right topic and payload.  In the case of indicators, nothing is done at the display end – sending a message from Node-Red to, for example “led1” to tell it to use an alternative image is sufficient to make it look “on”.

Alternatively we may be simply displaying text. The Nextion does text in various sizes fairly well whereas image handling is not quite so good (no transparent PNG files yet and hence the “crop image” method). Even with a graduated background this method works well.

The board features reset and programming buttons to make life easy, an FTDI-compatible programming connector on the left and all the general IO pins are brought out to 0.1” on the right – this board will have many more uses than simply this display! What else does the software (which compiles under Windows – Unofficial Development Environment) do? Just about everything – RGB LEDs, PWM, general IO, software clock – there’s a WORD doc file with the project

Links:

Here is the link for the EAGLE files for the PCB, PNG files of same, a bill of materials for parts and Nextions own 3d printer file for a simple bezel (we will endeavour to produce a better one for our own use an include it in the coming weeks, time permitting). Also included my own demo PowerPoint file as used here.

Here is the link to the  source code for the general purpose ESP code which includes commands to handle this display and to send out MQTT commands.  This is has been put together using the Windows unofficial Development environment using Eclipse.

Generalised software:

tmpC40BThere is of course (optionally) a LOT more to this board than just using the Nextion Displays… if you choose to use our software (which should compile without issue in Windows using the Unofficial Development environment) you can expect to be able to control the other ports via MQTT and serial. See the home control project on the blog – or the documentation file. I’ve just successfully tested the above boards to control GPIO0, 2,4,5,13,15 and 16 as outputs. GPIO2 is attached to the DS18B20 tracks on the board and simply dropping in a DS18B20 on the board will allow for temperature control (averaged and to the nearest degree C). You can also use DHT11 (not recommended as not very accurate) or DHT22 (more expensive but WAY better). Defines are in the user_config.c file.

Hackitt Boards

Using a standard FTDI and the Eclipse environment it is not necessary to use the reset button – simply press the programming button and start programming – then release. The reset is handled by a cap on the board and some Python software in the project. A future version will likely do away with the need to press the (GPIO0) programming button.

** April 16 2016 announcement – the project won second prize in the 1st Annual ESP8266 Design Contest over at esp8266.com

May 4th Update: Haptic feedback – when the board is being used in “Nextion” mode – we use GPIO12 as a beeper – simply fasten one of those cheap round haptic feedback devices to it and glue that to the back of the board.

September 18th Update: if you are using the board with the RGB LED and you have that attached – don’t solder in the ordinary LED – they both go to the same place and it is one or the other.

February 2017 Update: Some users have reported issues at higher speeds. If you have issues – try using 19k2. Given the low amount of information going back and forth, this will generally have little if any effect on performance.

Facebooktwitterpinterestlinkedin

128 thoughts on “Nextion WIFI Touch Display

  1. A year or so I ordered what I thought was the Nextion display…Turns out I purchased a TJC4024T032 a product that Nextion will not support and is to be sold in China only.
    http://support.iteadstudio.com/support/discussions/topics/1000062718

    – the Nextion Editor and UsartHMI will remain closed source.
    – TJC devices are intended for the Chinese market
    – Nextion devices are intended for the International Market
    – support for TJC devices will be supported by TJC.
    – support for Nextion devices is delivered by Itead.

    Since I’m unable to find firmware to convert the two displays for english use. I’m happy to give them to someone that might be able to use them for the shipping cost.
    I’m located in the San Francisco bay area.

    Paul Hampton

  2. Sorry you lost me with your curt reply Peter?
    Pictures of large unpopulated pcb’s are show in the HA blog but I ask again, can these be purchased and poulated?
    Not sure how clearer my original question could be?
    This blog really requires good coding skills. Ok something I dont have. I can follow instrctions (eventually) to download and upload to devices.
    I get excited about the posibilites, then find everyone starts talking in Martian (Petes reply an example).
    I am fine at electronics (50 yrs). Is there a starting point?
    Most of what I read/view is clearly for the enlightened.
    Sorry, but it looks a bit like a clicky group, where one is frightened to put therir hand up and say ‘sorry I dont understand that’, because it will show they arent on the same level.
    Anyone recomend some reading/YT viewing that can help me get started?

    1. Not meant to be curt, more concise. I don’t sell stuff. A long time ago we made some PCB gerbers for our own use and there’s a link in the site. Nothing to purchase.

    1. The Gerbers are there somewhere. Today you’re as well to get hold of WEMOS D1 – by the time you get the boards made in China and populate them….

  3. Hello Peter,

    I’m putting together a BOM for the parts needed in addition to the touch display circuitboard that I ordered from OSHPark. I’m having trouble however verifying a few items from the BOM you posted, since it looks to be an older version of the board. Specifically, the switches aren’t the OMRON version, but smaller tactile ones? I’ve found what I think would be serviceable switches, 4.70×3.5mm ones on Digikey. Does that sound right to you?

    Also, I wasn’t able to find R5 listed on the BOM, but it was in the SCH file as 20k. Is that accurate? Assuming one would use the ADC to measure battery voltage no more than 20VDC.

    Here’s a link to my cart, enough to create three fully populated boards. For components such as resistors and capacitors, I’ve set quantity=10 to get a better price. There is likely some room for improvement here, as the current price is $30 w/o shipping. This link could also be used by others to save repeat searching on Digikey.

    http://www.digikey.com/short/3251vm

    Thoughts? Looking forward to testing out a fully built board using a Nextion display!

      1. Thanks! I’m also using an ESP8266-12F, which has new pins broken out on the bottom of the board. That shouldn’t impact any current functionality, but may provide some useful additions on any future version of the control board.

  4. Hi Peter – a suggestion – if you update the H&B board add a micro usb socket for powering it easily once configured.
    Brilliant blog BTW !!

  5. Further to some comments elsewhere on the blog ( & some frustrating hours ) I have also found that I could not send text to the Nextion without reducing the baud to 19200.
    To add to my confusion I could receive notifications on button presses from the Nextion at 57600.

    1. I’ve not used this for some time – and of course, the SDK has changed etc… assuming it works at 19k2 – use it at that baud rate. I will amend the blog to recommend this.

      1. A thought – though I’ve never had any issue running the unit at 56k, there is one simple way to improve reliability at speed of the software UART… double the clock speed – there’s an instruction for that and it does not make that much difference to power consumption!

  6. I don’t suppose anyone in the UK has a couple of spare boards they’d sell? I’ve put an order in for 10 but am itching to get started.

    Thanks,

    Steve

      1. I’m already splitting them with a mate and I think they’re all earmarked. If we have any spare I’ll let you know, though

          1. Sorry, only just seen this. I’ll take 2 if you’ve got them please, Jonathan. Drop me an email to steve (at) efini (dot) co (dot) uk and I can sort out payment etc.

            Cheers,

            Steve

            1. Hi Mark

              If you want a couple of boards drop me an email at jonathan (at) weightman99 (dot) fsnet (dot) co (dot) uk

              Jonathan

Comments are closed.