The Nextion Experiment

Nextion BoardOur latest experiment! The board you see to the right should be with us in a couple of weeks. This little number will sit on the back of a Nextion board, from the smallest to  the largest without adding any height (hopefully) and contains as you see an ESP-12 and supporting components.

The extra connectors are just to give it a more general usefulness.

Having implemented software serial on GPIO4 and GPIO5, the board will allow for sending messages via MQTT directly to the Nextion while still allowing debugging and programming of the ESP using the normal ports. 

Far better I think than strapping a Raspberry Pi onto the things. We’ve not tried to do anything too clever here so this all assumes the display is already programmed up.

My own use for this is a couple of simple wall units to show and control heating and lighting… I already have a display hooked up to a Raspberry Pi for general control but it’s a tad excessive having those plastered all over the house hence this board which we’ve had made as thin as possible.

Can’t tell you much more until we get the boards back and give them a go.

Currently ending my first week of a 2 week contract (well for now anyway) over in Spain so my ability to experiment is severely hampered as you might expect (but that is compensated for by sunshine). 

By the time I get back to the UK  I’ll have some more Sonoffs to play with (hopefully the later types with one of the LEDS attached to GPIO13 on the ESP8266) and some new ESP-related stuff to review.  My new workshop is up – just needs electricity, insulation, desks, shelves – no problem really!

Facebooktwitterpinterestlinkedin

