Issues reading from serial gateway



  • Hi all,

    I am trying to setup a simple example. I use 2 Pro Mini with NRF24L01 to create simple binary sensor and serial gateway. I read the output from the serial gateway but the values read are not changing when the switch is toggled.
    The sensor uses this simple code: http://www.mysensors.org/build/binary#binaryswitchsensor-example
    And gateway is this: http://www.mysensors.org/build/serial_gateway No modifications to any of them. I do not use any controller, I was to de-serailize the output from the serial port myself on a PC for now.

    I have the output from the serial monitor which is following for the sensor and serial gateway:

    door sensor:
    req id
    send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
    sensor started, id=255, parent=0, distance=1
    req id
    send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
    req id
    send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
    req id
    send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
    req id
    send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:

    serial gateway:
    0;0;3;0;9;gateway started, id=0, parent=0, distance=0
    0;0;3;0;14;Gateway startup complete.
    0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
    255;255;3;0;3;
    0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
    255;255;3;0;3;
    0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
    255;255;3;0;3;
    0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
    255;255;3;0;3;

    I have searched this forum and is seems the issue might be the sensor trying to get the ID (as per the "req id" output). Any idea how to fix this?

    Thanks!



  • Change http://www.mysensors.org/build/binary#binaryswitchsensor-example line 46

    gw.begin();
    

    to

    gw.begin(null, 10, false);
    

    Where 10 is in this example the Node ID



  • I see, great, thank you! Is there a way how to assign the ID of the node from outside, without a controller? Let's say, there will be a number of nodes, sensors being turned on or off and the ID's should be assigned using the serial gateway from the connected PC. I guess this is what the controllers must be doing, I just want to control it myself.
    Thank you



  • Exactly, It's the controllers job to give out ID's to the Node's. There's no way around other then setting the Node ID in the sketch as i mentioned above.



  • Thank you for the response, however it does not make sense to me. How would it be possible for a controller to assign the ID? There must be some set of commands (API) on the node that are used by the controllers to assign the node ID's, right? I basically want to write a code that will act as a controller in terms of assigning the ID's to the nodes. Is this possible?
    Thanks!



  • Sure, thats what all the controllers do.

    Have a read on the API page



  • Thank you for pointing me to this direction. Happy New Year!



  • Hi, I have read the whole API documentation but still do not seem to find the way to configure the node ID. I have found this topic http://forum.mysensors.org/topic/350/problems-getting-sensorid/11 but sending the command "255;255;3;0;4;1" to the node did not help though. I would appreciate any hints on this topic. Thank you!


  • Plugin Developer

    @pelnarp said:

    Hi, I have read the whole API documentation but still do not seem to find the way to configure the node ID. I have found this topic http://forum.mysensors.org/topic/350/problems-getting-sensorid/11 but sending the command "255;255;3;0;4;1" to the node did not help though. I would appreciate any hints on this topic. Thank you!

    @pelnarp you should complete each serial command with \n(indicates command completed), your command should be 255;255;3;0;4;1\n



  • I am trying to send the values, but nothing happens. I am sending "255;255;3;0;4;1\n" over serial port (USB) to the serial gateway, but this does not seem to be processed. Either it is not sent to the sensor at all, or the sensor does not react. I am trying to send this from either Serial Monitor in the Arduino Studio or from my C# code, console app. The serial port works and reads the values properly, however sending this sequence seems to be an issue.



  • Ok, I have figured this out. When sending the value via the serial port there must be a delay between the characters (3ms). Therefore I do something like this (schematically), which works:

    foreach (char c in "255;255;3;0;4;1")
    {
    serialPort1.Write(c.ToString());
    Thread.Sleep(3);
    }



  • Hi, to all!

    My situation was exatly the same, that "pelnarps" had! My sensor couldn't get ID from gw, and gave the same results at both ends (gw, and sensor side). Changing gw.begin() as "ericdvb" suggested, solved this issue.
    Thanks ericdvb, and pelnarps! I convinced, that this issue can be solved decreasing baudrate, isn't it!


  • Mod

    Welcome to the MySensors forum @ElGuapo !
    The gw never gives out ID. The ID is given from your controller, or handled manually by setting ID in gw.begin if you prefer that.



  • Hi, mfalkvidd! Thanks for your fast replay. I'm new in Home automation. Actually I try to build my sample system, based on serial gateway. I have my gateway connected to Openhab as controller, and now started to works finally with a temperature sensor.
    I spent a lot of time trying to connect sensor to gateway, with no success. Just that piece of information needed to overcome.
    Thanks for all!


Log in to reply
 

Suggested Topics

  • 1
  • 10
  • 6
  • 1
  • 3
  • 2

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts