Suddenly a Sensor is Missing, not the whole Node. (RPI Eth Gateway, HA)

  • Hi,
    i'm running a sensor network for a couple of years without problems. The setup is described below.
    Some days ago i build an other sensor node and now suddenly a random sensor is missing a view days after HomeAssistant restart.
    So, after a restart everything works perfect. But after a view days the temperature reading of one node, not always the same node, didnt work. The values for humidity and battery level still work from this node. After a restart of the Pi everything works again.
    One time I didnt restart for a couple of days, even more temperature sensors failed. And again the humidity readings still work. After a restart everything works again.

    My network:
    A Raspberry Pi 3 with 64 Bit Raspbian. Homeassistant running in Docker.
    A RFM69 rf module is connected to the GPIO of the RPI to run a ethernet gateway. I had to recompile it because of the 64 Bit structure.
    I have several sensors based of an arduino structure and the RFM69 modules:

    • 3 Temperature/Humidity PLUS ONE NEW Temp/Hum sensor
    • 1 Temp/Hum/Light sensor
    • 1 USB charger sensor (report two current values, if switched on)
    • 1 power meter sensor (actually offline to rewrite the code for an new power meter with different protocol)

    Additionally a couple of actuators and switches over zigbee (SonOff USB stick), like curtains and wall plugs.
    And one BTLE temp/hum sensor.

    Now I 'm a little helpless where to start the debugging. I think the problem occurs between the mysensors gateway and HomeAssistant.
    Is this a space problem for storing the data?
    Maybe I can switch to a more convenient setup, like an mysensors USB gateway and the HASS-OS from HomeAssistant instead of the "experimental" docker stuff?

    I hope someone has a good idea to help.


  • Hi @se-O-matic

    can you please post your source code of the node in question?
    You only restarted Home Assistant, not the nodes, correct?

    Thanks and regards, Edi

  • Hi,
    thanks for the reply.
    Yes, a restart of the raspberry is enough.

    This is the code of the temperatur sensors:

     * My Sensors Node for temperature and humidity
     * Hardware: MSN R00
     * BME280 (temp, hum) at I2C
     * Runs at 2 x AA batterys
    // RFM69CW at 433 MHz / Raspebrry Pi as ethernet gateway
    #define MY_RADIO_RFM69
    #define MY_RFM69_NEW_DRIVER
    #define MY_RFM69_FREQUENCY RFM69_433MHZ 
    #include <MySensors.h>
    // BME280 library from Adafruit, need the Adafruit "Unified Sensor library", too
    #include <Adafruit_BME280.h>
    // Define child IDs and messages
    #define CHILD_ID_TEMP  0
    #define CHILD_ID_HUM   1
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    // Define strings, which are send to the controller
    #define SKETCHSTR "Temp Humidity Sensor"
    #define SKETCHVER "1.0"
    // Sleep time for sensor 
    uint32_t SLEEP_TIME = 300000;    // sleep time between reads (seconds * 1000 milliseconds)
    // Constructor for sensor
    Adafruit_BME280 bme;
    #define BME280_TEMP_OFFSET -1.0    // calibration ofsset for the temperature
    // Battery stuff
    #define EMPTY 536         // Brown Out ATMega   //536 equal to 1.8 V
    #define SCALE 0.2415      // (100/950-EMPTY)    //950 equal to 3.2 V
    int BATTERY_SENSE_PIN = A0;   // select the input pin for the battery sense point
    int batteryPcnt = 0, oldBatteryPcnt = 0;
    // Global variables for sensor values
    float temp = 25.0, hum = 50.0;
    float temp_last = 0.0, hum_last = 0.0;
    // Helper for calculate battery percentage
    int calc_pcnt(int value){
      int batteryPcnt = ((value - EMPTY) * SCALE);
      batteryPcnt = (batteryPcnt > 100) ? 100 : batteryPcnt;
      batteryPcnt = (batteryPcnt < 0) ? 0 : batteryPcnt;
      return batteryPcnt;
    void setup() {
      // use the 1.1 V internal reference
      //BME280 stuff
                      Adafruit_BME280::SAMPLING_X1,   // temperature
                      Adafruit_BME280::SAMPLING_NONE, // pressure
                      Adafruit_BME280::SAMPLING_X1,   // humidity
                      Adafruit_BME280::FILTER_OFF );
      oldBatteryPcnt = calc_pcnt(analogRead(BATTERY_SENSE_PIN));
    void presentation()
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo(SKETCHSTR, SKETCHVER);
      present(CHILD_ID_TEMP, S_TEMP, "Temperature");
      present(CHILD_ID_HUM, S_HUM, "Humidity");
    void loop() {
      //read temp and hum and lux
      temp = bme.readTemperature();
      temp = temp + BME280_TEMP_OFFSET;
      hum = bme.readHumidity();
      if(temp != temp_last){
        send(msgTemp.set(temp, 2));
        temp_last = temp;
      if(hum != hum_last){
        send(msgHum.set(hum, 2));
        hum_last = hum;
      // send the battery level
      batteryPcnt = calc_pcnt(analogRead(BATTERY_SENSE_PIN));
      if (batteryPcnt < oldBatteryPcnt) {
          oldBatteryPcnt = batteryPcnt;

    It's also hosted on github:


  • Sorry @se-O-matic , but I can't see any problem. Does the temperature recover with time? I only can imagine that you have a collision on air.

Log in to reply

Suggested Topics

  • 3
  • 24
  • 3
  • 2
  • 2
  • 2