• 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

ESP-Now, sync sender and receiver

Q&A Forum › Category: ESP32 › ESP-Now, sync sender and receiver
0 Vote Up Vote Down
William Lucid asked 5 years ago

ESP-Now project I have uses NTP on receiver.  I compare Barometric Pressure every 15 minutes to find the differenc from the previous 15 minute period.

For now I am sending readings from the sender every 4.5 Minutes to ensure readings are are available when 15 minute routine runs on the receiver.  Really only want one reading 30 seconds before the 15 minute routine runs.

Looking at difference in Barometric Pressure for .20 change (experimental value based on my logs and frequency of occurrence) in Barometric pressure.

Any recommendations on syncing sender and receiver?

Regards,
William

Question Tags: Asyncwebserver, Esp-now, Weather Station
7 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi.
I don’t know if this is the best solution, but what you can do is:

  • 30 seconds before the 15 minute routine, the receiver sends a message to the sensor node
  • when the sensor node receives that message, it sends the reading back to the receiver
  • then, the receiver proceeds with its 15 minute routine

I’m not sure if there is a better solution…

Regards,
Sara

0 Vote Up Vote Down
William Lucid answered 5 years ago

Hi Sara,

Another approach might be:

I am thinking of adding code from this sketch, I use in the receiver :  NTP_System_Time.ino

Using this code I would disconnect from NTP time server after setting system time; if statement like:

if((MINUTE % 15) == 0)  && ((Seconds) == 30) then send readings, could be added to sender code.

Do NTP time servers require always on connection or can connection to NTP server be disconnected, once system time is set?   Reconnection to NTP time server would occur when ESP32 is reset by a deep sleep wakeup.

Regards,
William

0 Vote Up Vote Down
Steve Mercer answered 5 years ago

NTP time servers can be contacted any time you want but remember that using the internal RTC is very inaccurate and can lose/gain minutes every hour. You could use an external 32k crystal to get much more accuracy. Your code seems reliant on the accuracy of the clock.

0 Vote Up Vote Down
William Lucid answered 5 years ago

Thank you Sara and Steve for your responses.

My Approach to syncing ESP-Now can be found on Github.

I have logs of ESP32_Sender and ESP32_Receiver with timestamps; after four hours of logging, works.

Querying NTP server one time when bootCount = 0; if clock drift is an issue, then querying NTP time server every 15 minutes can be tasked.  When ESP32_Sender wakes from Deepsleep it connects to NTP time server, then disconnects.  Should I turn off WiFi at this point?  From wakeup to sending readings is taking 17 seconds, readings are sent at 15 Minutes and 0 seconds.  ESP32_Receiver waits until 15 minutes and 30 seconds before completing 15 minute routine.

ESP32_Receiver is a merge of ESP32-Now and my exsisting Rain_Gauge –Weather, data logger project based on Asyncwebserver.

Regards,
William

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

Hi again.
After requesting the time you can disconnect the Wi-Fi and it will keep the time in the ESP32 internal clock (it is not necessary, you can keep it connected – but it will consume more power. So, if you want to save power, you should disconnect).
Thanks for sharing your project.
Regards,
Sara

0 Vote Up Vote Down
William Lucid answered 5 years ago

Thank you Sara. 
 
Question has been answered,
 
Regards,
William

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

Great!
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

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition 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.