MySensors Serial Gateway minimal example to send data


  • Contest Winner

    Hello everybody,

    I'm just trying the MySensors protocol stack. I thought the easiest way to get it work and understand would be to have to nodes: one serial gateway and one dimmer.

    I then thought i could connect the serial gateway to my favorite terminal program and see what the nodes are talking, I also thought that i should be able to send commands.

    So I set everything up and I get the incoming messages on the serial terminal program:
    0;0;3;0;14;Gateway startup complete.
    0;0;3;0;9;read: 3-3-0 s=255,c=0,t=17,pt=0,l=5:1.4.1
    3;255;0;0;17;1.4.1
    0;0;3;0;9;read: 3-3-0 s=255,c=3,t=6,pt=1,l=1:0
    3;255;3;0;6;0
    0;0;3;0;9;read: 3-3-0 s=0,c=0,t=4,pt=0,l=5:1.4.1
    3;0;0;0;4;1.4.1
    0;0;3;0;9;read: 3-3-0 s=255,c=3,t=11,pt=0,l=11:DimmableLED
    3;255;3;0;11;DimmableLED
    0;0;3;0;9;read: 3-3-0 s=255,c=3,t=12,pt=0,l=3:1.1
    3;255;3;0;12;1.1
    0;0;3;0;9;read: 3-3-0 s=0,c=2,t=3,pt=0,l=0:
    3;0;2;0;3;

    This looks quite good to me. However now I want to send something so I type
    3;0;1;0;3;50;\n
    (of cause the \n is sent by the terminal program, i.e. it is the linefeed)

    I expect this means send to node 3, childid 0, set command (1), no ack (0), V_dimmer type (3); value : 50

    Then the DImmer node also seems to receive something because it says
    read: 0-0-3 s=0,c=0,t=0,pt=0,l=1:\n

    However I cannot see any changes in the brightness of the conneced LED. I also dont understand why:
    3;0;1;0;3;99; does not work??!

    I think I have something clearly missunderstood about any of the concepts? I hope you can help me.

    Thanks
    Dirk_H


  • Admin

    @Dirk_H said:

    3;0;1;0;3;50;\n

    What happens if you send (without the last semicolon):
    3;0;1;0;4;50\n

    But the received debug message looks strange though.... not at all right.



  • try to send with ack "3;0;1;1;3;5" and see if the node response, im have the same sketch with led and only with value more than 70% the led turn on other value still off


  • Contest Winner

    Ok I tried to send the suggested messages:

    3;0;1;0;4;50 (without semicolon) : nothing happnes, i.e. the gateway does not even try to send (tx led also not blinking, although rx light on ftdi usb->ttl chip is blinking)

    3;0;1;0;4;50; (with semicolon) returns "0;0;3;0;9;send: 0-0-3-3 s=0,c=0,t=0,pt=0,l=1,st=ok:" on gateway and "read: 0-0-3 s=0,c=0,t=0,pt=0,l=1:\n" on the dimmer node

    Exaclty the same readings for 3;0;1;0;3;50; in case you menat 3 instead of 4 (the latter 3)

    3;0;1;1;3;5 does not work (does not work with semicolon at the end and does not work without it)

    3;0;1;1;3;50; retruns the same messages as the 3;0;1;0;4;50;

    Thanks for your efforts, I really hope that we can find the mistake. However may I assume that in principle it should be possible to send from the serial gateway with a terminal program as I proposed?



  • you try send with the arduino terminal?


  • Admin

    fishy...

    You shouldn't have that last semicolon. It could (potentially) confuse the parser on the gateway.

    Guess you've tried the different newline modes available in serial monitor.

    Your radio communication seems to work anyway. Always something 😉


  • Contest Winner

    Hmm ok, without the last semicolon nothing works - it does not try to send.
    I forgot to mention that I use a Arduino mini pro 3.3V @ 8MHz. Somewhere I read that the gateway should have 16Mhz- but because everything else (i.e. receiving) worked, I thought 8MHz would also work..

    Because of that I tried an Arduino Nano running on 16MHz -> and THIS WORKS. 😄

    If one changes the MySensors.h Baudrate to e.g. 38400 than everything also works fine with the 8MHz.

    However I think it is a very bad behaviour that receive works 100% fine but send not, evil computers 😀

    BTW, can I also change the lib files when working in a cloned codebender sketch?

    Thanks for your support!


  • Admin

    @Dirk_H said:

    Interesting findings.

    BTW, can I also change the lib files when working in a cloned codebender sketch?

    Not unless you upload/overwrite with your own lib. Probably easier to work locally when doing "advanced" stuff.'


  • Contest Winner

    One last thing I'd like to clarify after re-reading my previous post.

    The correct send string I entered in the terminal is without trailing ";" - like it was supposed before. As mentioned, the problem has been the BAUD rate of 156k with 8MHz crystal..

    So the correct command which will change the PWM -Dimmer level on node 3 to 50% is:

    3;0;1;0;3;50\n



Suggested Topics

51
Online

11.4k
Users

11.1k
Topics

112.7k
Posts