Start a new topic

Arduino Mega

Hiya,

I've had no issues connecting the Nextion to my Arduino Uno using pins 2 and 3; but when I swap the board and use exactly the same program / pins on my Arduino Mega - it doesn't work.... it doesn't seem to communicate at all. What am I doing wrong?

Thank you.208


so far as i know, i didn't try it yet my self bud you most cross the tx and rx wires between the

nextion and arduino mega, 

i can't find the wringht topic about this, sorry


1 person likes this

Well, I've kind of gotten somewhere.
It goes through the start of my program and changes the text on my screen; but the Nextion doesn't seem to send any signals back to the Arduino Mega.... I've included my code to see if anyone can help.

 

#include <SoftwareSerial.h>
#include <Nextion.h>
#include <Wire.h>

SoftwareSerial nextion(2, 3);// Nextion TX to pin 2 and RX to pin 3 of Arduino

Nextion myNextion(nextion, 9600); //create a Nextion object named myNextion using the nextion serial port @ 9600bps

boolean button1State;
boolean button2State;
boolean button3State;
boolean button4State;
boolean button5State;
boolean button6State;
boolean button7State;
boolean button8State;
boolean button9State;
boolean button10State;
boolean button11State;


String line1 = "Line 1....";
String line2 = "Line 2....";
String line3 = "Line 3....";
String line4 = "Line 4....";
String line5 = "Line 5....";
String line6 = "Line 6....";

void setup() {
  Serial.begin(9600);
  myNextion.init();
  Wire.begin();
  myNextion.setComponentText("t0", line1);
  delay(2000);
  myNextion.setComponentText("t1", line2);
  delay(2000);
  myNextion.setComponentText("t2", line3);
  delay(2000);
}

void loop() {
  String message = myNextion.listen(); //check for message
  if (message != "") { // if a message is received...
    Serial.println(message); //...print it out
  }
  myNextion.setComponentText("t3", line4);

  // Locomotive Direction
  if ( (message == "65 0 1 1 ffff ffff ffff") && (button1State == true) ) {
    myNextion.sendCommand("b0.pic=4"); //set "b0" image to 2
    myNextion.sendCommand("ref b0"); //refresh
    button1State = false;
    line6 = "Forward Direction";
    Updatescreen();
  }
  else if ( (message == "65 0 1 1 ffff ffff ffff") && (button1State == false) ) {
    myNextion.sendCommand("b0.pic=5");
    myNextion.sendCommand("ref b0");
    button1State = true;
    line6 = "Reverse Direction";
    Updatescreen();
  }

 

Updated; but still the same issues.
I know use TX2, RX2 as suggested in other posts; but it still doesn't seem to send signals back to the Arduino.


 

#include <SoftwareSerial.h>
#include <Nextion.h>
#include <Wire.h>

SoftwareSerial nextion(16, 17);// Nextion TX to pin 2 and RX to pin 3 of Arduino
// SoftwareSerial nextion(2, 3);// Nextion TX to pin 2 and RX to pin 3 of Arduino

Nextion myNextion(nextion, 9600); //create a Nextion object named myNextion using the nextion serial port @ 9600bps

boolean button1State;
boolean button2State;
boolean button3State;
boolean button4State;
boolean button5State;
boolean button6State;
boolean button7State;
boolean button8State;
boolean button9State;
boolean button10State;
boolean button11State;

String line1 = "Line 1....";
String line2 = "Line 2....";

void setup() {
  Serial.begin(9600);
  myNextion.init();
  Wire.begin();
  myNextion.setComponentText("t0", line1);
  delay(1000);
  myNextion.setComponentText("t1", line2);
  delay(1000);
}

void loop() {
  String message = myNextion.listen(); //check for message
  if (message != "") { // if a message is received...
    Serial.println(message); //...print it out
  }
  myNextion.setComponentText("t3", line4);

  // Locomotive Direction
  if ( (message == "65 0 1 1 ffff ffff ffff") && (button1State == true) ) {
    myNextion.sendCommand("b0.pic=4"); //set "b0" image to 2
    myNextion.sendCommand("ref b0"); //refresh
    button1State = false;
    line6 = "Forward Direction";
    Updatescreen();
  }
  else if ( (message == "65 0 1 1 ffff ffff ffff") && (button1State == false) ) {
    myNextion.sendCommand("b0.pic=5");
    myNextion.sendCommand("ref b0");
    button1State = true;
    line6 = "Reverse Direction";
    Updatescreen();
  }

 

Now I'm starting to get some comms, but this is what I'm getting....

....I must be doing something wrong?!?!?

 

ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ
ÿÿÿ

 

if found the topic where the say to cross wire the rx and the tx wires

http://support.iteadstudio.com/support/discussions/topics/11000002523

Sadly I still have the same problem.
I've been through everything I've found..... argh!

hmm, strange. you did cross the tx and rx? and if you don't cross the tx and rx??

I tried crossing them, uncrossing them, different pins.... I tried everything I could think of.
It's very strange!

i'll hope that someone off itead something can do or tell us for this problem

Me too, I've submitted a ticket and I'll post here to let everyone know how it goes.


1 person likes this

My concern is now that I've put it back onto the Uno and it does the same thing; the same garbled responses but normal transmissions.
Could there be a corruption somewhere? I've uploaded a 'blank' project to the Nextion, and then a simple one before going back to where I am now and it's always the same issue :/


if i wire up my nextion to my arduino mega 2560, i'll let you know


1 person likes this

can someone who knows Arduino explain if the above output is character based or

outputing numeric bytes.  Makes a big difference.  Generally chars 0 to 31 and control chars and inexcessible, and 255 0xFF is another such non-printable char.

dual-state button press component id is not "65 0 1 1 ffff ffff ffff"

but rather 0x65 0x00 0x01 0x01 0xff 0xff 0xff  -- component Touch Event Page 0 ID 1 Pressed 1
IF Text characters that is "e______" where the 6 characters following e are non printable.

IF incoming byte translated into 2-HexChars per byte it would look like "65000101FFFFFF"

IF message is each byte into decimals the sequence would be  101,0,1,1,255,255,255


Instead you are looking for a Text string of "65 0 1 1 ffff ffff ffff" - you can't mix in the same sequence, it can either be hex, charstring, or numeric?  Am I on to something??

Login or Signup to post a comment