SoftwareSerial not working with Arduino Giga

Hi all, we try to develop a project by using Arduino Giga R1 WiFi. According to our project, we needed to add a screen Nextion (NX8048P050-011). According to tutorials, we have some options for this as using Nextion.h and just SoftwareSerial.h. Our problem is while we download and include related SoftwareSerial library (GitHub - itead/ITEADLIB_Arduino_Nextion), we have an error like this : #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors

How can we solve this problem ? Or you can advice another solution and/or library ?

Why are you using software serial when you have hardware serial?

Sorry, we have new in these topic... Could you give more details ? Hardware Serial ? According to youtube videos and other source, always SoftwareSerial library is being used...

I don't go to YT much for factual information - maybe the videos only relate to Arduino platforms that don't have spare hardware serial ports.

By the way I checked again, just SoftwareSerial is used for Nextion screens. I'm waiting solutions in this way

What does that mean?

The display doesn't care whether the port is soft or hard just as long as the timing is correct.

Well, present your solution ?

Use a spare hardware serial port.

I may have already mentioned this

Familiarize yourself with the goods.
Pins 17 - 24,
See page 15 of 21 (15/21),
ABX00063-datasheet.pdf (arduino.cc)

1 Like

...early
Familiarize yourself with the goods often.

Hi again, thank you so much for your answer. Yes, i read the source and you are right... The notes that i learned, Arduino giga uses 4 different Serial communications like this :

The pins used for UART on the GIGA R1 are the following:

  • RX0 - D0
  • TX0 - D1
  • RX1 - D19
  • TX1 - D18
  • RX2 - 17
  • TX2 - 16
  • RX3 - 15
  • TX3 - 14
Serial.begin(9600); //initialize serial communication over USB
Serial1.begin(9600); //initialize serial communication on RX0/TX0
Serial2.begin(9600); //initialize serial communication on RX1/TX1
Serial3.begin(9600); //initialize serial communication on RX2/TX2
Serial4.begin(9600); //initialize serial communication on RX3/TX3

For basic tests, i tried to use Serial4 (RX3: 15 & TX3:14). I wrote the basic code like this for sending simple command to Nextion :

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial4.begin(9600);
  while(!Serial) continue;
  while(!Serial4) continue;

  Serial.print("Serial Start");

  Serial4.print("welcome_scr.ws_info_txtbox.txt=\"HELLO\"");
  Serial4.write(0xff);
  Serial4.write(0xff);
  Serial4.write(0xff);

}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("COMMAND SEND");
  delay(1000);
  Serial4.print("welcome_scr.ws_info_txtbox.txt=\"HELLO\"");
  Serial4.write(0xff);
  Serial4.write(0xff);
  Serial4.write(0xff);

}

But nothing was sent to Nextion device (I just want to update textbox value for example).

Where i do wrong :frowning: ? Baudrate etc etc. i tried everything.

Thanks a lot for your attentions and helps... (By the way, i am new in these devices, please forgive me for asking non professional questions...)

In the end, I solved the problem now everything is so good :slight_smile: thank you so much for enlighten me, i m so thankful :slight_smile:

For the benefit of others please describe what was wrong and what your solution was

Of course,

I am describing the solution for Arduino Giga and like Arduino Giga devices...

According to my last comment, check if your device has single Serial Communication (just one RX and TX port) or more Serial Communication ports as I wrote that referenced in Arduino Giga datasheet.

Then for basic level developer, please check cables are on right ports. For instance, for Arduino Giga, Nextion's red cable is on +5V, black cable is on GND (you may want to connect them for power on a USB cable 5V 1A), yellow cable is on RX and blue cable is on TX.

Again according to my device setup, I selected Serial1 connection. You can use other Serial2, Serial3 and Serial4. Bu then please do not forget to connect cables on related pins. Check these reference again :

The pins used for UART on the GIGA R1 are the following:

  • RX0 - D0
  • TX0 - D1
  • RX1 - D19
  • TX1 - D18
  • RX2 - 17
  • TX2 - 16
  • RX3 - 15
  • TX3 - 14
Serial.begin(9600); //initialize serial communication over USB
Serial1.begin(9600); //initialize serial communication on RX0/TX0
Serial2.begin(9600); //initialize serial communication on RX1/TX1
Serial3.begin(9600); //initialize serial communication on RX2/TX2
Serial4.begin(9600); //initialize serial communication on RX3/TX3

If you want any help, I will be happy for help. Thanks again @runaway_pancake @UKHeliBob

For the benefit of future users, please post the code that worked with the Nextion.

Of course :

void setup() {
  // put your setup code here, to run once:
  Serial1.begin(9600); //Set the baudrate for Nextion
  while(!Serial1) continue;
}

void loop() {
  // put your main code here, to run repeatedly:

  //Send variable value or static value to the target object on related scene
  Serial1.print("test_scene.test_textbox.txt=\"HELLO WORLD\"");
  //The following 0xff is for finalizing for each command on RX
  Serial1.write(0xff);
  Serial1.write(0xff);
  Serial1.write(0xff);
}

By the way a little question : I want to wrap text or divide text into two lines such as Hello\rWorld.

The \r is not working : Example : Serial1.print("test_scene.test_textbox.txt="HELLO\rWORLD"");

Could you suggest anything ?

\r, which stands for ASCII Carriage Return, must be interpreted by the target device.

What do the Nextion docs say about newline characters?

The offical source says like this :

Character escaping is performed using two text chars: \r creates 2 bytes 0x0D 0x0A, \” 0x22 and \ for 0x5C

And

Supported is \r hex 0x0D 0x0A, \” hex 0x22, \ hex 0x5C,
t0.txt=”\r”

What my fault in this ?

//Send variable value or static value to the target object on related scene
  Serial1.print("test_scene.test_textbox.txt=\"HELLO\rWORLD\"");
  //The following 0xff is for finalizing for each command on RX
  Serial1.write(0xff);
  Serial1.write(0xff);
  Serial1.write(0xff);

What "official source"?

In Arduino, use \r to represent a single non-printing character 0x0D (ASCII carriage return) and \n to represent a single 0x0A (ASCII line feed).

Or use Serial.write() to send arbitrary binary byte values, either single or multiple, e.g.

Serial.write(0x0D); //send CR

You could try something like

Serial.print("Hello");
Serial.write(0x0D);
Serial.write(0x0A);
Serial.print("World");