Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 PICO RFM69 (SPI) - communication problems arduino IDE #36

Open
LDavidFr opened this issue Dec 7, 2019 · 2 comments
Open

ESP32 PICO RFM69 (SPI) - communication problems arduino IDE #36

LDavidFr opened this issue Dec 7, 2019 · 2 comments

Comments

@LDavidFr
Copy link

LDavidFr commented Dec 7, 2019

Hello,
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 (server).
I restart esp32 server to receive a correct frame. But the next trame are not processed.

Solution 2:
Light Sleep
Same code and lib, I use Light Sleep. It works.
But obligation to reduce energy consumption. So Deep Sleep.

SERVER

#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{
    }
    }
  }
}


CLIENT DEEP SLEEP After reboot SERVER, first trame is good (receive and ack) and next trame KO

#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()
{
}

CLIENT LIGHT SLEEP Good for all trame (receive and ACK) but consumption is not ideal

#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();
}



@LDavidFr
Copy link
Author

LDavidFr commented Dec 8, 2019

RFM95 is same ... :/

@LDavidFr
Copy link
Author

LDavidFr commented Dec 8, 2019

Humm if send new request when after :recv failed: the server accept trame. (deep_sleep)

14:35:55.725 -> [SYS] Freq MCU : 80
14:35:55.835 -> [SYS] Mac address : d8a01d6b204c
14:35:55.835 -> Unable to find address for Device 0
14:35:55.905 -> [SYS] sensor Wire detection : 1 :: 51;
14:35:56.180 -> [RDF] Message : {"moduid":"d8a01d6b204c","sensor":{"modrev":3,"loop":0,"battery":"5.05","uptime":11822,"nexttime":30,"rssi":45,"data":{"temperature":"-127.00","ts":1575812145}}}
14:35:56.215 -> [SYS] Waiting for collision : 0
14:35:56.322 -> RH_RF95 interruptNumber=13
14:35:56.322 -> RH_RF95 pinMode _interruptPin=13
14:35:56.355 -> RH_RF95::init() complete!
14:35:56.355 -> [RFR] init OK
14:35:58.487 -> [SYS] recv failed
14:35:58.487 -> [RDF] Message : {"moduid":"d8a01d6b204c","sensor":{"modrev":3,"loop":1,"battery":"5.05","uptime":11822,"nexttime":30,"rssi":45,"data":{"temperature":"-127.00","ts":1575812145}}}
14:35:58.521 -> [SYS] Waiting for collision : 0
14:35:58.628 -> RH_RF95 interruptNumber=13
14:35:58.628 -> RH_RF95 pinMode _interruptPin=13
14:35:58.628 -> RH_RF95::init() complete!
14:35:58.628 -> [RFR] init OK
14:36:01.658 -> [RDF] got reply: {"lpcb":0,"sensorRestartconfig":0,"sensorRestart":0,"sensorRestartDailytime":"20:30","sensorFreq":30,"sensorId":2,"ts":"1575812160"}
14:36:01.691 -> [SYS] TimeStamp : 1575812145
14:36:01.691 -> [SYS] jsonsensorFreq : 30
14:36:01.691 -> [SYS] sensorFreq : 30
14:36:01.691 -> [SYS] Going to sleep now for : 30 :: 1575812175
14:36:01.691 -> [SET] Alarm (into lib) : 12-08 13:36:15
14:36:01.691 -> [ALA] Alarm Period
14:36:25.585 ->
14:36:25.585 -> [SYS] Freq MCU : 80
14:36:25.690 -> [SYS] Mac address : d8a01d6b204c
14:36:25.690 -> Unable to find address for Device 0
14:36:25.790 -> [SYS] sensor Wire detection : 1 :: 51;
14:36:26.076 -> [RDF] Message : {"moduid":"d8a01d6b204c","sensor":{"modrev":3,"loop":0,"battery":"5.08","uptime":12322,"nexttime":30,"rssi":45,"data":{"temperature":"-127.00","ts":1575812175}}}
14:36:26.076 -> [SYS] Waiting for collision : 0
14:36:26.216 -> RH_RF95 interruptNumber=13
14:36:26.216 -> RH_RF95 pinMode _interruptPin=13
14:36:26.216 -> RH_RF95::init() complete!
14:36:26.216 -> [RFR] init OK
14:36:27.880 -> [RDF] got reply: {"lpcb":0,"sensorRestartconfig":0,"sensorRestart":0,"sensorRestartDailytime":"20:30","sensorFreq":30,"sensorId":2,"ts":"1575812186"}
14:36:27.916 -> [SYS] TimeStamp : 1575812175
14:36:27.916 -> [SYS] jsonsensorFreq : 30
14:36:27.916 -> [SYS] sensorFreq : 30
14:36:27.916 -> [SYS] Going to sleep now for : 30 :: 1575812205
14:36:27.916 -> [SET] Alarm (into lib) : 12-08 13:36:45
14:36:27.949 -> [ALA] Alarm Period

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant