How to change sender, command, msg type, payload type, ... ?



  • Hi everyone, I'm using UNO to build a Serial Gateway and Pro mini to build a sensor node. I use GatewaySerial and AirQualitySensor in Mysensors' example to test the code. I want to send continuously a random number from the AirQualitySensor to GatewaySerial. This is what appearing on my Serial Monitor:
    0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;TSM:RADIO:OK
    0;255;3;0;9;TSM:GW MODE
    0;255;3;0;9;TSM:READY
    0;255;3;0;14;Gateway startup complete.
    0;255;0;0;18;2.0.0
    0;255;3;0;9;No registration required
    0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
    0;255;3;0;9;TSP:MSG:READ 255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;TSP:MSG:BC
    0;255;3;0;9;TSP:MSG:FPAR REQ (sender=255)
    0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL)
    0;255;3;0;9;TSP:MSG:GWL OK
    0;255;3;0;9;TSP:MSG:SEND 0-0-255-255 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=bc:0
    0;255;3;0;9;TSP:MSG:READ 255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;TSP:MSG:BC
    0;255;3;0;9;TSP:MSG:FPAR REQ (sender=255)
    0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL)
    0;255;3;0;9;TSP:MSG:GWL OK
    0;255;3;0;9;TSP:MSG:SEND 0-0-255-255 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=bc:0
    0;255;3;0;9;TSP:MSG:READ 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
    255;255;3;0;3;

    Could you tell me how to change the structure of this line "0-0-255-255 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=bc:0" like in this example:
    Building an IoT Humidity Sensor – 07:15
    — R Brown

    Thank you very much.


  • Plugin Developer

    @npkhoi

    Look at the API page on the mysensors web. You'll find the command to send a message there and lots more.

    I would first make sure I have comms up properly though, before creating a more complicated sketch.

    The last line from your gateway log is a request for node id from the node. You need a controller connected that can hand out node ids and reply to the request. The gateway is not responsible for handing out node ids. The alternative is to specify a fixed node id in your sketch. You should find the command for this also on the api page.

    Also have a look at the sticky post in the troubleshooting section. You should find links to posts explaining the debug output from the log.



  • Thank you martinhjelmare.
    I have read the page https://www.mysensors.org/download/serial_api_20 and I know the format of the message frame but I don't know how to change these things in the sketch . I spent a week trading code in the library and got nothing @@
    Maybe I'm so noob to fine the way to build just an example 😥 Could you give me a link that shows how to change the message frame ?


  • Mod

    @npkhoi I'n not sure I understand what you are trying to do, but https://www.mysensors.org/download/sensor_api_20#message-constructor describes how the message object can be interacted with.



  • @mfalkvidd I've read this link https://www.mysensors.org/download/sensor_api_20#message-constructor too, but I'm so confused what I have to do to change "255 - 255 - 255 - 255" to "2 - 2 - 0 - 0", I don't know what to do with the code in the link. Where do I have to change the code to configure the message frame ?


  • Mod

    @npkhoi I think you are trying to work on the wrong level. MySensors has objects to interact with so you don't need to assemble and parse strings.

    or maybe I just don't understand what you are trying to achieve.



  • @mfalkvidd I just want to use AirQualitySensor to send a random number to GatewaySerial (because I don't have an Air Sensor so I send a random number). That's exactly what I want to do now.


  • Mod

    @npkhoi thanks for e plaining. Then it should be sufficient to replace

    send(msg.set((int16_t)ceil(valMQ)));
    

    with

    send(msg.set(random()));
    

Log in to reply
 

Suggested Topics

1
Online

11.2k
Users

11.1k
Topics

112.5k
Posts