I use a esp32 pico with an RFM69.
Everything works fine except with the use of energy saving mode.
Solution 1:
Deel Sleep
The frames are sent but not processed by ESP32.
I restart esp32 server to receive a correct frame. Then the others are not processed.
Solution 2:
Light Sleep
Same code except that I use Light Sleep for energy saving.
And it works.
obligation to reduce energy consumption. So Deep Sleep.
SERVER
Code: Select all
#include <RHReliableDatagram.h>
#include <RH_RF69.h>
#include <SPI.h>
#define CLIENT_ADDRESS 2
#define SERVER_ADDRESS 1
RH_RF69 driver(5, 26);
RHReliableDatagram manager(driver, SERVER_ADDRESS);
void setup()
{
Serial.begin(9600);
while (!Serial)
;
delay(10);
if (!manager.init())
Serial.println("init failed");
delay(10);
}
uint8_t data[] = "And hello back to you";
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
void loop()
{
manager.temperatureRead();
if (manager.available())
{
uint8_t len = sizeof(buf);
uint8_t from;
if (manager.recvfromAck(buf, &len, &from))
{
Serial.print("got request from : 0x");
Serial.print(from, HEX);
Serial.print(": ");
Serial.println((char*)buf);
if (!manager.sendtoWait(data, sizeof(data), from)){
Serial.println("sendtoWait failed");
}else{
}
}
}
}
Code: Select all
#include <RHReliableDatagram.h>
#include <RH_RF69.h>
#include <SPI.h>
RTC_DATA_ATTR uint8_t data[] = "Hello World!";
RTC_DATA_ATTR uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
RTC_DATA_ATTR uint8_t len = sizeof(buf);
RTC_DATA_ATTR uint8_t from;
void setup()
{
RH_RF69 driver(5, 13);
RHReliableDatagram manager(driver, 2);
Serial.begin(9600);
if (!manager.init())
if (!manager.init())
Serial.println("init failed");
Serial.println("Sending to rf69_reliable_datagram_server");
if (manager.sendtoWait(data, sizeof(data), 1))
{
if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
{
Serial.print("got reply from : 0x");
Serial.print(from, HEX);
Serial.print(": ");
Serial.println((char*)buf);
}
else
{
Serial.println("No reply, is rf69_reliable_datagram_server running?");
}
}
else
Serial.println("sendtoWait failed");
Serial.println("sendtoWait test");
delay(500);
esp_sleep_enable_timer_wakeup(5 * 100000);
esp_deep_sleep_start();
}
void loop()
{
}
Code: Select all
#include <RHReliableDatagram.h>
#include <RH_RF69.h>
#include <SPI.h>
RTC_DATA_ATTR uint8_t data[] = "Hello World!";
RTC_DATA_ATTR uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
RTC_DATA_ATTR uint8_t len = sizeof(buf);
RTC_DATA_ATTR uint8_t from;
RH_RF69 driver(5, 13);
RHReliableDatagram manager(driver, 2);
void setup()
{
Serial.begin(9600);
}
void loop()
{
if (!manager.init())
if (!manager.init())
Serial.println("init failed");
Serial.println("Sending to rf69_reliable_datagram_server");
if (manager.sendtoWait(data, sizeof(data), 1))
{
if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
{
Serial.print("got reply from : 0x");
Serial.print(from, HEX);
Serial.print(": ");
Serial.println((char*)buf);
}
else
{
Serial.println("No reply, is rf69_reliable_datagram_server running?");
}
}
else
Serial.println("sendtoWait failed");
Serial.println("sendtoWait test");
esp_sleep_enable_timer_wakeup(5000000);
esp_light_sleep_start();
}