Introduction: Nextion Using SoftwareSerial (Arduino)

About: I am a semiconductor engineer. I do a lot projects as a hobby, such as robotics, programming, microcontroller, 3D printing, CAD modeling, and CNC.

The original Nextion Arduino library requires hardware serial. I will show you how to use the Arduino SoftwareSerial instead. This is handy for troubleshooting.

Supplies

  1. An Arduino board
  2. A Nextion touchscreen

Step 1: Modify Nextion Arduino Library

  1. Find the location of the EasyNextionLibrary folder.
  2. Open src/EasyNextionLibrary.h file, inside your Arduino libraries folder.
  3. Add the following line on the top of the file:
  4. #include <SoftwareSerial.h>
  5. Replace all of "HardwareSerial" by "SoftwareSerial
  6. Save the file.
  7. Open src/EasyNextionLibrary.cpp file
  8. Replace all of "HardwareSerial" by "SoftwareSerial
  9. Save the file

Step 2: Arduino Sketch

  1. On the top of an Arduino Sketch file, add the following lines:

#include "EasyNextionLibrary.h" 

SoftwareSerial myserial(8,9);  // 8 goes to Nextion TX, 9 goes to Nextion RX

EasyNex myNex(myserial);  


The remaining of your code are the same as when you use the HardwareSerial. That's it and enjoy. Now you can use the HardwareSerial for debugging.