How to know the node ids assigned by the mqtt gateway to the sensors?



  • Hi,

    I have a mqtt gateway running on arduino from mysensors library. I also have an openhab controller running on a raspberry pi connected to the arduino uno through the ethernet shield. I am trying to create my first item on openhab and I understand that the format required is
    MyMQTT/20/0/V_TEMP where 20 and 0 are node id and sensor id respectively.

    I can see following message on the serial monitor

    Started!
    0;0;3;0;9;read: 20-20-0 s=1,c=1,t=16,pt=0,l=1:1

    1. How do I configure the node id and the sensor id?
    2. Is it assigned automatically or do I assign it statically?
    3. How do I understand the above output on the serial monitor?


  • @amitach I have the same setup and I use a MQTT-Client for testing: http://www.jensd.de/wordpress/
    You have to stop OpenHAB, because only one connection to the gateway is possible.
    Usage:

    • start client
    • create a profile: Extras / Connection Profiles
    • connect with this profile
    • click button "Subscribe"
    • choose "Topic" : # (see wildcards: http://mosquitto.org/man/mqtt-7.html )
    • click button "Subscribe" (on the right from field "Topic"

    Now you see all messages from your sensor.



  • If you have any questions or comments regarding MQTT.fx please don't hesitate to get in touch with me!



  • @Jerady works with older verions of MQTT.fx 0.0.12 on win 7 32 bit .. the newer one is only for 64 bit machine.. cheers



  • @amitach im able see on mqttfx on windows with incoming msg of arduino senting temp and hum (MyMQTT/21/0/v_HUM with 41.0 below.. appear to be working on this machine while the openhab is running as server on this pc for testing .... ive check the openhab test.items
    i rename the line...

    String sketch20 "Cupboard Temp [%s °C]" (sketch,all) {mqtt="<[MyMQTT/21/0/V_TEMP:state:default]"}

    nothing is updating....



  • This post is deleted!


  • on the arduino serial monitor showing..

    0;0;3;0;9;read: 21-21-0 s=1,c=1,t=0,pt=7,l=5:21.0
    MyMQTT/21/1/V_TEMP

    30 18 00 12 4D 79 4D 51 54 54 2F 32 31 2F 31 2F 56 5F 54 45 4D 50 32 31 2E 30
    0;0;3;0;9;read: 21-21-0 s=0,c=1,t=1,pt=7,l=5:41.0
    MyMQTT/21/0/V_HUM

    30 17 00 11 4D 79 4D 51 54 54 2F 32 31 2F 30 2F 56 5F 48 55 4D 34 31 2E 30
    0;0;3;0;9;read: 21-21-0 s=0,c=1,t=1,pt=7,l=5:42.0



  • @Anthony-Straw Going to provide a 32 Bit version of MQTT.fx 0.0.14.3 for windows.





  • thanks 😉



  • @amitach said:

    Hi,

    I have a mqtt gateway running on arduino from mysensors library. I also have an openhab controller running on a raspberry pi connected to the arduino uno through the ethernet shield. I am trying to create my first item on openhab and I understand that the format required is
    MyMQTT/20/0/V_TEMP where 20 and 0 are node id and sensor id respectively.

    I can see following message on the serial monitor

    Started!
    0;0;3;0;9;read: 20-20-0 s=1,c=1,t=16,pt=0,l=1:1

    1. How do I configure the node id and the sensor id?
    2. Is it assigned automatically or do I assign it statically?
    3. How do I understand the above output on the serial monitor?

    You can let the gateway autoassign node IDs or take it in your own hands.

    What I found useful is to not rely on the automatic assignment but give my nodes a static ID, you can do that by replacing the gw.begin function call by this:

    gw.begin(NULL, NODE_ID, false);
    

    where NODE_ID is your chosen ID (you can use "#define NODE_ID 12" for example to specify it before).

    The sensor ID is specified by you. So in each example you see a line something like this:

    MyMessage msgMotion(CHILD_ID_MOTION, V_TRIPPED);
    

    where the first argument (here CHILD_ID_MOTION) specifies the sensor ID that will be sent along your message. You can, again, use #define to define a number in the top of your sketch.

    The serial output was a mystery to me as well until I looked up the printout in the libraries/MySensors/MySensors.cpp file. It's constructed like this:

    debug(PSTR("read: %d-%d-%d s=%d,c=%d,t=%d,pt=%d,l=%d:%s\n"),
    			msg.sender, msg.last, msg.destination,  msg.sensor, mGetCommand(msg), msg.type, mGetPayloadType(msg), mGetLength(msg), msg.getString(convBuf)); 
    

    So it's the sender's node ID, then probably the next hop's node ID, then the destination's node ID, then s=sensor ID, command type?, the message type (like V_TRIPPED, but as a number), payload type, length of the message, the message itself.


Log in to reply
 

Suggested Topics

  • 1
  • 2
  • 1
  • 1
  • 6
  • 1

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts