How to use sendBatteryLevel on the controller?



  • Hi there,

    Quick question, I read a lot about using sendBatteryLevel() on my nodes, however, I cannot find any information on how this is actually used on the controller side.

    My gateway forwards to MQTT, will it just generate a message for the battery level or how is it used?



  • @chbla I use serial to Domoticz where it records battery voltage. If it falls below 1.2v I have it set to send an alarm message...


  • Mod

    @chbla controllers do whatever they want, so the question does not have a general answer. Are you developing your own controller? Or are you using a specific controller?



  • Sorry I mixed up things - what I mean is, if I have a gateway that forwards to MQTT - regardless of the controller - how does the sendBatteryLevel data end up in the queue? Obviously it has different semantics that "normal" messages sent with send() ?


  • Mod

    @chbla I see. Thanks for clarifying.

    I am compiling a MQTT gateway to find out. Compiling takes a while but I'll report back as soon as it is ready.


  • Mod

    @chbla on my gateway, messages are sent to topic mysensors-out/0/255/3/0/0
    mysensors-out is configurable when you build the mqtt gateway
    The first 0 is probably the originating node (I let the gateway report its own battery level and the gateway has ID 0).
    255 is the child ID. Battery level always has child ID 255.
    I am not sure about the last two zeros.

    The payload is a string with the battery level. For 42% the string will be "42".



  • @mfalkvidd Thanks a lot for trying this out! I wondered if it is interpreted or used in a special way by the gateway already.
    But in this case I can do that myself.

    Thanks again!


  • Mod

    @chbla great. In case you want to reproduce what I did, use the following configure command for the raspberry pi gateway (I think it will run on any Linux machine):

    ./configure --my-transport=none --my-gateway=mqtt --my-controller-ip-address=127.0.0.1 --my-mqtt-publish-topic-prefix=mysensors-out --my-mqtt-subscribe-topic-prefix=mysensors-in --my-mqtt-client-id=mygateway1
    

    (this assumes you have a mqtt broker on localhost)

    I added the following to examples_linux/mysgw.cpp:

    void loop(){
            sendBatteryLevel(42);
            wait(5000);
    }
    

    Then just run

    make && sudo ./bin/mysgw -d
    


  • Thanks, I'll try that!


Log in to reply
 

Suggested Topics

  • 4
  • 8
  • 20
  • 15
  • 9
  • 2

10
Online

11.4k
Users

11.1k
Topics

112.7k
Posts