Start a new topic

How to debug on Arduino Uno

I have the Nextion display, been testing for a while.  Can upload from computer, design screens, etc...


I am ready to start testing the display with my Arduino uno board, and watched a video that explained, is not really possible unless I have a Mega 2560 board with 2 serial ports.


Is this still true?  Is there no work around for this? 


In short - this is not true, there are projects using uno, pic, esp8266, stm32 and other MCUs.


Serial is serial, so as long as you can program and control a serial line from your MCU back and forth with the Nextion, you'll be golden.  The Nextion Instruction Set contains basically what commands that you can send and what any of the expected responses should be.   It should also be noted that the print and printh commands can effectively allow the creative to implement their own full blown user defined protocol.


Happy Coding.

I will expand on this - there is only one Rx/Tx pair that can connect to the Nextion.  If you are limited to one serial, I guess there is no Arduino serial debug.  So many simply don't use the Arduino libraries and code directly for the serials.  The Nextion Debug simulator will help ensure your command and responses are correct before committing code to your uno.

I believe I understand.  Once the Nextion is hooked into Arduino, I can communicate via serial between the two devices.  At this point, I must use the serial port on Arduino to debug the communications between those two devices.  


If I  swap the rx/tx pins OUT from Nextion->Arduino, to Nextion->USB/SERIAL (on PC), I can debug the Nextion device using the Nextion editor program, and upload changes to the Nextion.


It's a task the change the pins, I can handle it.  I'm just the type of developer who likes to adjust everything, re-compile & upload very often - so that task of swapping the pins will get in the way.  Ideally I would just like to possibly debug and upload to the Nextion without a pin-swap.

Erich - I can't say I am familiar with the Arduino - so, I will try help where I can.

see thread  here : Nextion Display with Arduino Uno: How To


Their graphic shows using USB to upload and debug.

Arduino-Nextion.jpg


The thread also might have other clues you need.  -  Hope this helps


Patrick:


  Thanks for your help suggestion.  Here is the problem with that thread suggestion so far...


After I open "compnumber.ino" (which was downloaded from that thread)....  Arduino IDE compiler rejects the code, starting with "NexNumber" does not have a type.  This would be part of my struggle, as I was unclear how/where the updated Nextion libraries were, WHERE on my system there should be installed.


I went to Arduino IDE->Sketch->Include Library->Library manager, searched for Nextion.  IDE appeared to install:


"NeoNextion

Arduino library for the Nextion displays."


(error code copied from compiler--after a plethora of other warnings):

S:\Data\Arduino\Nextion\compNumber\compNumber\compNumber.ino: At global scope:

compNumber:61: error: 'NexNumber' does not name a type

 NexNumber n0 = NexNumber(0, 3, "n0");

 ^

compNumber:66: error: 'NexButton' does not name a type

 NexButton b0 = NexButton(0, 1, "b0");

 ^

compNumber:71: error: 'NexButton' does not name a type

 NexButton b1 = NexButton(0, 2, "b1");

 ^

compNumber:78: error: 'NexTouch' does not name a type

 NexTouch *nex_listen_list[] =

 ^

S:\Data\Arduino\Nextion\compNumber\compNumber\compNumber.ino: In function 'void n0PopCallback(void*)':

compNumber:92: error: 'n0' was not declared in this scope

     n0.setValue(50);

     ^

S:\Data\Arduino\Nextion\compNumber\compNumber\compNumber.ino: In function 'void b0PopCallback(void*)':

compNumber:105: error: 'n0' was not declared in this scope

     n0.getValue(&number);

     ^

S:\Data\Arduino\Nextion\compNumber\compNumber\compNumber.ino: In function 'void b1PopCallback(void*)':

compNumber:122: error: 'n0' was not declared in this scope

     n0.getValue(&number);

     ^

S:\Data\Arduino\Nextion\compNumber\compNumber\compNumber.ino: In function 'void setup()':

compNumber:132: error: 'nexInit' was not declared in this scope

     nexInit();

             ^

