How to sleep the Moteino M0?
-
Is anyone using the Moteino M0 as a MySensor?
I have got a BME280 sensor working with the RFM69HW attached but I am not getting low current sleep mode numbers.
I tried the ArduinoLowPower library LowPower.deepSleep(300000); command.
The current drops from 30 mA down to 16 mA.
I need to get to less than 100 uA.
Does the MySensors library support the Moteino M0 (SAMD21G18A) ?
How is the radio turned OFF?
I tried the sleep(300000); command without a response.
Edit August 6:
I tried the BatteryPoweredSensor example from the MySensors library with the
following changes for the RFM69HW radio:// Configure RFM69 Radio #define MY_RADIO_RFM69 #define MY_RFM69_NEW_DRIVER #define MY_IS_RFM69HW #define MY_RFM69_FREQUENCY RFM69_915MHZ #define MY_ENCRYPTION_SIMPLE_PASSWD "redacted" #define MY_RF69_IRQ_PIN 9 #define MY_RF69_IRQ_NUM 9 #define MY_RFM69_CS_PIN A2
I get this in the log file:
Payload Description 66074 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255 Sleep node, duration 5000 ms, SmartSleep=0, Int1=255, Mode1=255, Int2=255, Mode2=255 66084 TSF:TDI:TSL Set transport to sleep 66094 MCO:SLP:WUP=-2 Node woke-up, reason/IRQ=-2 (-2=not possible, -1=timer, >=0 IRQ) 66104 TSF:TRI:TSB Set transport to standby
Looks like it tries to sleep but wakes up 10 mS later with a -2 return (not possible)
The radio goes back to standby 10 mS later.Can someone tell me what changes to the MySensors.h library are necessary to get this working? Meanwhile, I will try a SPI register write the radio to get it to sleep.
-
@gbsmith
Solved by doing a SPI write to the RFM69 Operation Mode register to sleep the radio. Here is a working example:https://github.com/gb53smith/Public/blob/master/MySensors_BME280/MySensors_BME280.ino
This is a workaround since the MySensors.h method did nothing.
sleep(sleepTime);
Aside:
I had to enter the bootloader by double clicking the reset button or reconnecting the USB plug. The COM port number bounced between two port numbers. The port would disconnect just before serial upload. I did not have this problem with the simple Blink example. Does the MySensors library interfere with USB serial port and cause this instability?I found the answer in the LowPowerLabs forum.
There has to be a SerialUSB.begin(); statement in the previously loaded sketch. This will stabilize to USB port connection.
-
@gbsmith Interesting work, thanks for sharing.
Sleep on SAMD mcus is not implemented, that's why the call returns MY_SLEEP_NOT_POSSIBLE
https://github.com/mysensors/MySensors/blob/bfcb125e72fb32f2ea0482499563e73ae5990c2f/hal/architecture/SAMD/MyHwSAMD.cpp#L98
-
@gbsmith said in How to sleep the Moteino M0?:
https://github.com/gb53smith/Public/blob/master/MySensors_BME280/MySensors_BME280.ino
You are using the latest Felix's addition to Moteino family. It is cutting edge and I do not think anyone here has got Moteino M0 yet. Excellent work-around for sleep. What kind of current are you getting while properly sleeping?
-
@alexsh1 current draw details in sketch header. 10-20 uA
I had some problems with recovery after gateway power cycling. See discussion here. This issue has been fixed with a workaround.