Go Down

Topic: Nextion 7" HMI Display + PZEM004T-100A issues, values not showing up (Read 56 times) previous topic - next topic

crizangel

Hello!

I have a project that involves 9 PZEM004T-100A Power Analyzers and a Nextion 7" HMI Display (Basic model), and I can't seem to send values to my Nextion device thru the Arduino Mega's Serial3 ports. I have tried swapping out my v1.0 PZEM with a v3.0 one, and it still doesn't send to the Nextion. Is it possible that the textbox names that I have assigned to the textboxes within the display is too long? They are named "out1_curr", "sys_volt".

Attached is my code, which only utilizes only one power analyzer at the moment.

Code: [Select]
#include <SoftwareSerial.h>
#include <Nextion.h>
#include <PZEM004T.h>

PZEM004T pzem(19,18);
IPAddress ip(192,168,1,1);

#define NexSerial Serial3

void setup() {
Serial3.begin(9600);
pzem.setAddress(ip);
pinMode(13, OUTPUT);
}

void loop() {
float i = pzem.current(ip);
if(i >= 0.0){
  Serial3.print("out1_curr.txt=\"");
  Serial3.print("hotdog");
  Serial3.print("\"");
  Serial3.write(0xff);
  Serial3.write(0xff);
  Serial3.write(0xff);
}
delay(1000);

float v = pzem.voltage(ip);
if(v >= 0.0){
  Serial3.print("sys_volt.txt=\"");
  Serial3.print(v);
  Serial3.print("\"");
  Serial3.write(0xff);
  Serial3.write(0xff);
  Serial3.write(0xff);
}
delay(1000);

Serial3.print("out1_curr.txt=\"");
Serial3.print("reset");
Serial3.print("\"");
Serial3.write(0xff);
Serial3.write(0xff);
Serial3.write(0xff);

Serial3.print("sys_volt.txt=\"");
Serial3.print("reset");
Serial3.print("\"");
Serial3.write(0xff);
Serial3.write(0xff);
Serial3.write(0xff);
delay(1000);
}


Any help would be appreciated, and I apologize in advance if you have a hard time understanding my issue. Thanks!

wildbill

Which Nextion library are you using? I took a look at this one: https://github.com/itead/ITEADLIB_Arduino_Nextion But your code doesn't look anything like their examples.

crizangel

Which Nextion library are you using? I took a look at this one: https://github.com/itead/ITEADLIB_Arduino_Nextion But your code doesn't look anything like their examples.
I've had success with sending data via the method above, it's basically sending "textbox.txt="Example"", and the three 0xff to the Nextion, which it interprets and changes the text within the specified textbox.

I'm currently trying out other libraries because I found in my research that the Nextion-supplied library is garbage, at best.

Go Up