Nextion Using SoftwareSerial (Arduino)
by suriono in Circuits > Arduino
1939 Views, 3 Favorites, 0 Comments
Nextion Using SoftwareSerial (Arduino)
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
- An Arduino board
- A Nextion touchscreen
Modify Nextion Arduino Library
- Find the location of the EasyNextionLibrary folder.
- Open src/EasyNextionLibrary.h file, inside your Arduino libraries folder.
- Add the following line on the top of the file:
- #include <SoftwareSerial.h>
- Replace all of "HardwareSerial" by "SoftwareSerial
- Save the file.
- Open src/EasyNextionLibrary.cpp file
- Replace all of "HardwareSerial" by "SoftwareSerial
- Save the file
Arduino Sketch
- 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.