ATMega328p 8Mhz internal, standalone, mysensors low power problem
-
Hi ! I have started to upgrade mysensors ( 1.5 ) thats been working for a long time to version 2.1.1 but can't seem to get lowpower working.
Tried most of the stuff out there like different bootloaders and changing NRF24 chips but I end up with 17mA during transmit and between 2,4 - 3,5mA in sleep mode.
Tried using other low power libraries like http://www.gammon.com.au/power which works nice but is not compatible with mysensors because some parts are already implemented there I guess. With this library I get sleep mode like 20uA but then again can't get mysensors to work. What's the catch ?
Anyone else have this problem and hopefully a solution for standalone ATMega 328p ?
-
@torfinn I cannot reproduce this. Can you post your sketch?
-
Here is a minimal sketch I am testing with:
#define MY_RADIO_NRF24 #include <SPI.h> #include <MySensors.h> #include <DHT.h> #define DHT_DATA_PIN 8 #define SENSOR_TEMP_OFFSET 0 static const uint64_t UPDATE_INTERVAL = 60000; #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); DHT dht; void presentation() { sendSketchInfo("TemperatureAndHumidity", "2.2"); present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); } void setup() { } void loop() { dht.readSensor(true); float temperature = dht.getTemperature(); float humidity = dht.getHumidity(); send(msgHum.set(humidity, 1)); sleep(10000); }
-
@torfinn nothing wrong with your sketch it should do the trick. Are you sure it worked with low consumption in v1.5?
(p.s. I put the sketch in your post between code marks for better reading)
-
I have 4 sensors (temp/hum and contact switch) powered by 3V coin battery and with the library 1.5.4 they run for a year. I also decided to upgrade them to the library 2.1.1 and I got some issues. For example the binarysqwitchsleepsensor doesn't sleep. I also noticed that the initialization has many messages sending failure and that is a heavy blow for the battery, I went back to the 1.5.4.
-
@mortommy that explains something. The 2.x version is more strict in guaranteeing communication is working. There are some tricks to get around it.
-
Thank's for your feedback.
Did you use the usual gw.sleep command on 1.5.4 or any other lowpower libraries ?
-
Could it be board related ? I am using Arduino 1.8.1. I tried compiling with Ardino Pro / ATmega 328p 8Mhz as stock setup and now using both bootloader and setup from here: https://github.com/MCUdude/MiniCore/blob/master/README.md#boards-manager-installation
I was just thinking that maybe some of the command in the mysensors library are disabled if it detects another board setting ?
Also anyone know if the pin 2 / IRQ should be used ? Its not connected in my project could it be that mysensors is awakened by this ?
-
@torfinn RESOLVED:
Hi ! I had problem with properly registering on the gateway ( due to chips was used on old version earlier ). After finding this post I tried the https://www.mysensors.org/build/debug#clearing-eeprom and it fixed problem. Looking at 40uA sleeping now
-
@mortommy Hi ! I decided to go with 2.1.1 on new sensors but still have the old 1.5.4 gw running. Had to change frequency to #define MY_RF24_CHANNEL 125 as the 2.1.1 sensors also registered partialy ( temp not humidity ) on the old 1.5 gw.
Also tried out #define MY_REPEATER_FEATURE Disabled this seems to do the opposite what i thought. Radio is never turned off ie. 17mA drain.
Added the following to try the lower the init etc. and it improves a little.
#define MY_REGISTRATION_FEATURE Disabled
#define MY_REGISTRATION_RETRIES 1I think its a serious flaw that if the gw for any case locks up our sensors will drain the battery until it's back online again.
-
@torfinn said in ATMega328p 8Mhz internal, standalone, mysensors low power problem:
#define MY_REGISTRATION_FEATURE Disabled
This has no effect, the correct approach would be to comment this line:
https://github.com/mysensors/MySensors/blob/master/MyConfig.h#L146