battery powered sensors problem



  • Hi,

    I have strange problem with my battery powered BME280 sensors. I use Easy/Newbie PCB for all my sensors (wall and battery powered). Hardware works fine I think because all my wall powered sensors works ok almost one year now.

    Battery sensors works ok when I disconnect it from battery and charge before power loss. Every time when I let it power off itself my gateway hangs and all sensors data didn't show in Home Assistant. Also debug logs in HA didn't show any communication from gateway. I have 2 the same battery sensors powered by two 18650 cells (sketch is the same, difference is another node id). When this situation happens I have to restart all my network to get it working again. I have all my wall powered sensors on one circuit so I can easily reboot them. But without restarting battery sensor (this one still powered) network doesn't work.

    I cannot do debug of powered off sensor. Debug logs in Home Assistant shows nothing (no log from gateway). I cannot reconnect serial console to gateway because it will reboot the gateway...

    I upgraded my gateway and battery powered sensors to newest mysensors version, but I use old RMF69 driver - I don't know it it relevant or not.

    Gateway sketch is the standard one - radio type, channels, encryption only

    battery sensor and gateway sketch is below

    Any ideas what is wrong?

    #define MY_ENCRYPTION_SIMPLE_PASSWD "xxxxxxxxxxxxxxxxxx" 
    #define MY_NODE_ID 9
    #define MY_RADIO_RFM69
    #define MY_IS_RFM69HW
    #define MY_RFM69_NETWORKID 101
    
    #include <MySensors.h>  
    #include <Wire.h>
    #include <Adafruit_Sensor.h>
    #include <Adafruit_BME280.h>
    
    #define SEALEVELPRESSURE_HPA (1013.25)
    
    int BATTERY_SENSE_PIN = A0;  
    
    unsigned long SLEEP_TIME = 60000*5; 
    int oldBatteryPcnt = 0;
    Adafruit_BME280 bme;
    unsigned status;
    
    MyMessage msg(1,V_TEMP);
    MyMessage msg2(2,V_HUM);
    MyMessage msg3(3,V_VAR1);
    
    void before()
    {
    }
    
    void setup()  
    { 
    status = bme.begin();  
    
    bme.setSampling(Adafruit_BME280::MODE_FORCED,
                        Adafruit_BME280::SAMPLING_X1,   // temperature
                        Adafruit_BME280::SAMPLING_NONE, // pressure
                        Adafruit_BME280::SAMPLING_X1,   // humidity
                        Adafruit_BME280::FILTER_OFF );
    
    }
    
    void presentation() {
      sendSketchInfo("sensor_front", "1.0");
    
         present(1, S_TEMP,"temp front");
         present(2, S_HUM,"hum front");
         present(3, S_CUSTOM,"bat raw");
    
      }
    
    
    void loop()     
    {     
    
    int sensorValue = analogRead(BATTERY_SENSE_PIN);
    int batteryRaw = sensorValue;
    
    int batteryPcnt = map (batteryRaw,335, 435, 0, 100);
    if (batteryPcnt>100) batteryPcnt = 100;
    
     Serial.print("Battery percent: ");
     Serial.print(batteryPcnt);
     Serial.println(" %");
     sendBatteryLevel(batteryPcnt);
     
      bme.takeForcedMeasurement();
      wait(1000);
     
      float hum = bme.readHumidity();
      send(msg2.set(hum,0));
      float temperature = bme.readTemperature();
      send(msg.set(temperature,1));
      send(msg3.set(batteryRaw,0));
    
      sendHeartbeat();
      sleep(SLEEP_TIME);
    
    }
    
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    #define MY_ENCRYPTION_SIMPLE_PASSWD "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
    
    // Enable and select radio type attached
    #define MY_RADIO_RFM69
    #define MY_IS_RFM69HW
    #define MY_RFM69_NETWORKID 101
    
    
    // Enable serial gateway
    #define MY_GATEWAY_SERIAL
    
    // Define a lower baud rate for Arduinos running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
    #if F_CPU == 8000000L
    #define MY_BAUD_RATE 38400
    #endif
    
    
    // Set blinking period
    //#define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Inverses the behavior of leds
    //#define MY_WITH_LEDS_BLINKING_INVERSE
    
    // Flash leds on rx/tx/err
    // Uncomment to override default HW configurations
    //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
    
    #include <MySensors.h>
    
    void setup()
    {
    	// Setup locally attached sensors
    }
    
    void presentation()
    {
    	// Present locally attached sensors
    }
    
    void loop()
    {
    	// Send locally attached sensor data here
    }
    


  • Could it be the node battery is too low, the node restarts (sending presentation messages and so on) and then the voltage falls below the BOD threshold again. So in fact it stays in this loop until the battery is totally empty.
    Due to the repeated restart messages, the gateway becomes unavailable for the other nodes.
    This should be possible to see on the gateway debug output though.



  • @electrik I think about it but when I open the sensor and press reset to test - sensor is dead. No power indicators, no blinking. Also my sketch presents sensor at every boot. In HA logs it will be written lines like "node 9 cannot add child 1 already existing" etc. but log is empty.

    Also without resetting another battery sensor I cannot bring to life my network. It should be some kind of simple mistake but I cannot find it 😞 Node id are different and sensor data when battery is charged are correct.

    Maybe sensor send some kind of incomplete or spam messages? All other sensors become inactive from HA perspective - it looks like some gateway problem... or HA. I'm really confused. I can try to power off arduino when battery is almost empty but dont like this kind of solutions



  • There are more messages than just the presentation messages that don't show in the HA logs, like find parent. You should check the actual GW debug output when this situation occurs to see them.
    This would be really necessary if you ask me, otherwise it can't be seen what happens to the gw to make it hang.


Log in to reply
 

Suggested Topics

  • 2
  • 7
  • 6
  • 2
  • 8
  • 998
  • 910
  • 16

193
Online

9.7k
Users

10.3k
Topics

106.4k
Posts