Nextion display project doesn't work

sorry, what type of Arduino did you used?

Dyspho:
Perry,

Thanks a lot for checking the infos regarding serial ports !

Ok, so here what happened today:

I tried your code and it didn't work.

Then I decided to write a more simple sketch where I only send data because the previous one, even if it was simple too, was a bit confusing with sending and receiving data + writing many things in the monitor.

So, on the Nextion I only put a text block (t0) with written "empty" in it.
With the sketch, on launch it would write "test" in this block instead.

/*

This code is based on the software serial example on Arduino's website
*/

#include <SoftwareSerial.h> //Include the library

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
 
  Serial.begin(57600); //open the serial port
  while (!Serial) { // wait for serial port to connect. Needed for native USB port only
  ;
  }

Serial.println("Serial On"); //Print this messages when the serial port is connected
  mySerial.begin(9600); // set the data rate for the SoftwareSerial port

}

void loop() { // run over and over

// Write "test" in the text box t0
  mySerial.print("t0.txt=""); // Changing the value of box n1
  mySerial.print("test");
  mySerial.print(""");
  mySerial.write(0xff);  // We always have to send this three lines after each command sent to the nextion display.
  mySerial.write(0xff);
  mySerial.write(0xff);

}




It actually DID work !

I don't know what's the difference with the previous one, but this one worked !
Maybe you were right all along about saying the numeric block were crap !

Thanks so much for the help !!

I am probably not done here yet thought haha
I will try to go back to the previous sketch and make it work.

PerryBebbington:
My pleasure! :slight_smile:

Do I have to read your new problem now....??? :confused:

#include <SoftwareSerial.h>
//#include "Nextion.h"
//#define mySerial Serial
SoftwareSerial mySerial(0,1);

void setup() {
//nexInit();
mySerial.begin(9600);
}

void loop() {
tinggi_m = (MAKS_TINGGI-durasi)/100;

mySerial.print("tTinggi.txt="");
mySerial.print(tinggi_m);
mySerial.print(""");
mySerial.write(0xff);
mySerial.write(0xff);
mySerial.write(0xff);

}

ignore other syntax, focus on syntax for nextion.
I think, I have correctly followed the example above. I use Arduino Uno.

but, it doesn't work. this makes me very confused.
Please, help me :frowning:

Hello
Welcome to the Arduino fora.
Before you do anything else please take a moment to read General guidance and
How to use this forum
Especially item #7 on posting code.

You are trying to use software serial on pins 0 and 1, these pins are already in use for the serial monitor, so that's never going to work. You need to use software serial with pins that are not being used anything else.

You have a variable tinggi_m, which you do not declare so the code will not compile.

You are trying to send the text to the display every time around loop(), which is far too often.