32 thoughts on “The Nextion Experiment

  1. John,
    I checked in the board manager and it is the latest available but it is working now happily sending values to cloudmqtt.
    cheers,
    Phil

    1. Well I’ll be ……..
      I tried the dtostrf() again and this time it works, yesterday it crashes the ESP every time, the only thing I did different was use a different format
      dtostrf(h,4,2,msg);
      instead of
      dtostrf(h,4,1,msg);
      Maybe the ESP didn’t like that, not enough decimal points??

      Thanks for the advice Mr. PuceBaboon, it was good advice.

      1. Phil,

        You might want to try updating the core support (Tools->Board->Boards Manager->ESP8266) from the IDE. It looks like the dtostrf() function has had quite a few updates since the earliest versions. Unfortunately, you never quite know what else the update might break. 🙂

        -John-

  2. Pete,
    Reading about the Nextion displays prompted me to dig out the 2.4″ one I got ages ago and give the Nextion editor another go, I found it really hard to get to use before.
    Now I’ve got MQTT working between raspberry Pis and got some ESP8266s it’s time to get stuck in and get it all joined up and talking.
    Having issues compiling code in the Arduino IDE for the ESP12, the PubSub library just will not compile, once I get that sorted I’ll be on my way, looking forward to your PCBs working OK.

    Phil

    1. Hi Phil – well, I don’t use the Arduino environment but I HAVE done and the PubSubClient seemed to work a treat. When I tried it there was a slight variation for the ESP but that may all be in one package now. It does work.

    2. Phil,

      There’s also a version of TuanPM’s MQTT from Ingo Randolph (https://github.com/i-n-g-o/esp-mqtt-arduino) which is, as you’d expect, a lot closer to Tuan’s original in terms of use.

      You don’t say how the compile fails, but I had trouble after using the Arduino-IDE library updater recently where is started falling over because of multiple definitions for some of the SSL settings in MQTT (even though I’m not using them). I just commented them out the ones in the MQTT src and left it to pick up the (new?) defines from the core library.

      1. Hi
        When it fails it just hangs … no errors!
        I tried another example sketch I found which compiles OK, it took me some time to sort out the correct port and user details before I got it working but I now have an ESP-12 that will send data to the cloudmqtt.
        Next step is to get it to send some DHT22 data ……
        Thanks for the reply.

      2. Anyone good a C ? 😉
        I’ve got the sketch sending to MQTT but when I add in the DHT22 code I have a problem that the returned values for temp and humidity are float values but the publish function wants a string, I tried sprintf but Arduino won’t compile it apparently so I tried dtostrf() but this just crashes the ESP12 whenever it get to it ?? It works with an UNO!
        I try a couple of ESPs with the same result.

        Any suggestions, I’m nearly there!

        1. Well, a LOT more info would be good – are you using the Espressif SDK- etc… I would suggest…… you use

          os_sprintf (yourbuffer,”Hurray the value is %TTT”, your_float);

          where TTT is whatever the code for float… erm d or f ????

          I had mine reduced to integers – could not really see the point of sub 1 degree or sub 1 percent – so they get stored as simply signed 16 bit integers.. but if you want floats I’m sure os_sprintf is your best bet.

          1. Pete,
            I’m using the Arduino IDE and I’m just using the variables returned by the dht library, which are floats. I’m afraid I’m just not that knowledgeable about C, this often happens to me, I get the bigger stuff done then get stuck on something silly.

  3. A board like this with a lipo charging chip and a connector for a battery, installed into a simple enclosure would be quite nice.

      1. Vladimir and Daniel – so the plan is to use these with plug-in-the-wall power supplies so power is not a worry – but of course you could always turn the ESP off when not in use – and in my case I reduce power on the display by dimming the backlight when no-one has pressed anything for a while.

        1. After had a lot of nice time digging your so interesting blog, I’m starting my own first project around esp8266 and Nextion (display still to arrive from China). It’s about power consumption monitor and management and I’m thinking to add a PIR sensor to switch the display on when someone is approaching it. All wall powered, so it’s not really a power consumption need, but I’d prefer not having the Nextion powered on all the time. Do you see any cons about that?

          Is the board you’ve shown here somehow available for purchase?

          1. Not at this time as we don’t know if it will work yet. In couple of weeks we’ll have the boards and I’ll blog about them – if they turn out well we’ll either offer them at a small markup or put the files on the web. I think this might be a generally useful board.

      2. A few hours between charges would work well for my application, but I think you could increase battery life with judicious use of sleep modes and low back-light levels …. and bigger batteries.

  4. Hi, Peter.
    Have seen your blog two years ago. I’ve impressed your drift to IoT.
    May be you would like to look to one project – ESP8266 software toolkit.
    Web demo: http://demo.wifi-iot.ru/
    Home page: http://www.wifi-iot.ru/
    They added a lot of functions and peripheral devices to ESP.
    Nextion added too.
    There is a language problem, but you can understand a lot without translation.
    If you want to know something more i will try to help.

  5. Had I had my thinking cap on we’d have put a pair of pins for reset to save disconnecting the Nextion if it needs reprogramming (as the pins on the ESP are tristate in reset). However it does mean we can make some nice little wall displays. If the board works out ok we’ll put the gerbers up for anyone who wants to have a go.

    1. Speaking of Nextion reprogramming, I was disappointed that Itead has not released the serial protocol for uploading new “programs” to Nextion displays. Seems like it would be nifty to send a Nextion update to the controlled attached to a Nextion (ESP2866, RasPi, Arduino) and have it push the update to the Nextion over serial. Slow, yes, but having the capability to do remote updates is handy. I’m guessing it wouldn’t be hard to reverse engineer the upload protocol with a serial sniffer. I’m going to order a Nextion panel and see what I can do.

      1. But…. it’s serial – if anyone is interested it would surely not take very long to figure that out given a very trivial screen layout. But then I guess that is what you are saying.

        I suggest a blank screen all but for a label – and a button – and see what happens when you update it. I do know that you won’t find much compression as I know they are concerned about processor speeds hence the lack of transparent PNG files – I suggest that any images will likely be sent as simple BMP files. If you DO take the time to figure out the entire protocol, be sure to write back in and let us know to save people re-inventing the wheel.

        I certainly will be writing in as I find out more about these devices. Having set a price point below others, they have nothing to lose by giving us as much info as possible.

        1. I’m hoping serial upload is simply a special command that tells the Nextion to get ready for an upload, then a straight transfer of the TFT file, then an end-of-transfer command. That would be easy. Maybe there is some error checking, that would take a bit more work to sniff and decipher. Think how nice this would be: make some changes to your interface in the editor, compile to a TFT file, send the file to your controller and tell it to upload, it signals the Nextion to get ready for an upload, the TFT file is transferred then ended, then reboot the Nextion and new interface.

          Or it may be as you say that a serial upload is very different from the TFT file so every element would have to be figured out (ug). Hopefully not.

          1. Nextions program by simply attaching your FTDI or other usb to serial device – and from the PC program – press go – the file is uploaded – you see the status on the display. I don’t care about people deciphering the code – some of my code was written by others (rBoot and other material) and so protecting it would be a bit cheeky.

  6. Looks very interesting Pete. My only suggestion would be to replace the programming switch with a simple jumper across a couple pins. Isn’t this much easier than a momentary switch which needs holding down. I’ve used this very successfully on a couple of projects after borrowing the idea from Nathan Chantrell’s proto board for the 03.

    Simon

    1. Except that… you don’t have to hold the pin down while programming – you only have to hold it down as the power comes up then you can release it!

Comments are closed.