Tamer Savaşcı
Published © GPL3+

Nextion LCD communicate with Arduino UNO

You can communicate your Nextion LCD with your Arduino UNO by Software serial ... a liitle tricky but not much :)

BeginnerProtip1 hour54,782
Nextion LCD communicate with Arduino UNO

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Nextion NX8048T070 - Generic 7.0" HMI TFT LCD Touch Display
Itead Nextion NX8048T070 - Generic 7.0" HMI TFT LCD Touch Display
×1
USB to TTL adapter
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Itead Nextion Editor

Story

Read more

Schematics

nextion

nextion part

Code

Arduino part

Arduino
Arduino part of the code
#include "Nextion.h"
SoftwareSerial HMISerial(10, 11);

NexText t0 = NexText(0, 2, "t0");
NexSlider h0 = NexSlider(0, 1, "h0");
NexGauge z0  = NexGauge(0, 3, "z0");
NexDSButton bt0 = NexDSButton(0, 5, "bt0");


NexTouch *nex_listen_list[] = {&h0, &bt0, NULL};

void bt0PopCallback(void *ptr)
{
  uint32_t dual_state;
  NexDSButton *btn = (NexDSButton *)ptr;
  dbSerialPrintln("b0PopCallback");
  dbSerialPrint("ptr=");
  dbSerialPrintln((uint32_t)ptr);
  bt0.getValue(&dual_state);
  
  if (dual_state)               
  {
    digitalWrite(13, HIGH);           // if my dual state buton is pressed
  }
  else
  {
    digitalWrite(13, LOW);            // if not
  }

}
void h0PopCallback(void *ptr)
{
  int numberx = 0;
  int gosterge = 0;
  uint32_t number = 0;
  char temp[10] = {0};
  dbSerialPrintln("h0PopCallback");
  h0.getValue(&number);
  utoa(number, temp, 10);
  t0.setText(temp);
  numberx = number;
  gosterge = map(numberx, 0, 100, 0, 180);
  z0.setValue(gosterge);
}

void setup(void)
{
  pinMode(13, OUTPUT);
  nexInit();
  h0.attachPop(h0PopCallback);
  bt0.attachPop(bt0PopCallback, &bt0);
  dbSerialPrintln("setup done");
}

void loop(void)
{
  nexLoop(nex_listen_list);
}

Credits

Tamer Savaşcı

Tamer Savaşcı

3 projects • 16 followers
Curious chemist..

Comments