Start a new topic

Nextion Libraries error on Wemos D1

This is my first time to learning Arduino, and try Nextion Display to make more interactive things. But there much problem to solve, while start isntalling aplication, find libraries and examples. 


At begining learn, understanding how its work and try to compiling an example, i was found many problem errors. 


Please tell me where is causes errors problem. My instalation setup, libraries needed or the other causes.


This is a program was errors when compiling :


/**

 * @example CompSlider.ino

 *

 * @par How to Use

 * Show how to use API of class NexSlider.

 *

 * @author Wu Pengfei (email:<pengfei.wu@itead.cc>)

 * @date 2015/8/11

 * @copyright

 * Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n

 * This program is free software; you can redistribute it and/or

 * modify it under the terms of the GNU General Public License as

 * published by the Free Software Foundation; either version 2 of

 * the License, or (at your option) any later version.

 */

 

#include "Nextion.h"

NexText t0 = NexText(0, 2, "t0");

NexSlider h0 = NexSlider(0, 1, "h0");

NexTouch *nex_listen_list[] =

{

    &h0,

    NULL

};

void h0PopCallback(void *ptr)

{

    uint32_t number = 0;

    char temp[10] = {0};

   

    dbSerialPrintln("h0PopCallback");

    h0.getValue(&number);

    utoa(number, temp, 10);

    t0.setText(temp);

}

void setup(void)

{

    nexInit();

    h0.attachPop(h0PopCallback);

    dbSerialPrintln("setup done");

}

void loop(void)

{

    nexLoop(nex_listen_list);

}



And this is errors message :


Arduino: 1.8.1 (Windows XP), Board: "WeMos D1 R2 & mini, 80 MHz, 921600, 4M (1M SPIFFS)"

In file included from C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.h:18:0,

                 from C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp:15:

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp: In function 'bool recvRetNumber(uint32_t*, uint32_t)':

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp:55:5: note: in expansion of macro 'nexSerial'

     nexSerial.setTimeout(timeout);

     ^

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp: In function 'uint16_t recvRetString(char*, uint16_t, uint32_t)':

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp:114:16: note: in expansion of macro 'nexSerial'

         while (nexSerial.available())

                ^

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp: In function 'void sendCommand(const char*)':

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp:166:12: note: in expansion of macro 'nexSerial'

     while (nexSerial.available())

            ^

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp:171:5: note: in expansion of macro 'nexSerial'

     nexSerial.print(cmd);

     ^

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp: In function 'bool recvRetCommandFinished(uint32_t)':

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp:192:5: note: in expansion of macro 'nexSerial'

     nexSerial.setTimeout(timeout);

     ^

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp: In function 'bool nexInit()':

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp:226:5: note: in expansion of macro 'nexSerial'

     nexSerial.begin(9600);

     ^

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp: In function 'void nexLoop(NexTouch**)':

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

C:\Documents and Settings\Me\My Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-0.7.0\NexHardware.cpp:242:12: note: in expansion of macro 'nexSerial'

     while (nexSerial.available() > 0)

            ^

exit status 1

Error compiling for board WeMos D1 R2 & mini.

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.


bmp
1 Comment

Straight up answer?


You state you are beginning to learn.

- but not only Nextion must you learn

- you must learn you microprocessor WeMos D1 R2 & mini

- you must learn your Arduino Compiler

- you must learn your Arduino IDE

- you must learn your programming Language Arduino C++.


The last or bottom errors are many times symptom of first error.

- showing last does nothing, has no meaning without first at top.

So picture means nothing.


#define nexSerial Serial2

A #define means swap ... search Arduino Reference for #define

- so every spot in code where nexSerial is will be swapped out

  before compile with Serial2


Two lines above this contains ITEADLIB_Arduino_Nextion-0.7.0\NexConfig.h:37:19:

This is where start of your error can be found

 - NexConfig.h file  on line 37, 19 characters in from beginning of line


So your Please tell me where is causes errors problem

- I believe your compiler has already done so.

Most likely cause of such Error comes in looking and reading

Does your WeMos D1 R2 & mini even have a Serial2

 - Look in Microprocessor Manual for WeMos D1 R2 & mini

 - Search Arduino Reference for Serial explanation

 - Search WeMos D1 R2 & mini to learn about your microprocessor

But root cause is not Nextion related

Login or Signup to post a comment