@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
How do I configure the node id and the sensor id?
Is it assigned automatically or do I assign it statically?
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.