Nextion screen problem with DUE

Here's the link to the Nextion library. It uses software serial, so you'll need make some modifications to use hardware serial (refer to the link). Not sure if there would be other software compatibility issues.

Your touchscreen is 5V so you'll need to level shift or voltage divide to 3.3V for the Due's RX input. I think the Due's TX could be directly connected to the touchscreen. Check the touchscreen datasheet to see if 3.3V is high enough for the touchscreen to recognize this as high.

Hi

thanks for the reply.

The code I sent you above is working pretty well on arduino Mega using HARDWARE SERIAL.

The MCU on the back of the Nextion is a 3.3V chip (STM32F030C8T6 powered after the 3.3V regulator) so this is why I dont understand why it does not work.

The only difference between the MEGA and the DUE I can see on the serial pins is that on the MEGA all serial pins are 5V TTL and on the DUE pins 0 and 1 are 5V and the other 3 are 3V TTL.

Just noticed you should be using Serial2 for pins 18 and 19...

Nextion myNextion(Serial2, 9600); //TOUCH A ---> TX to pin 18 and RX to pin 19

Note that on the Due, pins 0 and 1 are 3.3V ... pin0 (RX0) has already been level shifted to 3.3V using a single bus buffer.

EDIT: Oops ... should be

Nextion myNextion(Serial1, 9600); //TOUCH A ---> TX to pin 18 and RX to pin 19

dlloyd:
Just noticed you should be using Serial2 for pins 18 and 19...

Nextion myNextion(Serial2, 9600); //TOUCH A ---> TX to pin 18 and RX to pin 19

Actually that is only comment because I am using 2 touch screens one on SERIAL1 and the other on SERIAL2

Note that on the Due, pins 0 and 1 are 3.3V ... pin0 (RX0) has already been level shifted to 3.3V using a single bus buffer.

This is why I dont understand why it does not work. I only get "e ÿÿÿ" instead of for exemple 65 0 4 1 ffff ffff ffff

On pins 0 and 1 I get this rubbish e ÿÿÿ and on the other serials nothing at all, the TX/RX LEDs on the DUE dont even blink when I press a button on the touchscreen.

Any other ideas?

OK, I wouldn't use pins 0 and 1 with a touchscreen as that's used for programming. Here's the hardware serial port pinouts:

Name      RX  SAM3X Pin    TX  SAM3X Pin   Description
Serial    RX0  URXD   0    TX0  UTXD   1   Connected to ATmega16U2, serial programming, serial monitor
Serial1   RX1  RXD0   19   TX1  TXD0  18   USART0, Touchscreen A?
Serial2   RX2  RXD1   17   TX2  TXD1  16   USART1, Touchscreen B?
-------   ---  RXD2   52   ---  TXD2  65   USART2, UNSUPPORTED
Serial3   RX3  RXD3   15   TX3  TXD3  14   USART3, ?
SerialUSB ---  ----   --   ---  ----  --   Native USB Port

Its a bit convoluted ... please re-check your connections?

Connections are exactly the same as in Arduino MEGA. I ordered another DUE because I do not find anything that could not make it work...

I am still thinking about the touchscreen properties, check the attachment pse.

Ok, so some eveolution here.

I have another device which comunicates in RS232 and so I used a MAX232 to interface between my device and the DUE and it works, I get the respective data in the monitor using the DUE.

So why the hell the nextion touch would not work???

I am still struggling with arduino due serial coms... I sent an email to ITEAD the fabricant of NEXTION displays, and basically they said we tried with UNO and MEGA and we dont care about DUE.

If anyone has any thoughts about this would great.... how to use SERIAL comm with nextion touch display.

Thanks

Hi, any solution? I have same problem - programing Nextion with hardware serial trough Mega works fine, but with Due after 4 sek connection is lost

Guys, just trying to figure out this problem, I've got the messages from the Nextion to reach the arduino through Hardware serial 2 by doing the following:

Check the file NexConfig.h for the configuration:

#define nexSerial Serial2

Removing the mention to SoftwareSerial from the NexUpload.c file;
Adding

#include"SD.h"

Including to the Setup:
nexSerial.begin(9600);

Yeah, it seems that the messages to and from the Nextion are at 9600 bps

Still will try to update the Nextion variables, but the buttons are being captured successfully.

Regards,

Luciano.

Variables getting updated, but still no callbacks being triggered (only the debug message returns were shown, such as [537332668:0,1,b_sistemp]) and error messages both ways:

recvRetCommandFinished err

Will keep working.

Regards,

Luciano

The devil is on the details. It turns out that I was missing the nexInit() on the Setup. No need to add nexSerial.begin(9600);. It is all made by the nexInit(). Moreover, the Serial for debugging is initialized as 9600bps. No need also for Serial.begin(9600).

Now everything is working apart from the button instances. Even the dual state buttons are triggering the callbacks, but I am missing some detail for the button instances.

If anyone can help, I have done the following:

  1. Created the button instance:
NexButton       b_sistemp       = NexButton(0, 1, "b_sistemp");
  1. Added it to the listen list:
NexTouch *nex_listen_list[] = 
{
    &b_sistemp,
    NULL
};
  1. Registered the callback on the Setup():
b_sistemp.attachPop(b_sistempPopCallback, &b_sistemp);
  1. Created a callback for the button:
void b_sistempPopCallback(void *ptr)
{
    NexButton *btn = (NexButton *)ptr;
    dbSerialPrintln("b_sistempPopCallback");
    dbSerialPrint("ptr=");
    dbSerialPrintln((uint32_t)ptr);

    page_number = 2; //Sistemp Page
    Serial.println(F("Sistemp button was pressed"));
}

Edited: The debug serial gives me the button details, but the callback is not triggered:

[537332668:0,1,b_sistemp]

Regards,

Luciano

Changed the Nextion event to be triggered on the button release and now everything works fine! No problems so far. Hopefully I can finish this project with no extra issues.

Hi Do you have a copy of the sketch/project that is working with just one botton on it, so i can see what is going on.

thanks

lspaula:
Changed the Nextion event to be triggered on the button release and now everything works fine! No problems so far. Hopefully I can finish this project with no extra issues.

I'm also very interested! It would be very helpful! Could you please post the Nextion part of your code?

Thank you very much in advance!

Kind regards

lspaula:
Changed the Nextion event to be triggered on the button release and now everything works fine! No problems so far. Hopefully I can finish this project with no extra issues.

I was wondering if you did any 5V to 3.3V level shifting between the Nextion screen and the DUE serial port 2 or did you wire then direct?
Thanks

Has anyone come up with a successful solution to use the Nextions with the Due?

I've tried several times to move from the Mega to the Due for more memory. Everything works, except for the Nextion. I've tried the suggestions about the SD.h versus the SoftwareSerial.h...

I found this 30 step tutorial from Nextion to bring their screen to life with a DUE :o :

Looks like once the library is modified for the DUE, you can't use it for anything else.

I'll still give it a try as the Mega is too short on memory for my project.