One thing Nextion and the people representing them are really good at is telling you how amazing their product is. While many people here have more … differentiated opinions about that they are in fact making sort of an understatement. The Nextion plattform actually has some very interesting capabilities they don’t tell you about. Among those things: drawing QR codes at runtime whereever you want - even from your MCU over serial, an alpha channel (transparency) for drawings and the ability to read the current CPU load percentage. Why Nextion hides this from you? I wondered about that, too. Details below.
The origin of this discovery is the high interest in developping a custom firmware for the NSPanel. While the stock firmware doesn’t look bad, many prefer a solution compatible to popular home automation systems like Tasmota. The" good" news is that the NSPanel at its heart is a Nextion Discovery screen, so creating alternative UIs is as easy as with any other Nextion screen***. Or at least that’s what we thought. Every custom firmware suffered of the same serious touch offset of about 30 pixels. The stock UI however doesn’t. Didn’t take long to find out that the stock firmware used a so far unknown command: lcd_dev
. Truth be told, we don’t understand what its capabilities are but copying it with the exact arguments as used in the Sonoff firmware fixes the touch offset.
This discovery lead to the question what other commands there are that are hidden - and guess what: there’re quite a few and they’re way too interesting to not share them: Full Instruction Set
Before I wrote this post I asked Patrick and Thierry for what reason even “normal” commands like the qrcode
command are not available to users. Unfortunately the reply was that they won’t comment on this and that anything outside the official instruction set would void your warranty.
With regards to the lcd_dev
command I can understand the point. However, for draw commands like qrcode
I can’t tell you why they’re hiding it. The obvious thought was it must be an unstable/new/not-ready/…" command. So I had a look at the QR component and guess what. It uses this exact command internally (you’ll find the same instruction in the TFT file in both cases). This is not surprising; actually the opposite would be much more suprising. But it pretty much defeats every reasonable argument for their behavior.
Honestly, my best guess is that they forgot to add it to the NIS when introducing the QR code component…
As a “proof of concept” I created a demo that makes a QR code walk around the screen, updating itself with its current coordinates. Additionally it shows you the current CPU load. You could already do the animation part on the intelligent series but this demo works on all series. There are more useful use cases for this of course; being able to display QR codes from an Arduino can be very useful! In my opinion way too useful to hide.
Happy hacking!
Max
*** Nextion does not make it easy to create a UI as shown by the Sonoff product or the discovery series promo pictures! A lot of extra work is required to do so.
In my opinion the Sonoff NSPanel is a perfect example of what Nextion is not suited for. Nextions selling point is that it makes simple to medium UIs very quick to develop and that you don’t have to code the widgets yourself. Drag, drop, done. That’s the reason why people buy them and why their high price (compared to simple LCD panels) is justified. Sonoffs UI is not simple, requires developing custom widgets anyways and it’s not a low volume product.
The widget I talked about is the round slider. It is also shown in the promotional pictures of the discovery series on Nextions home page, giving the illusion this would be what you get. It’s not. You have to code it yourself. Additionally you can’t code it in a fully-featured programming language or using a decent editor, no, you have to do it in Nextions limited, prorpietary language using their editor.
In my very personal opinion Sonoff could have created an at least as appealing yet cheaper product by omitting the Nextion part alltogether and running the UI on the ESP32. Many people have shown that it’s more than capable enough to do so using free UI libraries much more powerful than Nextion. They spent time and money making all this custom stuff on Nextion (including a JSON parser btw. Yes. On Nextion.) while a ready-to-use solution like openHASP exists. It uses similar hardware and the library linked above, meaning a circular slider is built-in. All they’d have needed to do is maybe create a custom look and be done.