Nextion Using SoftwareSerial (Arduino)

by suriono in Circuits > Arduino

1596 Views, 3 Favorites, 0 Comments

Nextion Using SoftwareSerial (Arduino)

nextion.jpg

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

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

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.