Sleeping with RFM95 ?
-
Hi,
I'm trying to put a node to sleep that consists of an Arduino Pro Mini board (3.3 V, 8 MHz) and an RFM95 module (SX1276 chip) using MySensors (2.4.0). In the code below, the node does not go to sleep. I've tried with and without transportDisable/transportReinitialise, and also cutting power to the RFM95 module using powerDownRadio / powerUpRadio, but whenever sleep actually works, the radio transmission no longer works after waking up… I don’t know what else to test. Any idea? Is it a hardware problem ?#define MY_DEBUG
#define MY_RADIO_RFM95
#define MY_RFM95_FREQUENCY (RFM95_868MHZ)
#define MY_IRQ_PIN 2
#define MY_RST_PIN 9
#define MY_NODE_ID 22#include <MySensors.h>
MyMessage msgTestRfm(100, V_CUSTOM);
void presentation() {
sendSketchInfo("Test RFM", "1.1");
present(100, S_CUSTOM);
}void loop() {
send(msgTestRfm.set(1));
wait(200);// couper la radio (sinon sleep() bloque)
transportDisable();
wait(50);// sommeil — pas de LowPower ici !
sleep(5000);// réactiver la radio
transportReInitialise();
wait(200);Serial.println("Réveillé !");
} -
I don't think you should have to disable the transport. Just look at the example of the Sensebener https://www.mysensors.org/hardware/micro
A simple sleep should be sufficient .... I didn't even know the transportDisable and transportReinitialise were part of the library :)
And not really sure with what you mean with sleep not working. If you remove the transportDisable, the waits and the transportReinitialise you should see a reading every 5 seconds in your controller.
-
@Aymeric As @TheoL mentioned, the library automatically handles putting the radio to sleep when you call
sleep(). The functionstransportDisable()andtransportReinitialize()are internal to the library and not meant to be used directly.If you can share the serial/console output, we may be able to better understand what’s going on.
-
Thanks for your answers. I tried the code keeping only sleep without the other functions, and it worked once. When I uploaded another, more complex sketch, it didn’t work anymore, and even if I put back the one that used to work, it no longer works :
4098 TSF:MSG:SEND,22-22-0-0,s=100,c=1,t=48,pt=2,l=2,sg=0,ft=0,st=OK:1
4306 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
4311 TSF:TDI:TSL
4315 MCO:SLP:WUP=-1
4317 TSF:TRI:TSB
Réveillé !
4419 TSF:MSG:SEND,22-22-0-0,s=100,c=1,t=48,pt=2,l=2,sg=0,ft=0,st=OK:1
4628 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
4632 TSF:TDI:TSL
4636 MCO:SLP:WUP=-1
4638 TSF:TRI:TSB
Réveillé !I think there is a problem with PIN 2 / IRQ because if I connect the IRQ to GND, there is a 5 s sleep, but then the radio no longer works.
13764 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
13770 TSF:TDI:TSL
13772 MCO:SLP:WUP=-1
13774 TSF:TRI:TSB
Réveillé !
20779 !TSF:MSG:SEND,22-22-0-0,s=100,c=1,t=48,pt=2,l=2,sg=0,ft=1,st=NACK:1 -
Thanks for your answers. I tried the code keeping only sleep without the other functions, and it worked once. When I uploaded another, more complex sketch, it didn’t work anymore, and even if I put back the one that used to work, it no longer works :
4098 TSF:MSG:SEND,22-22-0-0,s=100,c=1,t=48,pt=2,l=2,sg=0,ft=0,st=OK:1
4306 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
4311 TSF:TDI:TSL
4315 MCO:SLP:WUP=-1
4317 TSF:TRI:TSB
Réveillé !
4419 TSF:MSG:SEND,22-22-0-0,s=100,c=1,t=48,pt=2,l=2,sg=0,ft=0,st=OK:1
4628 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
4632 TSF:TDI:TSL
4636 MCO:SLP:WUP=-1
4638 TSF:TRI:TSB
Réveillé !I think there is a problem with PIN 2 / IRQ because if I connect the IRQ to GND, there is a 5 s sleep, but then the radio no longer works.
13764 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
13770 TSF:TDI:TSL
13772 MCO:SLP:WUP=-1
13774 TSF:TRI:TSB
Réveillé !
20779 !TSF:MSG:SEND,22-22-0-0,s=100,c=1,t=48,pt=2,l=2,sg=0,ft=1,st=NACK:1 -
Hello, it was a hardware problem. I had tried with two different Pro Mini boards, but after trying with a third one, everything is working now. Thank you for your help.
-
I learned my lessons about bread boards. Slowly replacing my cheap AliExpress ones with good quality ones. I blew up 2 nano's and 1 nrf this week because of a bad breadboard