Start a new topic

How to set values for Temp and Humid through Nextion

i have made a temperature and humidity controller, recently i was using simple LCD and some mechanical buttons, with these button i can set values for each and every element but i am using Nextion 7" display, it is very nice but the problem i am facing is that i don't know, how Nextion buttons communicate / set temp and humid.

if anyone have sample code then please share to me


1 person likes this idea

1) which model Nextion

a) NX8048T070_011 or

b) NX8048T070_011 without expansion

c) NX8048T070_011 with expansion

2) which MCU are you connecting to the Nextion


Typically a temp/humidity sensor talks to an MCU via Analog to DIgital

- the MCU would then would relay status to Display

1st of all thanks for always support

by the way i am using NX8048T070_011 with arduino uno

i can SET and control temp in the UNO by using mechanical buttons but set value through Nextion is 1st time and i don't have any idea about.

please give me some example code then i can go through

okay, so with the Basic 7", there is no means for a mechanical button Nextion Side.

If you have downloaded IteadLib_Arduino_Nextion library, view its code.

#include <Arduino.h>

#include <Nextion.h>

void GetSensorValues(void) {

  uint_32t temp, humidity;

  NexNumber nexTemp = nexNumber(0,1,"n0.val");

  NexNumber nexHumidity = nexNumber(0,2,"n1.val");

  // read sensor values and temp, humidity calcs




void setup(void) {



void loop(void) {



1 person likes this

Edit your NexConfig.h and NexHardware.cpp and look through NexNumber.cpp

Put two number components on your HMI page

You will see in NexNumber.cpp how setValue gathers the n0.val= to get ready for the call to sendCommand that is in NexHardware.cpp.  sendCommand tags the trailing three 0xFF bytes as per the Nextion Instruction Set.  Not much magic going on.

Check the example folders for other code examples on how to handle and respond to touch events

I am still waiting, it is very urgent for me, my all work is on hold because of this function

please do something

I apologize, but I do not debug code user code. (Personally, my preference is a pascal).

Perhaps those that are more skilled in Arduino C can look for errors.

But, such a demanding tone will not attract many of them.  Sorry.

I have to work on finalizing the coding for the Nextion Contest - Closes the 19th.

Judging will need to be done to announce a winner before Christmas.

No Problem

but i appreciate your support in all aspect

i am also near to the solution, practice make a man perfect


For numbers you can use a Number Component in HMI

and NexNumber in your code.

NexNumber mytemp = NexNumber(0,7,"n0");

Then with a number mytemp.setValue(mytemp); // updating n0 with mytemp

Not mytemp your nextion number  ... but the number back from sensor.

I used below code and no error but not yet tested

WHAT IS YOUR OPENION, IS IT FINE or need some changes????????

 NexNumber n0 = NexNumber(3,15,"n0");

 NexNumber n1 = NexNumber(3,16,"n1");

void loop()



 h = dht.readHumidity();

  // Read temperature as Celsius (the default)

   t = dht.readTemperature();



void SetValues(void) {




I am a proficient Pascal programmer.  Delphi, Kylix, mikroPas, TurboPas

IT background, System Utilities, Security, Databases, Server Admin, Network, even Repair

Bare Metal MCUs of choice, Intel Edison, STM32, ESPs ...

and perhaps deepest understanding of Nextion firmware.  But ....

Arduino and Arduino C would not be my strong suit, so pseudo code.

Since I don't test such on physical hardware, Scientifically, could be errors, typos.

Best wishes for you

i will try my best to get this working

Thanks for best cooperation

I know that in the last 3 months I have answered three temp/humidity project questions in the Forum and the code for such may also be posted in their thread.  Google Nextion + (more specific to your sensors) maybe faster than reading each Free Chat.

Login or Signup to post a comment