ESP-NOW time sychronization

jtomas
Posts: 1
Joined: Mon Dec 21, 2020 3:30 am

ESP-NOW time sychronization

Postby jtomas » Mon Dec 21, 2020 3:38 am

Hi,

I am going to use esp32 based sensor units to build a wireless sensor network.
I am struggling with the time synchronization problem in the network.
Could esp-now protocol achieve time synchronization in wireless sensor network?

Thanks

spirosbond
Posts: 4
Joined: Thu Dec 24, 2020 11:06 pm

Re: ESP-NOW time sychronization

Postby spirosbond » Thu Dec 24, 2020 11:13 pm

Hey there. You need to program the time synchronization by yourself. If you want the actual time one of your nodes need internet connections and to setup an NTP server to get the time periodically. There is an NTP server example in the IDF repository. If you don't care about having the actual time/date and it is enough for you that all nodes have the same reference based on one master, you can just broadcast the time() of the master and use the function settimeofday() function to the slaves. Look at the standard time.h library.
In the second approach keep in mind that there is the delay of the packet Tx and Rx of the network. That can be significant in case you are enabling power saving and auto sleep.

I hope this helps. Have fun.

imharish63
Posts: 1
Joined: Tue Oct 19, 2021 10:07 am

Re: ESP-NOW time sychronization

Postby imharish63 » Tue Oct 19, 2021 10:25 am

I am planning to use 4 esp32 nodes and one of them connected to ntp server for time synchronization. and wants to time sync rest of the devices to esp access point wifi mode. Is it possible? I have doubt regarding broadcast the time() of the master and use the function settimeofday() function to the slaves. on Slaves if i use the function , what is the parameter to be passed in function to obtain masters time onto slave.

also i have one more idea to sync each of esp32 nodes with ntp server and check for actual time difference between nodes after synchronization and rectify the time in order to have the lag of less than 5 ms. How to transmit time info in this manner between the devices. Kindly help me out?

@spirosbond
@jtomas

Who is online

Users browsing this forum: Bing [Bot], joe_fang_iD, Majestic-12 [Bot] and 287 guests