compNumber:137: error: 'n0' was not declared in this scope

     n0.attachPop(n0PopCallback);

     ^

compNumber:140: error: 'b0' was not declared in this scope

     b0.attachPop(b0PopCallback);

     ^

compNumber:143: error: 'b1' was not declared in this scope

     b1.attachPop(b1PopCallback);

     ^

S:\Data\Arduino\Nextion\compNumber\compNumber\compNumber.ino: In function 'void loop()':

compNumber:154: error: 'nex_listen_list' was not declared in this scope

     nexLoop(nex_listen_list);

             ^

compNumber:154: error: 'nexLoop' was not declared in this scope

     nexLoop(nex_listen_list);

                            ^

exit status 1

'NexNumber' does not name a type


You might want to try Itead's Library located here:

https://github.com/itead/ITEADLIB_Arduino_Nextion


This library is configured for the Mega by default, so there may be some configuration for the UNO that you will need to adjust.  I assume it is this library they are referring to.

Ok.  I moved the neoNextion directory to a different folder.  downloaded the folder from the link you gave me.  compiled "compNumber" and now get this mess:


Arduino: 1.6.12 (Windows 8.1), Board: "Arduino/Genuino Uno"

In file included from S:\Data\Arduino\libraries\Nextion-master\NexHardware.h:18:0,

                 from S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp:15:

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp: In function 'bool recvRetNumber(uint32_t*, uint32_t)':

S:\Data\Arduino\libraries\Nextion-master\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp:55:5: note: in expansion of macro 'nexSerial'

     nexSerial.setTimeout(timeout);

     ^

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp:67:31: warning: left shift count >= width of type

         *number = (temp[4] << 24) | (temp[3] << 16) | (temp[2] << 8) | (temp[1]);

                               ^

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp:67:49: warning: left shift count >= width of type

         *number = (temp[4] << 24) | (temp[3] << 16) | (temp[2] << 8) | (temp[1]);

                                                 ^

In file included from S:\Data\Arduino\libraries\Nextion-master\NexHardware.h:18:0,

                 from S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp:15:

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp: In function 'uint16_t recvRetString(char*, uint16_t, uint32_t)':

S:\Data\Arduino\libraries\Nextion-master\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp:114:16: note: in expansion of macro 'nexSerial'

         while (nexSerial.available())

                ^

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp: In function 'void sendCommand(const char*)':

S:\Data\Arduino\libraries\Nextion-master\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp:166:12: note: in expansion of macro 'nexSerial'

     while (nexSerial.available())

            ^

S:\Data\Arduino\libraries\Nextion-master\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp:171:5: note: in expansion of macro 'nexSerial'

     nexSerial.print(cmd);

     ^

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp: In function 'bool recvRetCommandFinished(uint32_t)':

S:\Data\Arduino\libraries\Nextion-master\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp:192:5: note: in expansion of macro 'nexSerial'

     nexSerial.setTimeout(timeout);

     ^

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp: In function 'bool nexInit()':

S:\Data\Arduino\libraries\Nextion-master\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp:226:5: note: in expansion of macro 'nexSerial'

     nexSerial.begin(9600);

     ^

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp: In function 'void nexLoop(NexTouch**)':

S:\Data\Arduino\libraries\Nextion-master\NexConfig.h:37:19: error: 'Serial2' was not declared in this scope

 #define nexSerial Serial2

                   ^

S:\Data\Arduino\libraries\Nextion-master\NexHardware.cpp:242:12: note: in expansion of macro 'nexSerial'

     while (nexSerial.available() > 0)

            ^

exit status 1

Error compiling for board Arduino/Genuino Uno.

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.


So this is pointing to NexHardware and NexConfig.


As I stated, the library is configured for the Mega2560 by default and there will need to be some configuration changes - the clues may be in the image I posted above and in the thread I gave the link to

Got it, fixed now.  Thanks for you help.

Excellent - Happy coding Erich


Login or Signup to post a comment