Start a new topic

Arduino +Dht22 + Nextion

I dont speak english


Google Translate


I need to show the Dht22 temperature value on the Nextion screen. But I did not make it. I have an application with Dht22 in hand. I need to follow a path.


Türkçe


Nextion ekranında Dht22 sıcaklık değerini göstermem gerekiyor. Ama bir türlü başaramadım. Elinde Dht22 ile uygulama yapan varmı. Yada nasıl bir yol izlemem gerek.


DHT22 pdf from sparkfun:

https://www.sparkfun.com/datasheets/Sensors/Temperature/DHT22.pdf


IteadLib Arduino Nextion Library

https://github.com/itead/ITEADLIB_Arduino_Nextion


Nextion Instruction Set

https://www.itead.cc/wiki/Nextion_Instruction_Set


Nextion Editor Quick Start Guide

https://www.itead.cc/wiki/Nextion_Editor_Quick_Start_Guide


Nextion HMI Solution

https://www.itead.cc/wiki/Nextion_HMI_Solution


Nextion Number Component n0 on page0 of HMI design

- where n0.id has the value 1 (first component on page)

- Nextion needs to receive: page0.n0.val=23ÿÿÿ

- the three bytes ÿÿÿ each are hex 0xFF or dec 255. char ÿ


Via the IteadLib Arduino Nextion Library


void display_temp(void) {

  NexNumber mytemp = NexNumber(0,1,"page0.n0");

  uint32_t temp;

  // insert code to deal with DHT22

  // temp = ...

  // send temp to Nextion n0

  mytemp.setValue(temp);

}



1 person likes this

Global Memory:0

Page:page0 Memory Occupied:0+173=173

Error: Invalid Variables:page0.n0.val( Double click to jump to code)

Compile Successful! 1 Errors, 0 Warnings,File Size:100.362

:((

  • Do you have a page "page0" in your design?
  • Does page0 contain a numeric variable "n0"?

 


1 person likes this

image


Leave out the trailing 3 characters. Those are supposed to be the end marker when you send these commands via UART only.

1 person likes this

No knowledge of programming nextion. Could you show an example

Sorry - no.

Read the manuals, see the coding examples, try yourself.

 

Please check the link below for visual view of the Editor


Nextion Editor Quick Start Guide

https://www.itead.cc/wiki/Nextion_Editor_Quick_Start_Guide


Select a Number Component from Component Pane (left side)

Check objname in attribute pane (right  side)

This should be n0

check id in attribute pane of n0 for number

this number is used in Arduino later to link to n0

NexNumber mytemp = NexNumber(0,1,"page0.n0");

the 0 changes with the page number

the 1 changes with the id number

the page0.n0 changes with pagename & objname

(You need to type these changes in your Arduino code)


if n0.id is 1 then then Arduino needs to send

   page0.n0.val=23 followed by 0xFF 0xFF 0xFF

across the serial RX/TX wires.  This is to state what is to happen.

But in Arduino this is accomplished with the .setValue as in


void display_temp(void) {

  NexNumber mytemp = NexNumber(0,1,"page0.n0");

  uint32_t temp;

  // insert code to deal with DHT22

  // temp = ...

  // send temp to Nextion n0

  mytemp.setValue(temp);

}


Your number component n0 is your place holder for your temperature

But its value will be changed by your Arduino MCU when you know

what the actual value of Temperature will be.

Thank you very much. I will try and write the result soon.
Login or Signup to post a comment