Finally working: Nextion HMI, ESP32 and
Sonoff’s new Human Presence SENSOR SNZB-06P!

First of all, I need to apologize for 2 Sundays without a new blog article! But getting finally everything up and running was not as easy as I thought… Although my dear Chinese colleagues had provided me with excellent code for both sides, ESP32S3 and Nextion, I had to do several adaptations until everything was ready to use outside their lab.

But now, after some patches here and there, everything works finally and I’ll proudly present today the step by step procedure with pictures. From next week on, we’ll look together into the code, so that you can reproduce everything or still better, extend and adapt it for your own needs.

But today, as I said before, I’ll give you the proof of work, with the ESP32S3 code and the Nextion code already compiled and uploaded.

The needed parts

1 – 4 SONOFF ZigBee Human Presence Sensor(s)

1 SONOFF ZigBee Bridge Pro (this creates the link between the sensors and your Wifi)

1 Nextion 7″ Intelligent Series HMI (this is the enclosed version which I find nicer, though the raw version will do it, too)

1 Arduino Nano ESP32 or compatible (I decided for the smaller and cheaper Seeeduino Xiao ESP32S3 which is compatible)

The Setup

After uploading the firmware to the ESP32S3 via USB and to the Nextion HMI via the FocaMax board or any other USB to TTL UART adapter, we can connect everything: The ESP32S3 gets power from a 3A capable USB 3.1 port, so that we can power the Nextion HMI from its +5V and GND Pins. The Nextion’s yellow RX cable goes to the ESP32’s TX pin (D3) and the Nextion’s blue TX cable goes over a 1.5k resistor to the ESP’s RX pin (D2). Why that resistor ? Remember, the Nextion Intelligent series has 5V logic level but the ESP32 only 3.3V. To prevent frying the ESP32’s RX input, this current limiter resistor is needed. In the other direction, such is not needed. The Nextion’s RX input is perfectly compatible with 3.3V.

BTW: Does anyone know how to get rid of this ugly moiré when taking pictures of a LCD screen with an iPhone? Please tell me by email (see bottom of this post).

Somewhere, you’d also need to place the ZigBee Bridge and to power it with 5V from an USB charger:

Now, where to place the sensor? My office with 9 square meters is so small, wherever I placed it, it would detect my presence all.the.time… Thus, I decided to install it near my Italian Espresso maker in the next room, again powered from a simple USB charger:

When I came back to my office after taking the picture, I saw the result on the Nextion display: Someone was close to my coffee maker!!!

Now, how to make the link ?

First of all, your ZigBee bridge and the human presence sensor have to be configured and connected to the cloud through The EweLink application on your phone as shown in my last blog article, so that afterwards, the Nextion+ESP32 combination can retrieve the information. And the “connecting everything over the air” continues as follows.

After powering on, we are greeted with a nicely animated splash screen first, before we need to connect to the Wifi with the help of the on-screen keyboard At this moment, we aren’t yet connected as the icon in the upper right corner displays:

Clicking onto “Connect” does within a few seconds what we expect and we are presented with the second screen where we connect to the EweLink cloud:

Now, everything is “on the air” and we see the main screen where we may check the status of up to 4 Human Presence Sensors:

Walking again over to the Espresso maker next room showed again that the human presence sensor was working and that the Nextion displayed the info in real time!

And that’s it for today! From next time on, we’ll look under the hood of the ESP32 and the Nextion code to understand how everything works. Stay tuned!

For today, thanks for reading and happy Nextioning!

Questions, comments, critics, suggestions? Just send me an email to thierry (at) itead (dot) cc! 🙂

And, by the way, if you like what I write, and you are about to order Nextion stuff with Itead, please use my referral link! To you, it won’t make a change for your order. But it will pay me the one or the other beer or coffee. And that will motivate me to write still more interesting blogs 😉