Mysensors protocol requirements



  • Hi. I have made an Arduino sketch that communicates with my PC using the Mysensors protocol. However, I am not using the Mysensors library, but done my own implementation of the protocol.

    The reason for this approach is that I have mounted a 433 MHz receiver and transmitter on the Arduino. The receiver I use for receiving the signal directly from my weather station in the garden and the transmitter I use for sending commands directly to some cheap RF plugs.

    In other words, the units I communicate with on 433 MHz are not Mysensors units, and my Arduino sketch is just translating the signal to/from the 433 MHz units to the Mysensors protocol. In this way I can use existing home automation software that already supports Mysensors.

    So far I have tested it with Domotics and MYSController, and everything seems to work just fine. However, I have a few questions to the Mysensors protocol that I hope you can help me with:

    1:
    Is it required/mandatory that each sensors/actuator sends a presentation message? This would be troublesome for me to implement, since my "gateway" sketch does not know which sensors/actuators I have when it boots up. Normally the sensors/actuators would send the presentation message themselves when they are booted, but this does of course not happen in my case, since my sensors/actuators that communicates on 433MHz are not Mysensors devices. Both Domoticz and MYSController seems to register the sensors the first time they send a message (for example the first time the weather station sends the temperature). Is it ok to do it like this, or could there be any cases where this could cause problems?

    2:
    At the moment my sketch does not support Ack, meaning that all Mysensors messaages I send to the PC have Ack parameter set to 0, and the sketch does not do anything if it receives and message from the PC where the Ack parameter is set to 1. If it is required to support Ack, then how does the aknowledge telegram look like, and what should be done if no acknowledge is received?

    3:
    In which cases would the req message type be used?

    4:
    Are there any of the internal messages that are required/mandatory to be supported in my sketch?

    Thanks.


  • Admin

    @jokkemokke

    1. Some controllers rely on and use the presentation message to know which device to create. When you receive a 433Mhz message can you determine it's type? Couldn't you just send the presentation message the first time (after startup) you receive a message from a new 433-sender?

    2. That is fine.

      If you send out a message with request-for-ack enabled from controller. The message travels all the way to its final destination. The library then issues an ack message which is sent back to gateway. Gateway produces a serial message with the ack parameter set to 1. Normal incoming sensor-data has ack set to 0 (as it isn't an ack).

      In your case you don't need to handle this as I imagine your don't have any actuators that you want to control? If you do... then just send the same message back to controller to simulate the ack-behaviour (when controller requests an ack).

    3. The req message type is used to request data from a node. It is up to the node to handle the reply. I don't think you need to implement this.

    4. You should probably answer the version request (I_VERSION) message. And send a startup-complete message when you have everything up and running in your gateway. (I_GATEWAY_READY),



  • Thanks for the reply.

    You write that the sketch should send I_GATEWAY_READY to the controller when it has finished starting up. But how can I be sure that a controller is connected and that this message will be seen (I guess the same goes for the presentation messages).

    My sketch communicates with the controller using ethernet. The ethernet part is handled the same way as in the EthernetGateway sketch from the Mysensors library. This sketch uses the client.available(), but this function does not return anything unless the controller actually sends some data (it does not return when the controller connects).

    So I am wondering how I can see when a controller is connected, so that I know when I should start sending the messages that only are send during startup.


  • Admin

    You can send it the first time you have something available from a new client.



  • But teoretically it could take forever before the controller sends something to the gateway, since it seems that it only sends a message if you press a button in the controller to activate a actuator or something.

    Maybe it would be better to have a delay in the sketch before it sends the startup message to the controller, and the hope that a controller connects during this delay?


  • Admin

    I cannot answer for all controller implementations. But the Vera-plugin asks for version when it start up.

    https://github.com/mysensors/Vera/blob/master/L_Arduino.lua#L650

    This is how we do it in the dev-branch
    https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino#L177


Log in to reply
 

Suggested Topics

0
Online

11.3k
Users

11.1k
Topics

112.5k
Posts