Synchronizing ESP32's to send ESP-NOW messages in-between sleep periods


I have a project in which I have 2 battery powered ESP32s. I want them to sleep most of the time, so their wifi modems will be powered off during these periods. I need a good strategy to determine when to send the ESP NOW messages so that the receiver's modem will be ON. (either can send messages at anytime).

Since both have an RTC, I was thinking about setting a rendez-vous time every 1 or 2 minutes to power the modems at the same time and exchange data. I am not sure if this will work, and I wanted to know if anyone had a better strategy?

Thanks for your help!

How about a query?

Hey, you awake? No, OK I'll try again in a few?

Yes, send me you stuff.

1 Like

You could use an MQTT broker. If there's a message waiting for a node when it wakes up, it will read it.

You could use an RTC to control the wake time so that both are live at the same time.

Or send Request/Acknowledge semaphores.

Yeah, I thought about being almost always asleep and checking if something changed before sleeping again. Your method means I would need to sustain wake up for at least a few tens of milliseconds? then I guess it wouldn't be too bad for the battery actually.

I never tried the MQTT broker, I'll read on it.

I do have onboard RTCs, I am just scared they would somehow be a little off, or drift. I guess if I do a 2 sec timeframe every minute, chances are this effect wouldnt affect functionality?

The MQTT Broker route, to me, fits with your scheme the best.

It needs a WiFi connection, which makes a node many seconds awake and full powered.

suggests that this could be problematic.

It seems like ESP-NOW is much faster to wake up from sleep than connecting to wifi ESP-NOW - #7 by luotope suggests it could take 400-700ms to execute transactions between sleep periods. It seems like espressif mention a faster connection delay too GitHub - espressif/esp-now: A connectionless Wi-Fi communication protocol

Now, I still feel like the RTC sync strategy may be better actually.. Maybe every time seconds hit 0 or something, an interrupt is triggered from the RTC of both devices, and they start communicating if need be. Then they'd go back to sleep a few seconds later.

Since you don't want the time it takes to log on to WiFi every time you wake, have you considered a third unit that is always on? It could act as the switchboard between the sleeping units.

Yes but we cannot have anything that is wall-plugged, so it wouldn't work. what do you think of the other proposed approaches?

Then the only thing I can think of is to use the RTC to sync the wake times then stay awake until you get an ACK from the other node.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.