Install <Nextion.h>

Hi all

How to
#include <Nextion.h>

src\Dashboard.cpp:5:21: fatal error: Nextion.h: No such file or directory

I believe i need this file to send commands to the Nextion display.

regards Wil

To save you the hassle of googling how to install library on platformio, add lib_deps = Nextion to the platformio.ini file in the main project folder.

Thank you pfeerick , it did install perfectly.

now it is erroring about Serial2 not being installed

In file included from .pio\libdeps\nano\Nextion_ID37\NexHardware.h:18:0,
from .pio\libdeps\nano\Nextion_ID37\NexHardware.cpp:15:
.pio\libdeps\nano\Nextion_ID37\NexHardware.cpp: In function ‘bool recvRetNumber(uint32_t*, uint32_t)’:
.pio\libdeps\nano\Nextion_ID37\NexConfig.h:37:19: error: ‘Serial2’ was not declared in this scope
#define nexSerial Serial2

You are compiling for a nano which does not have a Serial2, it only has one hardware serial called Serial. You might want to use this hardware serial or a SoftwareSerial. Configuration is then done via editing a configuration file where the library was downloaded (`.pio\libdeps..´), see Segnix/libraries/itead_Nextion at master · itead/Segnix · GitHub

I probably have to change according to the configuration

#define nexSerial Serial2  ---> #define nexSerial Serialxxx

xxx what is ??? ( naked woman ?)

Still stuck here

Yeah so with which Serial do you connect the Nextion then? Hardware serial on D0,D1 or do you want a software serial? I asked the same question above.

Have done some Arduino IDE coding before . Platformio is all new to me and rather confusing.

Yes Hardware serial D0,D1 used for Nextion display

Then it’s just as in the references website which also leads to a blog post:

/* comment out the debug serial enable */ 
/* set nextion serial communication port to Serial, which is D0,D1. */
#define nexSerial Serial 

Note that the hardware serial port is also used for flashing. So if you want to flash a new firmware, the Nextion’s connection to D0,D1 must be temporary pulled out and reconnected after flashing (and then reset)

I dont have a #define DEBUG_SERIAL_ENABLE to comment out.

These my declarations below

#include <Arduino.h>

#include <SPI.h>

#include <wire.h>

#include <Nextion.h>

#define nexSerial Serial

//#include <SoftwareSerial.h>

//SoftwareSerial mySerial(2, 3); // RX, TX

All these modifications need to be done in the NexConfig.h file. For these kind of modifications (if you want it to be persistent and reproducable accross computers) you will however want to have a local copy of the library with the correct configuration. So you should download and extract GitHub - itead/ITEADLIB_Arduino_Nextion (direct), put it in the lib/ folder of your project, then modify the config file from above, then delete .pio\ folder inside your project because it contains the stock version of the library, then recompile.


Tx will try:grinning:

:heart: I’m getting no more errors. Thank you
It would probably be better if I change from hard to soft serial. Need to figure that one out.

May I ask how to delete the pio\folder ??

Right click on the .pio folder in the file explorer, and Delete is down the bottom :wink:

1 Like

Me dummy, thanx :blush:

This is maby a little of platformio topic.

Have arduino Nano with Nextion display
the gauges work fine, when turning the potentiometers
but the picture ( oil light) does not get deleted ( hiden) when commanded to do so.

  if (oil == 1) 
    Serial.print("vis p0,0");         

Think it still has something to do with the serial communication .

This seems to be a rather specific question for your project and without knowing the full firmware or what’s running on the Nextion we are unable to help here apparently. All I see in the code is a direct print and write to the serial where the Nextion is connected, I’m unfamiliar with the commands. Maybe you can get help at Issues · itead/ITEADLIB_Arduino_Nextion · GitHub?

1 Like