Go Down

Topic: Tutorial on how to write code with Nextion and Arduino (Read 8153 times) previous topic - next topic

DRE50

You have a timer event on the nextion display whats that for? and how did you come up with the hex number for that?

Seithan

Hello DRE50,

Can you please be more specific as I use many timers in the project?

And for the HEX, it is better to read through Serial.
UBUNTU:
"I am what I am, because of who we all are", compassion, kindness and humanity that connect us together by sharing  ourselves with others and caring for those around us.

DRE50

Hello DRE50,

Can you please be more specific as I use many timers in the project?

And for the HEX, it is better to read through Serial.

I down loaded your relay project and i noticed you have a timer on the HMI file. i was wondering what it was for? and i having a hard time figuring out how you came up with the Hex for it?

Seithan

You can see this abstract in the code:

You can read the comments
Code: [Select]

case 'S':
   /* or <case 0x53:>  if 'S' matches, we have the command group "Nextion is Synchronized".
    * From the timer component on Nextion, we send every 4,9 seconds a < printh > command
    * so we check if Nextion is connected and synchronized.
    * If it is not, pin 12 turns HIGH as Alarm
    * We check the above, by writing in the timer's event: < printh 23 01 53 >
    */
      timeout_synq = millis(); // setting the timer to be equal to millis(), because Nextion sent a alive message
                 
                 
      break; 


Code: [Select]

void check_Nextion_synq()
{
 if((millis() - timeout_synq) > TIMEOUT_FOR_SYNQ ) {
     digitalWrite(12,HIGH);
     /* you could put a buzzer here (pin 12) to notify you that the connection is lost
      * for the LED, you will need a 220ohm in series.
      * Here we turn the buzzer or the LED on
      */
    }else{
    digitalWrite(12,LOW); //stops the LED or the buzzer if synq comes back
    }
}


And all these because the page is going to remain the same for a long time, it is good to know if the connection between Nextion and Arduino remains and Arduino and Nextion are alive
UBUNTU:
"I am what I am, because of who we all are", compassion, kindness and humanity that connect us together by sharing  ourselves with others and caring for those around us.

wesno

I needed to build a pretty complex input panel to drive my application (a control panel for a stepper motor to move a table on a model railroad) and an Arduino program, along with an input panel on a Nextion display seemed to fit the bill.  However, I'd never seen either piece of hardware until 3 weeks ago.  I'm a long-time programmer but on mainframes, servers and PCs.

This forum was essential to getting my Arduino skills up and your very excellent Nextion tutorial was EXACTLY what I needed.  It lets you send simple commands and make the Nextion do exactly what you want.  I was surprised at how quickly I got things going.  Contributions like yours, being offered for free no less, often go unnoticed and unheralded.  I just wanted to tell you that you made my initial experience with the Nextion much less painless than it could have been.

I must confess to a basic bit of ignorance.  I coded my Arduino program okay and got my Nextion panels (4 of them actually, linked with navigation buttons) all done up nice and they all worked fine using the Simulation mode of the Nextion Editor.  Under simulation, I could actually move my stepper motor very precisely.  However, when I got my real panel and wired it up, I was unable to reliably send and receive data between the Nextion and Arduino. 

Fast forward to the final answer:  being a non-electrical engineer I didn't realize that the GND from the actual Nextion panel needed to be connected to GND on the Arduino.  Once I did that, all was fine.  I'm sure this basic requirement is covered somewhere but I surely missed it.

That last mistake is all on me.  Again, once I got that issue resolved, the application worked amazingly well.  Thanks again, my friend.

PerryBebbington

Quote
Fast forward to the final answer:  being a non-electrical engineer I didn't realize that the GND from the actual Nextion panel needed to be connected to GND on the Arduino.  Once I did that, all was fine.  I'm sure this basic requirement is covered somewhere but I surely missed it.
Common ground and why you need one

This is a common problem for people not from an electrical background, hence the tutorial.

Seithan

This forum was essential to getting my Arduino skills up and your very excellent Nextion tutorial was EXACTLY what I needed.  It lets you send simple commands and make the Nextion do exactly what you want.  I was surprised at how quickly I got things going.  Contributions like yours, being offered for free no less, often go unnoticed and unheralded.  I just wanted to tell you that you made my initial experience with the Nextion much less painless than it could have been.
I am glad that my Tutorial helped you and this is my target.

I am also happy because you made your first application with Arduino and Nextion and it worked as it should.

Certainly, if you were in my shoes, you would do the same and give your knowledge without second thought.

And I do not think I have written in my tutorial how Nextion is connected, as I have a link to Nextion Guide.

I am willing to help you in the future with everything I can.

- Athanasios Seitanis

I try to avoid writing a lot of replies, especially if no help is needed, but your post really moved me and I really appreciate your sincere comments.
UBUNTU:
"I am what I am, because of who we all are", compassion, kindness and humanity that connect us together by sharing  ourselves with others and caring for those around us.

Go Up