battery level doesn't appear ?



  • Hello all,

    I have a node with switchs and dimmer, and I tried to send Battery level like that :

      if ((millis() - myTime) > 10000) { // toutes les dix secondes
        myTime = millis();
        gw.sendBatteryLevel(97,1);
      } else {
        if ((millis() - myTime) < 0) {
          myTime = millis();
        }
      }
    

    but in Domoticz I can't see the battery level ! however, I have the same code for two other nodes with temperature sensors and in this case It works ? is Battery level for temperature sensors only ?

    thanks


  • Mod

    What do you mean by "1" in "97,1"?
    The signature for sendBatteryLevel is

    void sendBatteryLevel(uint8_t level, bool ack=false);
    

    Sending 1 means the same as true, even though sending 1 is less clear than sending true. It should still work though.



  • hello,

    thanks for your answer. For me 97,1 means 97% and acknowledge. And the same code work properly with my other nodes with temperature sensors !

    Any other ideas ?



  • I have rain, light and temp sensor and battery level is working, so I think you can have it for almost any sensor type.
    Have you tried to remove everything except gw.sendbattery...

    Just to check?

    The last } does it have a { above if
    I guess you have otherwise you cannot compile but maybe that is in an IF loop or some other loop that doesn't work as expected


  • Hero Member

    @flylowgofast Is the actual sensor updating? From my experience Domoticz only updates/shows the new battery level when a new value is received for the sensor data..



  • Hello @flopp,

    I'll try this evening to remove all the code but gw.sendbattery...
    I think there isn't problem with { or }, perhaps you don't like my way to write code 😄

    thanks



  • hello @AWI,

    is there a way to verify if my sensor send a newx value ? because I can't use terminal with debug informations, I use Rx / Tx for an other purpose !

    thanks


  • Hardware Contributor

    @flylowgofast - Check Domoticz log, if the value updates you see it there.
    Or for more details, check serial log on your gateway. There you see all trafic. As AWI said, you wont see any updates on Domoticz if its the same value as before, Domoticz needs new value to update.



  • "Battery Level" is a internal message.
    See: http://www.mysensors.org/download/serial_api_15
    This means it is going to the gateway and nobody knows what the gateway is doing with it...
    Please correct me if I am wrong.


  • Hardware Contributor

    I have several nodes reporting battery level to Domoticz.



  • hello,
    here is logs from gateway

    2;4;1;1;3;70;0;3;0;9;send: 0-0-2-2 s=4,c=1,t=3,pt=0,l=1,sg=0,st=fail:7
    Finished
    0;0;3;0;18;PINGFinished
    2;4;1;1;3;70;0;3;0;9;send: 0-0-2-2 s=4,c=1,t=3,pt=0,l=1,sg=0,st=fail:7
    0;0;3;0;9;read: 1-1-0 s=255,c=3,t=0,pt=1,l=1,sg=0:97
    0;0;3;0;9;send: 0-0-1-1 s=255,c=3,t=0,pt=1,l=1,sg=0,st=ok:97
    1;255;3;0;0;97
    Finished
    0;0;3;0;18;PING0;0;3;0;9;read: 65-65-0 s=255,c=3,t=0,pt=1,l=1,sg=0:99
    0;0;3;0;9;send: 0-0-65-65 s=255,c=3,t=0,pt=1,l=1,sg=0,st=fail:99
    65;255;3;0;0;99
    0;0;3;0;9;read: 1-1-0 s=255,c=3,t=0,pt=1,l=1,sg=0:97
    0;0;3;0;9;send: 0-0-1-1 s=255,c=3,t=0,pt=1,l=1,sg=0,st=ok:97
    1;255;3;0;0;97
    Finished
    

    Is there a documentation to understand better ?

    thanks



  • Can you post your sketch here?



  • This is from my GW

    0;0;3;0;18;PING0;0;3;0;9;read: 12-12-0 s=255,c=3,t=0,pt=1,l=1,sg=0:98
    12;255;3;0;0;98
    0;0;3;0;9;read: 12-12-0 s=1,c=1,t=38,pt=7,l=5,sg=0:2.979
    12;1;1;0;38;2.979
    0;0;3;0;9;read: 12-12-0 s=0,c=1,t=23,pt=3,l=2,sg=0:66
    12;0;1;0;23;66
    Finished
    
    

    98% battery
    2.979 voltage
    66 lux



  • You can also restart your Node and then it will send all data again like, Sketchname, version and also all childs



  • my loop(){}

    // the loop routine runs over and over again forever:
    void loop() {
    
      // Process incoming messages (like config from server)
      gw.process();  
    
      //---------------Lecture des ouvertures de porte------------------
      doorOpenOffState = digitalRead(HALLOFFICEDOOR); // lecture Ă  chaque cycle (urgence)
      if (doorOpenOffState != doorOpenOffChange){
        gw.send(msgDoorOffice.setSensor(OFFICEDOOR).set(doorOpenOffState));
        doorOpenOffChange = doorOpenOffState;
      }
    
      doorOpenBedState = digitalRead(HALLBEDROOMDOOR); // lecture Ă  chaque cycle (urgence)
      if (doorOpenBedState != doorOpenBedChange){
        gw.send(msgDoorBedroom.setSensor(BEDROOMDOOR).set(doorOpenBedState));
        doorOpenBedChange = doorOpenBedState;
      }
      
      if (digitalRead(ECLEXT) != oldInterExt){
        oldInterExt = !oldInterExt;
        eclState = !eclState;
        gw.send(msgLightSwitch.set(eclState));
      }
    
      //---------------Envoi du niveau de batterie !! pour rester eveillé------------------
      /*if ((millis() - myTime) > 10000) { // toutes les dix secondes
        myTime = millis();
        gw.sendBatteryLevel(97,1);
      } else {
        if ((millis() - myTime) < 0) {
          myTime = millis();
        }
      }*/
      gw.sendBatteryLevel(97,1);
    
    // ---------------Traitement volet 1-----------------
      analogUpV1 = analogRead(UPV1);
      if ((analogUpV1 <25) && !manOnV1) { //analogUp proche de zéro et ancienne valeur niveau haut (en l'air)
        digitalWrite(TRIAC5, HIGH);
        digitalWrite(TRIAC2, LOW);
        triacTempoV1 = millis();
        triacManPriorityV1 = true;
        manOnV1 = true;
        memoStopV1 = false;
      } else {
        analogDownV1 = analogRead(DOWNV1);
        if ((analogDownV1 <25) && !manOnV1) { //proche de zéro
          digitalWrite(TRIAC5, LOW);
          digitalWrite(TRIAC2, HIGH);
          triacTempoV1 = millis();
          triacManPriorityV1 = true;
          manOnV1 = true;
          memoStopV1 = false;
        } else {
          if (analogUpV1 > 800 && analogDownV1 > 800 && !memoStopV1){ // les deux fils en l'air
            digitalWrite(TRIAC5, LOW);
            digitalWrite(TRIAC2, LOW);
            triacManPriorityV1 = false;
            manOnV1 = false;
            memoStopV1 = true;
          } else {
            if (!triacManPriorityV1){
              if (shutterOff1State && shutterOff2State) {
                shutterOff1State = false;
                shutterOff2State = false;
                digitalWrite(TRIAC5, LOW);
                digitalWrite(TRIAC2, LOW);
              } else {
                if (shutterOff1State) {
                  shutterOff1State = false;
                  digitalWrite(TRIAC5, HIGH);
                  digitalWrite(TRIAC2, LOW);
                  triacTempoV1 = millis();
                } else {
                  if (shutterOff2State) {
                    shutterOff2State = false;
                    digitalWrite(TRIAC5, LOW);
                    digitalWrite(TRIAC2, HIGH);
                    triacTempoV1 = millis();
                  }
                }
              }
            }
          }
        }
      }
      if (((triacTempoV1 + TEMPOOPENV1) < millis())) {
        digitalWrite(TRIAC5, LOW);
        digitalWrite(TRIAC2, LOW);
        triacManPriorityV1 = false;
      }
    
    // --------------------------Traitement volet 2------------------------
      analogUpV2 = analogRead(UPV2);
      if ((analogUpV2 <25) && !manOnV2) { //analogUp proche de zéro et ancienne valeur niveau haut (en l'air)
        digitalWrite(TRIAC3, HIGH);
        digitalWrite(TRIAC4, LOW);
        triacTempoV2 = millis();
        triacManPriorityV2 = true;
        manOnV2 = true;
        memoStopV2 = false;
      } else {
        analogDownV2 = analogRead(DOWNV2);
        if ((analogDownV2 <25) && !manOnV2) { //proche de zéro
          digitalWrite(TRIAC3, LOW);
          digitalWrite(TRIAC4, HIGH);      
          triacTempoV2 = millis();
          triacManPriorityV2 = true;
          manOnV2 = true;
          memoStopV2 = false;
        } else {
          if (analogUpV2 > 800 && analogDownV2 > 800 && !memoStopV2){ // les deux fils en l'air
            digitalWrite(TRIAC3, LOW);
            digitalWrite(TRIAC4, LOW);        
            //triac3 = false;
            //triac4 = false;
            triacManPriorityV2 = false;
            manOnV2 = false;
            memoStopV2 = true;
          } else {
            if (!triacManPriorityV2){
              if (shutterBed1State && shutterBed2State) {
                shutterBed1State = false;
                shutterBed2State = false;
                digitalWrite(TRIAC3, LOW);
                digitalWrite(TRIAC4, LOW);            
              } else {
                if (shutterBed1State) {
                  shutterBed1State = false;
                  digitalWrite(TRIAC3, HIGH);
                  digitalWrite(TRIAC4, LOW);              
                  triacTempoV2 = millis();
                } else {
                  if (shutterBed2State) {
                    shutterBed2State = false;
                    digitalWrite(TRIAC3, LOW);
                    digitalWrite(TRIAC4, HIGH);                
                    triacTempoV2 = millis();
                  }
                }
              }
            }
          }
        }
      }
      if (((triacTempoV2 + TEMPOOPENV2) < millis())) {
        digitalWrite(TRIAC3, LOW);
        digitalWrite(TRIAC4, LOW);      
        triacManPriorityV2 = false;
      }
    }
    


  • @flylowgofast
    Look ok


  • Hero Member

    @flylowgofast for information on the logs take a look at the debug topic



  • My real problem is not to send battery level. I try to do that because after 24 or 48 hours my node stop sending messages . So, I hoped that was a way to make it awake !


  • Hero Member

    @flylowgofast From what I read from your sketch you seem to do some high voltage / current switching. Especially the radio doesn't like all kinds of electronic disturbances (emc etc.) To avoid lockups you need to pay special attention/separate power supplies (if you haven't done already).



  • Hello AWI,

    Thanks for your reply, yes my node trigs 5 triacs. I use snubber, regulator, capacitor. And ond the other hand, all commands to the node work properly ? just battery level doesn't work and after several hours NRF24L01 stop to work.
    I would like to reset NRF24L01 but with MySensors we don't have direct access to it anymore. Perhaps there is a way to reset the sketch globaly ?

    thanks for your help



  • @flylowgofast said:

    My real problem is not to send battery level. I try to do that because after 24 or 48 hours my node stop sending messages . So, I hoped that was a way to make it awake !

    It would have been nice if you had wrote this in your first post.😞
    So everyone could focus on the main problem



  • Hello @flopp ,

    Sorry I was myself focus on this second problem that's interesting to solve too ?
    At the end twice aren't solve ! 😞



  • Hello all,

    At the end, I choose to do a software reset every 24 hours. This solution is very bad for me but it works !!

    bye


  • Hardware Contributor

    @flylowgofast One simple thing can be to move the radio away a bit and see if that helps. Its as AWI said probably interferance power-radio.



  • Hello @sundberg84,
    I already considered this idea but my node have been running perfectly for two days before failed. So I think, power consideration are not the problem. I can trigg on and off my shutters many and many times without problem.


Log in to reply
 

Suggested Topics

  • 1
  • 3
  • 3
  • 5
  • 3
  • 10

1
Online

11.4k
Users

11.1k
Topics

112.7k
Posts