• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

How to request ntp data on demand from Arduino Mega connected serially to ESP 8266 webserver

Q&A Forum › Category: Arduino › How to request ntp data on demand from Arduino Mega connected serially to ESP 8266 webserver
0 Vote Up Vote Down
Roger Wilson asked 2 years ago

Hi Sara and Rui,
Thank you for your brilliant tutorials, guides and related support. They are so helpful.
I have one of those Arduino Mega 2560 plus ESP8266 boards, in which the Mega 2560 and ESP8266 on the board can be connected to each other via one of the serial ports. I have different sketches running on each of them (Mega 2560  and ESP8266). With your help I have the ESP8266 running a webserver and successfully fetching ntp time&date updates, which I can send to the Arduino Mega 2560 ok and plug them into the sketch running on the Mega 2560. However, what I want to do is have the Arduino Mega 2560 sketch request these updates on demand ie not have them sent to it when not needed or requested. The Mega 2560 sketch is running a nixie clock which has an RTC but I’d like to be able to resynchronize the RTC with ntp time&date intermittently.  I’m just not sure how to code the Arduino sketch to request the ESP8266 webserver fetch and send an ntp time&date update to the Mega on request only? Once I can do this I think I can manage the RTC time&date update. I expect it is simple but I haven’t been able to figure it out yet.
Can you help me with this please?

3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi Roger.
I think the easiest way is to have a two-way communication via serial.
When the ESP8266 receives a certain message from the Arduino board, it will send the requested time.
If you already have the time being sent to the Arduino, I think you should already know how to send data via serial.
 
Regards,
Sara

0 Vote Up Vote Down
Roger Wilson answered 2 years ago

Thank you Sara. Yes, having figured out how to pass the messages and deliver instructions between the two boards  via the serial port, I have now got this all working. I had some frustrating inconsistency problems initially, which I initially thought might be related to the baud rate but were actually related to other timing issues. I was looking for the reply from the ESP8266 to the request for the time update too soon after the request had been made.  A delay in looking for the response solved that but I was concerned that that might upset other processes in the sketch so opted for a periodic push update from the ESP8266 instead, which has proven much cleaner and simpler. Thanks for steering me in the right direction. This is my first ever web app (at probably more than twice your age). 

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

That’s great!
We are always on time to learn something new.
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.