Start a new topic

No response from Nextion

Arduino Mega and Nextion 2.8.


No response after tft with button uploaded to the display.


-I Uploaded tft

-vscope set to global

-Send component ID is selected.


-------Arduino Sketch--------


#include <Nextion.h>

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

void setup() {
  Serial2.begin(9600);
  myNextion.init();

}

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

 
}



All I am currently trying to do at this point is having the serial monitor register anything



Hi Anthony,

Tell something more!

nextion give the model number, eg NX3224T028 or TJC3224T028

on which pins you've connected Nextion?  

have already tested a sample of Itead / nextion?

this libary you use someone changed  (I'm not saying this is bad!)

NX3224T028

GND - GND

5v - 5v

Tx - Rx2 pin17

Rx - Tx2 pin16

 none of the sample nextion files work. this is the Receivemessages sample.

I have tried 2 .h files. both the standard file and a modifies file removing the Software serial.


Thank you for getting back to me...

Hi Antony


I assume you gnd and the + 5V comes from the same power supply.

What I miss in your sketch,

the allocation of a text field! on your Nextion

load the following sketch and create a screen with a text field t0

put your tx and rx pins on 2 & 3 and see what happens. 

/*
Ricardo Mena C
ricardo@crcibernetica.com
http://crcibernetica.com
  This example code is in public domain
*/

#include <SoftwareSerial.h>
#include <Nextion.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

void setup() {
  Serial.begin(9600);
  myNextion.init();

}

void loop() {

  myNextion.setComponentText("t0", "Hello");
  delay(1000);
  int value = 1234;
  myNextion.setComponentText("t0", String(value));
  delay(1000);
  
}

 (Source: https://github.com/bborncr/nextion)

Sorry Itead!    I use Yours :-) 


greeting Vic

I just tried everything on an a friends UNO and it seams to be working, so the problem is the use of my MEGA with this code.



Hi Antthony,


Test your mega

change  line 12 & 13 to XX &YY

with a LED

 

/* Blink without Delay 2 leds en i2c display
 This example code is in the public domain.
 http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
 edited by DuikerVic
 */
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
 LiquidCrystal_I2C lcd(0x27,16, 2);
 
 
// constants won't change. Used here to set a pin number :
const int ledPin2 =  12;      // the number of the LED pin
const int ledPin3 =  13; 
// Variables will change :
int ledState2 = LOW; 
int ledState3 = LOW;    // ledState used to set the LED
int backlightState = LOW;

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis2 = 0;
unsigned long previousMillis3 = 0;   // will store last time LED was updated
unsigned long previousMillis4 = 0;

// constants won't change :
const long interval2 = 1000;     // interval at which to blink (milliseconds)
const long interval3 = 500;
const long interval4 = 200;

void setup() {
  lcd.begin();
  lcd.backlight();   
  lcd.print("blinkwithout delay");
  lcd.setCursor(0, 1);
  lcd.print("2 leds/i2c display");
  
  // set the digital pin as output:
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
}

void loop()
{
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the
  // difference between the current time and last time you blinked
  // the LED is bigger than the interval at which you want to
  // blink the LED.
  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis2 >= interval2) {
    // save the last time you blinked the LED 
    previousMillis2 = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState2 == LOW)
      ledState2 = HIGH;
    else
      ledState2 = LOW;
      
      unsigned long currentMillis2 = millis();
  }
  if(currentMillis - previousMillis3 >= interval3) {
    // save the last time you blinked the LED 
    previousMillis3 = currentMillis;   

      // if the LED is off turn it on and vice-versa:
    if (ledState3 == LOW)
      ledState3 = HIGH;
    else
      ledState3 = LOW;
 unsigned long currentMillis3 = millis();
    // set the LED with the ledState of the variable:
  }
 //===
if(currentMillis - previousMillis4 >= interval4) {
    // save the last time you blinked the LED 
    previousMillis4 = currentMillis;   

      // if the LED is off turn it on and vice-versa:
    if (backlightState == LOW)
      backlightState = HIGH;
    else
      backlightState = LOW;
 unsigned long currentMillis4 = millis();
    // set the LED with the ledState of the variable:
    digitalWrite(ledPin2, ledState2);
    digitalWrite(ledPin3, ledState3);    
    if(backlightState == HIGH)  lcd.backlight();
    else lcd.noBacklight();
  } 
  }


 

I can get the LiquidCrystal_I2C lcd to work just fine. The issue is with getting the serial setup from the nextion to the Arduino MEGA. I can get everything to work just fine on the UNO.

I got the screen to work by...


SoftwareSerial nextion(10, 11);// Nextion TX to pin 10 and RX to pin 11 of Arduino


software serial can not be ported to hardware serial port. logical !


good luck with your project


Vic

Hi Everybody!


I need help! 


Here is my sourceCode:


  

/*

Ricardo Mena C
ricardo@crcibernetica.com
http://crcibernetica.com

  This example code is in public domain

*/

#include <SoftwareSerial.h>
#include <Nextion.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

void setup() {
  Serial.begin(9600);
  myNextion.init();

}

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

  
}

 And the Serial Monitor Tuch Event not jet only five caracters but i don't copy that. "q/square/˙˙˙"


Whats the Problem Help please


Thanks MRD


I use Arduino UNO

It works with pins 10,11 but only sometimes on Mega


Login or Signup to post a comment