Battery voltage sensor is no longer recognized by Homeassistant



  • hello all,
    i am a newbie when it comes to mysensors. nevertheless, by copy and paste i have built a sensor that sends the battery voltage from my car to my homeassistant every 20 min. My car is parked by the road and is not used much. so i want to keep an eye on the voltage.
    so far this has worked for about 6 months.
    for some inexplicable reason, it no longer does.
    so i can rule out a hardware error i turned it off and set up a test sensor on a plug-in module.
    the debug values seem ok to me , but i can't judge it seriously. but it is not detected by my serial gateway.
    can someone help me and tell what can be wrong?
    i will share here the debuginfo and the sketch.
    i hope for your help, thanks.

    16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2
    26 TSM:INIT
    28 TSF:WUR:MS=0
    34 TSM:INIT:TSP OK
    36 TSM:INIT:STATID=122
    38 TSF:SID:OK,ID=122
    40 TSM:FPAR
    45 ?TSF:MSG:SEND,122-122-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    440 TSF:MSG:READ,0-0-122,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    445 TSF:MSG:FPAR OK,ID=0,D=1
    459 TSF:MSG:READ,122-0-122,s=255,c=3,t=8,pt=1,l=1,sg=0:1
    626 TSF:MSG:READ,6-6-122,s=255,c=3,t=8,pt=1,l=1,sg=0:1
    777 TSF:MSG:READ,4-4-122,s=255,c=3,t=8,pt=1,l=1,sg=0:1
    2052 TSM:FPAR:OK
    2053 TSM:ID
    2054 TSM:ID:OK
    2056 TSM:UPL
    2059 TSF:MSG:SEND,122-122-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2070 TSF:MSG:READ,0-0-122,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2075 TSF:MSG:PONG RECV,HP=1
    2078 TSM:UPL:OK
    2079 TSM:READY:ID=122,PAR=0,DIS=1
    2084 TSF:MSG:SEND,122-122-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    2093 TSF:MSG:READ,0-0-122,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    2100 TSF:MSG:SEND,122-122-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
    2109 TSF:MSG:SEND,122-122-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
    2138 TSF:MSG:READ,0-0-122,s=255,c=3,t=6,pt=0,l=1,sg=0:M
    2146 TSF:MSG:SEND,122-122-0-0,s=255,c=3,t=11,pt=0,l=9,sg=0,ft=0,st=OK:Voltmeter
    2155 TSF:MSG:SEND,122-122-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
    2163 TSF:MSG:SEND,122-122-0-0,s=1,c=0,t=30,pt=0,l=12,sg=0,ft=0,st=OK:KFZ-Batterie
    2423 TSF:MSG:SEND,122-122-0-0,s=2,c=0,t=30,pt=0,l=16,sg=0,ft=0,st=OK:Versorgungs-Akku
    2931 !MCO:SND:NODE NOT REG
    3184 !MCO:SND:NODE NOT REG
    3688 TSF:MSG:SEND,122-122-0-0,s=1,c=2,t=38,pt=0,l=0,sg=0,ft=0,st=OK:
    3696 TSF:MSG:SEND,122-122-0-0,s=2,c=2,t=38,pt=0,l=0,sg=0,ft=0,st=OK:
    Presentation done
    3702 MCO:REG:REQ
    3707 TSF:MSG:SEND,122-122-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
    3715 TSF:MSG:READ,0-0-122,s=255,c=3,t=27,pt=1,l=1,sg=0:1
    3720 MCO:PIM:NODE REG=1
    3723 MCO:BGN:STP
    3724 MCO:BGN:INIT OK,TSP=1
    3729 TSF:MSG:SEND,122-122-0-0,s=1,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:11.5
    3774 !TSF:MSG:SEND,122-122-0-0,s=2,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=NACK:5.0
    KFZ-Batterie: 11.5
    Versorgungs-Akku: 5.0
    
    3781 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
    3789 TSF:TDI:TSL
    3790 MCO:SLP:WUP=-1
    3792 TSF:TRI:TSB
    3802 !TSF:MSG:SEND,122-122-0-0,s=1,c=1,t=38,pt=7,l=5,sg=0,ft=1,st=NACK:15.6
    3811 !TSF:MSG:SEND,122-122-0-0,s=2,c=1,t=38,pt=7,l=5,sg=0,ft=2,st=NACK:5.7
    KFZ-Batterie: 15.6
    Versorgungs-Akku: 5.7
    
    3819 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
    3827 TSF:TDI:TSL
    
    

    and here the sketch

    
    #include <Arduino.h>
    
    // Enable debug prints
     #define MY_DEBUG
    
    #define MY_RADIO_RF24
    #define MY_NODE_ID 122                // Immer eindeutig pro Sensor
    #define CHILD_ID_KFZ_Akku 1
    #define CHILD_ID_Versorgungs_Akku 2 
    //#define CHILD_ID_BetriebsSpannung 3 
    
    const float INTERN = 1.1; // bestimmt pro IC
    float vcc = 5.0;          // wird dann gemessen
    int sleepTime = 5000;     // 4sec.
    int sleepTimePin = 6;     // Testpin. gegen Masse = 10min. Offen=4sec.
    int KFZ_Batterie_SENSE_PIN = A2;          // KFZ-Akku-Spannung
    int Versorgungs_Batterie_SENSE_PIN = A1;  // Betriebs-Akku-Spannung / weil A0 defekt war wurde es getausch
    float KFZFaktor = 0.01523;        //      // mit Spannungsteiler von 16V auf 1.1V gerechnet (470Ohm Parallel und 6,8k in Reihe)
    float VersorgungsFaktor=0.00560;        // über Spannungsteiler muss 1,1v ergeben von max 5v (220k und 50K)
    int OldKFZBatteriePcnt = 0;
    int OldVersorgungsBatteriePcnt = 0;
    #include <MySensors.h>
    
    MyMessage msgKFZ_Voltage(CHILD_ID_KFZ_Akku, V_VOLTAGE);
    MyMessage msgVersorgungs_Akku(CHILD_ID_Versorgungs_Akku, V_VOLTAGE);
    
    
    
    //*******************************
    void presentation()
    //*******************************
    {
      sendSketchInfo("Voltmeter", "1.0");
      present(CHILD_ID_KFZ_Akku, S_MULTIMETER, "KFZ-Batterie");
      delay(250);
      present(CHILD_ID_Versorgungs_Akku, S_MULTIMETER, "Versorgungs-Akku");
      delay(250);
      delay(250);
      send(msgKFZ_Voltage.set(6, 1));
      delay(250);
      send(msgVersorgungs_Akku.set(6, 1));
      delay(250);
      delay(250);
      request(CHILD_ID_KFZ_Akku, V_VOLTAGE);
      request(CHILD_ID_Versorgungs_Akku, V_VOLTAGE);
      Serial.println(F("Presentation done"));
    
    }
    
    //*******************************
    void setup()
    //*******************************
    {
    // use the 1.1 V internal reference
      analogReference(INTERNAL);
    
      pinMode(sleepTimePin, INPUT_PULLUP);    // Pin für Schlafzeit
      if (digitalRead(sleepTimePin) == LOW) sleepTime=600000;
      else sleepTime=5000; 
    }
    
    //*******************************
    void loop()
    //*******************************
    {
      //Serial.println("Aufwachen und senden");
      //delay(100);
    
      float KFZ_voltage = analogRead(KFZ_Batterie_SENSE_PIN);
      float Versorgungs_voltage = analogRead(Versorgungs_Batterie_SENSE_PIN);
    
       KFZ_voltage = KFZ_voltage * KFZFaktor;
       Versorgungs_voltage = Versorgungs_voltage * VersorgungsFaktor;
    
      float KFZBatteriePcnt = KFZ_voltage; // /25;    // Sendet nur bei Änderung der Spannung um 0.5V...jetzt immer bei änderung
      float VersorgungsBatteriePcnt = Versorgungs_voltage; // /25;
    
      if ((OldKFZBatteriePcnt != KFZBatteriePcnt) || (OldVersorgungsBatteriePcnt != VersorgungsBatteriePcnt )) {
        send(msgKFZ_Voltage.set(KFZ_voltage, 1));
        send(msgVersorgungs_Akku.set(Versorgungs_voltage, 1));
        Serial.print(F("KFZ-Batterie: ")); Serial.println(KFZ_voltage, 1);
        Serial.print(F("Versorgungs-Akku: ")); Serial.println(Versorgungs_voltage, 1);
        Serial.println();
        OldKFZBatteriePcnt = KFZBatteriePcnt;
        OldVersorgungsBatteriePcnt = VersorgungsBatteriePcnt;
        
      }
    
      sleep(sleepTime);
    }
    

    i must add that i already have 13 other sensors and actuators running.
    These are running perfectly.



  • it's a pity that no one here seems to be able to help.

    I have been looking for solutions for several days.

    I have restarted homeassistant and mysensors.
    what i have found out so far is:

    the serial gateway does not work
    the wemos d1 gateway works.

    whereas both gateways all others (13 pieces with 20 entities) are recognized immediately without any problems.

    only my voltmeter in the car does not work with the serial gatreway

    very strange

    Translated with www.DeepL.com/Translator (free version)



  • tries to create a virtual value, a false sensor.

    "It worked for about 6 months" ... wear and tear or a case of a component ???

    courage you will find

    ( it is difficult to help a person on a material problem without seeing anything )



  • @JeeLet thank you for your feedback.
    I have already replaced all components, so I assume that there is no hardware defect.
    i think i have found the error. at least that's how it looks.
    i have changed the gateway. before it was a TCP gateway with a Wemos D1.
    I want to get away from WiFi, so now I use a serial gateway.
    as described all sensors and actuators work with this gateway. only not S_Multimeter with V_Voltage.
    To get around my programming errors here as well, I used a standard sketch from github.
    https://github.com/barduinor/MySensors-Barduino/tree/development/examples/MockMySensors
    here i simply enabled #define ID_S_Multimeter to it and uploaded it.

    with the serial gateway only S_ARMED and S_DOOR are recognized.
    with the TCP gateway S_Multimeter is also recognized.

    maybe someone with Serial Gateway can also try this and confirm my assumption or not.
    There must be no other circuit connected. one arduino, one nrf24 and one sketch

    best regards



  • look here https://www.home-assistant.io/integrations/mysensors#custom-unit-of-measurement
    the "CUSTOM UNIT OF MEASUREMENT" part

    tests with type V_LEVEL or V_UNIT_PREFIX

    if it works the problem comes from the version of MySensors Arduino library ?
    Library API



  • @Branther said in Battery voltage sensor is no longer recognized by Homeassistant:

    3802 !TSF:MSG:SEND,122-122-0-0,s=1,c=1,t=38,pt=7,l=5,sg=0,ft=1,st=NACK:15.6
    3811 !TSF:MSG:SEND,122-122-0-0,s=2,c=1,t=38,pt=7,l=5,sg=0,ft=2,st=NACK:5.7

    st=NACK means the message isn't acknowledged by the gateway. So could it be the message isn't received by home assistant?



  • sorry for my late reply. i don't have time to continue at the moment.
    but i will continue to report when i have more time. at the moment it is very complicated.
    the problem still exists and i will report back.
    thanks for your feedback



  • so, hello again.
    i must apologize. the errors were mine.
    I had several defective nrf24l
    i also had a couple of faulty ESP8266s to top it off
    In addition, the power supply regulated to 3.3v for the transmitter Arduino was not sufficient. etc. etc..
    I have experimented a lot.
    Now finally everything runs as expected
    (I hope for a long time)
    this post can be closed.
    best regards.



  • thanks for the feedback.

    can we say that with cheap material (no-name) we pay the rest of the bill later?
    (what was the model??)



  • yes, absolutely. i always order all my components from aliexpress.
    i don't think it makes any difference which dealer i use there.
    you can be lucky and sometimes not
    sometimes you can tell right away, for example an NRF module didn't have an IRQ. sometimes you have to search specifically to get the nrf24l plus model for example, which is different from the normal nrf module.
    in germany the parts are 3-4 times more expensive.
    so i put up with it. if you have several components, you can swap them and limit the error.
    thanks again


Log in to reply
 

Suggested Topics

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

16
Online

11.3k
Users

11.1k
Topics

112.6k
Posts