MQTT Broker gateway



  • If I run the MQTTGateway my temperature shows in fahrenheit when I run the same nodes on a SerialGateway it is showing Celsius why will this be the case?



  • Downloaded from https://github.com/Damme/MQTTGateway latest MQTT Gateway (the one that responds on serial with "Ok!" not "Started!", with the modifications to MySensors.cpp) but no difference, still no sketch name and with the above settings, openHAB cannot control the relay sensor...

    I used the same arduino that is working with Temp_Humidity sensor so the setup is good, the relay pins are specified in the sketch. I used the Clean_Eeprom_Config before uploading, I even used other Arduino Uno, no diffrerence, still cannot control the relay sensor from openHAB.

    Anyone has a clue, a hint or something? The serial output from both the sensor and the gateway, together with openHAB configuration are two posts up.

    Edit: 3 hours later and managed to make many of the sensors (Door, Distance, Dust, Gas, Humidity, Light, Motion) everyone working in conjunction with MQTT Gateway and openHAB except the Relay one...

    Any help is appreciated.

    Regards,
    Adrian



  • Callback for incomming messages does not occur so I guess that the message does not get to the relay sensor. Is there someone that is using this with MQTT Gateway and openHAB?



  • @adrianmihai83 I was testing this today and it was working with the MQTTGateway. Here is my config file same as above:

    Switch node2_sw2 "Study Lights" (node2,all) { mqtt=">[mysensor:MyMQTT/2/1/V_LIGHT:command:ON:1],>[mysensor:MyMQTT/2/1/V_LIGHT:command:OFF:0],<[mysensor:MyMQTT/2/1/V_LIGHT:command:MAP(1on0off.map)]" }

    Here is the info from the serial port monitor.

    upload-805fea56-06b2-4632-a2c0-fb8cd80a8ec5



  • Will test it tomorrow morning and come back with result, what i see is exactly the same configuration, the only difference is that your's is on the 3'rd node and mine on 1'st node. Anyway, will see.

    Thank you for your answer.

    I am still waiting for my other NRF24L01 ( I ordered 30 pcs), they will arive this week. Maybe there is a problem running the sketch on node one, id 0. Tomorrow I will go and buy 2 of the NRF24 from a store even if they are 4 times more expensive, this not working is killing me 🙂



  • Why is the broker offering me the same id for all of the sensors? I start the first one, broker offers me id 0, without disconnecting it I connect the second sensor and the gateway offers me same id, id=0.

    I have cleared eeprom to both of them and see the requesting id first time i power them up, but still same id for both...

    Edit 1:

    Defined static ID and the relay works, didn't modify anything, just static ID 2 to the relay...

    Edit 2:

    Just tested with ID 0, 1 and 2 and I can confirm that the relay does NOT work with ID 0, it's almost a week now and I have tried everything and the answer was as simple as this: does not work with ID 0.


  • Hero Member

    By ID do you mean node ID? If so, the gateway has node ID 0, so I'm not surprised if it's not good for other nodes.

    But you may be talking about a child ID or something else.



  • Yes, I am talking about node ID, but what I can tell you is that until two days ago I didn't assigned node ID manual and I didn't have 3 NRF's to test with gateway + 2 nodes. Only when I got other RF's and made a couple of sensors saw that the gateway is assigning node ID 0 to all of the sensors, and all sensors worked, for example:

    1. temp humidity node had Node ID 0 and Child 0 and 1, and from openHAB I could use them at MYMQTT/0/0/V_HUM and MYMQTT/0/1/V_TEMP
    2. motion sensor at MYMQTT/0/2/V_MOTION
    3. and do on, other 2 sensors, all I had to take care is that all of them had distinct Child ID

    Only when I got other NRF's and could make sensors and use them in paralel saw that the gateway is offering NODE ID 0 to all of my sensors, I don't know why, checked MYMQTT.h and it was set to auto assign Node ID, even in the statemant gateway.begin() assumes that the gateway should auto assign Node ID, and gw.begin(incomingMessage, AUTO, true) states it clear that relay sensor should get Node ID from the gateway.

    All I did is manual assigned nodes for every one and workking like a charm. I simply like it this way, it let's more control, it's simply more "my way".

    Now I want to combine some of the sensors and use a Mega2560 for this, hoping for a nice outcome.


  • Plugin Developer

    This post is deleted!

  • Code Contributor

    @John Could you send me log from MQTTgateway also? (or tcpdump)


  • Plugin Developer

    This post is deleted!


  • I have a next problem:
    OpenHAB (192.168.1.3) <-> Arduino GW mqtt (192.168.1.234:1883)<-> Arduino TEMP (DHT)

    org.eclipse.paho.client.mqttv3.MqttException: ═х єфрхЄё  яюфъы■ўшЄ№ё  ъ ёхЁтхЁє
    at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNet
    workModule.java:75)
    at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(Cli
    entComms.java:538)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNet
    workModule.java:66)
    at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(Cli
    entComms.java:538)
    at java.lang.Thread.run(Unknown Source)

    with ping everything is ok.
    test


  • Plugin Developer

    This post is deleted!


  • I connected the serial to MQTT GW:
    If I have connected Wiznet, I've got "0;0;3;0;9;check wires",
    if i disconnected Wiznet then got "Started!"


  • Plugin Developer

    @Damme
    You can forget about my posts, after some quite intensive debugging i found out there was an ugly inconsistent race condition going on in my app. Issue is gone now.



  • Could anyone help me with running MQTTGateway with enc28j60 ethernet module? Should a gateway respond to ping? Openhab says 'no route to host'. Should i change anything else than Ethernet.h to UIPEthernet.h in source code ?


  • Code Contributor

    I just wanted to say hello again to everyone. I had to disappear for a while. Just had too much for my brain to handle. So all my automation project were on halt but will be continued again.

    I know there are lot of bugs in this GW and I will hopefullt start developing soon again. Just write your experience you had so far and I'll try to keep up 🙂

    //Damme


  • Plugin Developer

    @Damme Good luck!



  • @Damme I tried today the mysensor 1.4.1 library, uploaded with Arduino 1.5.8 to UNO with Ethernet Shield (W5100) and an NRF24L01+pa+lna. Compilation and upload worked fine.
    I can ping the IP address defined in the MQTTGateway.ino sketch.
    I maintained on my RPI the openhab.cfg file with the url and port number from the gateway.
    When starting the openhab it shows:
    ... - MQTT Service initialization completed.
    ... - Starting MQTT broker connection 'mysensor'.

    Then a couple of message later:
    ...Mqtt Exception
    Caused by: java.net.SocketTimeoutException: connect timed out

    Any suggestion what I could look at.

    I also tried to work with the development library of Mysensors but did not get very far with that. My ultimate goal is to something like a moteino with the RFM69HW radio module in connection with either openhab or pidome.
    I have a quite a bit of hardware lying around here so I am happy to do any testing if somebody gives me some guidance.
    Thanks.



  • This post is deleted!


  • Thanks for the mqtt broker. Just a tip to people who might fall in to the same pit as I:

    The mqtt broker gateway doesn't distribute node ids unless you're connected to it using a mqtt client. I.e. if you did what I did, installed the gateway and wanted to test that the sensors found the gateway and was distributing the code then it doesn't work until you've connected to it. I had to go through the source code to figure it out.

    If you don't have openhab or simply want to test, this is what I did on my raspberry (but should work similarly on others)

    // install mosquitto client
    sudo apt-get install mosquitto-clients

    // Start the client, replace the 10.0.0.200 with your ip. The port will default to 1883

    mosquitto_sub -h 10.0.0.200 -d -t hello/world -v

    You should be able to see messages:
    Received PUBLISH (d0, q0, r0, m0, 'MyMQTT/20/0/V_LIGHT_LEVEL', ... (2 bytes))



  • Hi All

    Just a simple question:

    Are there any limitation in how many MQTT connections/sessions the MQTT Gateway can handle?

    If so, can this be changed?



  • Hello. I am new to Mysensors, openhab and mosquitto.. I have a working knowledge of arduino and nrf24l01, and currently am running a wireless(nrf) twitter controlled heating scheduler, and am sending multiple temp (ds18b20) sensors to Xively feed.

    I am really hooked on the idea of mqtt and openhab, and i thought that mysensors seemed like a good solution for implementing that idea.

    My progress so far is to install the DallasTemperatureSensor by MySensors node to one nano, and the ethernet gateway sketc as a first step, and now i have installed the mqttgateway again from the build page, and i have a working install of mosquitto and openhab on a rasp pi b+.

    I am just having difficulty getting it all stuck together. I have created the sitemap items and transform files as above and can access the openhab sitemap for the above configuration. i just don't know if i need to configure other items? how can i test each step? and can i use mosquitto with the setup that i have outlined. There seems to be conflicting info about what can and cannot be done with mosquitto and mysensors.

    1 do i need to modify the sketch of the temp node? i have some output from the serial that suggests that it is communicating with the gateway.
    2 do i need to modify the gateway with info of the mosquitto server?
    3 what can i do to test each step of the transit from temp sensor to openhab?

    Thanks for any and all responses.



  • Hello!

    I've downloaded the 1.4.1 version of the library and tested it via OpenHab.
    I'm still not getting the sketch_name correctly via MQTT and Openhab. Is it still an open bug?

    Thanks!

    Simon



  • Hi Simon,
    I had the same problem
    I tried several time clean Eeprom and flash sketch again but with no results
    Only after cleaning of Eeprom with the following scratch my sensor is starting work correctly
    I recommend to try it:
    Clearing EEPROM

    Igor



  • @mwhansen Hi, I am also struggling with this, seems it can only handle one connection now which makes it extremely hard to debug or check node ids


  • Code Contributor

    @Gambituk To connect to a external MQTT server (mosquitto) use this MQTT gateway version:
    http://forum.mysensors.org/topic/524/mqtt-client-gateway/



  • Thanks @celonunes I eventually found that version of gateway via somebody else. i have another post with some issues i found with that version. http://forum.mysensors.org/topic/921/strange-value-being-sent-from-controller-using-mixed-temp-relay-node it's not really resolved, but i have some kind of workaround.


  • Code Contributor

    @mwhansen @alexeinz The MQTT gateway can handle up to four simultaneous socket connections, this is the limit of Arduino ethernet shield (Wiznet W5100).

    The problem is that openhab don't get along with the way the gateway handles multiple client packages. I will send a fix for this problem in the next few days.



  • @celonunes actually, i figured a way around it using mosquitto bridge
    that way its much more robust too, so I am good 🙂
    can post my conf if anyone interested.


  • Code Contributor

    Those are the most recent changes to MQTT gateway:

    • Fixed node id distribution by the gateway (reported by @viking)
    • Fixed the problem with openhab and multiple MQTT clients
    • Fixed the appearance of garbage in messages sent from MQTT to a node


  • I can't change on-off manually for button with relay sketch, if i try, connection is lost, switching from screen never works again until restart everything.

    2015-03-05 15:51:29.200 [INFO ] [runtime.busevents ] - node2_sw2 received command OFF
    2015-03-05 15:51:32.624 [INFO ] [runtime.busevents ] - node2_sw2 received command ON

    Openhab 1.6.2 or 1.7.0 same result.

    **My main problem is losing connections with nodes. I also tried serial binding and same result.
    **
    Mysensors+Openhab useless with mqtt and also serial binding


  • Code Contributor

    @C.r.a.z.y. Could you send the serial output from the gateway? And a more complete log from openhab showing errors?


  • Admin

    @C.r.a.z.y. said:

    I can't change on-off manually for button with relay sketch, if i try, connection is lost, switching from screen never works again until restart everything.

    Are you sure it isn't a powering issue of the "button-node" where radio shuts down when you press the button? Are you controlling a physical relay?



  • @celonunes You can find MQTT and serial logs in the zip files openhab 1.6.2 and 1.7.0 logs-1.7.0.zip logs-1.6.2.zip

    @hek My nodes are working perfect when i only plug serial usb to any usb socket of a computer-printer-usb hub even a mobile phone charger 🙂 they are good without server/controller



  • @hek My relay powered from nano icp headers maybe this makes trouble for wifi , i will change this and give update.

    My button is not normal button , its an ir distance sensor which trigers the relay.



  • I can't seem to get openhab to communicate with my MQTT gateway. I can connect to the gateway with the MyMQTT Android app and I receive messages from my light sensor node including the sketch name and light level. I can ping my gateway without issue as well.

    However, OpenHab never seems like it notices the gateway. No data in the sketch name or node result. I've used the sitemap, items, and config files as described above and I've also customized them to match my sensor node more specifically. Both without success. The only change I've made is my sensor node is defined as node ID 20 within it's sketch.

    When using start_Debug.bat what should I see in the command line window to indicate OpenHab even sees or connects to the gateway. I see no indication that it attempts to connect to the IP address of my gateway.

    Thanks



  • Maybe if you can share your items, sitemap, and rules if any.





  • can you also please paste a sample of what you see in myMQTT or screenshot maybe? or it can be easier to copy and paste from a terminal window? are you using raspberry pi or something else?



  • @hooraysimpsons unplug the power and restart your modem, check your dhcp menu if it has ip for Ardiuno.

    Check your mqtt from serial monitor, you must see "gateway started..."



  • mosquitto_sub -h localhost -v -t '#'
    This is what i use to see what is happening on mqtt broker, i am using a raspberry pi and mosquitto installed on the same pi. you can also swap localhost for ip address ie 192.168.0.5 etc



  • @C.r.a.z.y. it sounds like he is getting as far as the mqtt broker, so the gateway must be working. ?



  • Crazy- I was thinking my network connection as a source of the problem. On my router homepage the gateway does not show up as being given an IP. However, the MyMQTT Android App sees the gateway without issue so the routing across my network from phone to gateway is successful. I have attached a screenshot of the MyMQTT andoird app output.

    2015-03-08 14.55.12.png

    I am trying to run OpenHab on a windows PC. I don't have mosquitto running at all. My understanding is that it is not required.



  • Group all
    Group node1 (all)
    Group node2 (all)
    Group sketch (all)

     Number node1_light  "Light Level"     (node1,all)  {mqtt="<[mysensor:MyMQTT/20/0/V_LIGHT_LEVEL:state:default]"}
    

    Try changing the first line of items like this above.. and in sitemap change node1_temp to node1_light

    Also see if activating any of the switches in openhab publishes to myMQTT ?



  • Restarting the modem and checking wires of arduino solved my problem before.
    I am sure mqtt have to be in dhcp list.



  • I have restarted my router with no effect. The gateway still does not show up as an active client (using DDWRT) but I still have a connection from phone to gateway.

    Added the above line. I've used one before like it but went back to what was given at the beggining of this thread to start anew. I also tried with the following edits
    "Light Level"
    "Light Level [%s]"
    "Light Level [%.1f]"

    None of which make a difference. The reason I think OpenHab doesn't even see the gateway is because nothing shows up in sketch name either which should work even if the above line was incorrect.

    I have done the testing with the Android App turned off as well since I know OpenHab had some issues earlier if other clients were accessing the gateway.

    I still see no reference to my gateway's IP in any of the OpenHab output/logs. So I'm not sure it is even trying.

    The only error message in my openhab log is:
    11:23:46.951 [ERROR] [sphere.cpr.AtmosphereFramework:2215 ] -

    I tried clearing the EEPROM in the gateway. I changed it's Mac address and removed the DHCP lease for it from my router. Still no evidence of the gateway on my router status page but also still able to connect to it with my phone.

    Another update:
    I installed Mosquitto and I see the light sensor level using mosquitto_sub -h 192.168.1.134 -t MyMQTT


  • Code Contributor

    @hooraysimpsons Your gateway seems to be working fine. Do you see something like this on your openhab logs?

    2015-02-27 17:48:06.349 [INFO ] [.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
    2015-02-27 17:48:06.350 [INFO ] [o.i.t.m.i.MqttBrokerConnection] - Starting MQTT broker connection 'mysensor'
    


  • @celonunes Nope. I figured it out. In my openhab config file there was space prior to my MQTT related lines

    " mqtt:mysensor.url=tcp://192.168.1.134:1883"
    " mqtt:mysensor.clientId=OpenhabMQTT"
    Instead of
    "mqtt:mysensor.url=tcp://192.168.1.134:1883"
    "mqtt:mysensor.clientId=OpenhabMQTT"

    Removed the space and now I get my light sensor output value. I still don't get the sketch name coming through but I'll look into that later.



  • @celonunes @hek
    I installed this https://github.com/lurch/rpi-serial-console
    pi@raspberrypi ~ $ rpi-serial-console status
    Serial console on /dev/ttyAMA0 is disabled

    Now my nodes are working perfect when i use manual button or ui but my logs are not correct

    My config:

    add on : org.openhab.binding.serial_1.6.0.201411271703.jar
    String Arduino "Arduino" { serial="/dev/ttyUSB0" }

    As you see there are "fails" but nodes are working.

    015-03-09 12:37:51.725 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

    2015-03-09 12:37:56.726 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 52-52-0 s=255,c=0,t=18,pt=0,l=5:1.4.1
    52;255;0;0;18;1.4.1
    0;0;3;0;9;read: 52-52-0 s=255,c=3,t=6,pt=1,l=1:0
    52;255;3;0;6;0

    2015-03-09 12:37:58.768 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 52-52-0 s=255,c=3,t=11,pt=0,l=14:Relay & Button
    52;255;3;0;11;Relay & Button
    0;0;3;0;9;read: 52-52-0 s=255,c=3,t=12,pt=0,l=3:1.0
    52;255;3;0;12;1.0
    0;0;3;0;9;read: 52-52-0 s=1,c=0,t=3,pt=0,l=5:1.4.1
    52;1;0;0;3;1.4.1
    0;0;3;0;9;read: 52-52-0 s=2,c=0,t=3,pt=0,l=5:1.4.1
    52;2;0;0;3;1.4.1

    2015-03-09 12:37:59.700 [INFO ] [runtime.busevents ] - S2 received command ON
    2015-03-09 12:37:59.822 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;0

    2015-03-09 12:38:00.106 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:0

    2015-03-09 12:38:00.546 [INFO ] [runtime.busevents ] - S2 received command OFF
    2015-03-09 12:38:00.661 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;1

    2015-03-09 12:38:00.967 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

    2015-03-09 12:38:01.161 [INFO ] [runtime.busevents ] - S2 received command ON
    2015-03-09 12:38:01.339 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;0

    2015-03-09 12:38:01.649 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:0

    2015-03-09 12:38:01.782 [INFO ] [runtime.busevents ] - S2 received command OFF
    2015-03-09 12:38:01.894 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;1

    2015-03-09 12:38:02.076 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1



  • Just want to make sure I'm understanding this correctly since I feel the MQTT terminology is new to me.

    The MQTT Broker is the MQTT server so if I wanted to use this with openhab on a pi I would just need the MQTT plugin and then point it to the IP of the gateway?

    I have the ethernet module ordered so I can't test myself yet.


  • Code Contributor

    @C.r.a.z.y. You are using the raspberry serial port to connect the openhab with the arduino and the arduino is running the SerialGateway sketch, is that right?


  • Code Contributor

    @Chaotic said:

    The MQTT Broker is the MQTT server so if I wanted to use this with openhab on a pi I would just need the MQTT plugin and then point it to the IP of the gateway?

    That's right.



  • I have ENC28J60-I/SO connected by ethernetcable to my Asus RT-n66u in LAN 4. But It will not show up in my router... On my ENC28J60 there is a red light on D1 and the ethernet port has a green light and a yellow flashing light.

    Serial monitor says "
    Started!
    0;0;3;0;9;read: 20-20-0 s=255,c=0,t=17,pt=0,l=5:1.4.1
    0;0;3;0;9;read: 20-20-0 s=255,c=3,t=6,pt=1,l=1:0
    0;0;3;0;9;send: 0-0-20-20 s=255,c=3,t=6,pt=0,l=1,st=ok:M
    0;0;3;0;9;read: 20-20-0 s=255,c=3,t=11,pt=0,l=18:Temperature Sensor
    0;0;3;0;9;read: 20-20-0 s=255,c=3,t=12,pt=0,l=3:1.0

    . But nothing more. I have followed the MQTT gateway guide and set an static ip in the sketch.. DHCP is on in my router.

    The only thing I see in my router is : That the cable is connected to something and that its 10 Half duplex.

    I have also tried to connect it to other LAN ports but no difference

    What could be wrong?


  • Code Contributor

    @msebbe Did you try to ping the gateway static IP?



  • @celonunes

    Yes, both from windows cmd and from the router ui with this result:

    PING 192.168.1.197 (192.168.1.197): 56 data bytes

    --- 192.168.1.197 ping statistics ---
    5 packets transmitted, 0 packets received, 100% packet loss

    Could be that I have not changed the MAC adress cause I tried to figure out how to do it but I dont understand this part from the MQTT gateway sketch:

    *1 -> NOTE: Keep first byte at x2, x6, xA or xE (replace x with any hex value) for using Local Ranges.

     #define TCP_PORT 1883						// Set your MQTT Broker Listening port.
     IPAddress TCP_IP ( 192, 168, 1, 197 );				// Configure your static ip-address here
     uint8_t TCP_MAC[] = { 0x02, 0xDE, 0xAD, 0x00, 0x00, 0x42 };	// Mac-address - You should change this! see note *2 above!

  • Code Contributor

    @msebbe Which library your are using for the ENC28J60? The UIPEthernet has some examples you could try to test if your module is working.



  • @celonunes
    Just wanted to say I was able to get this working.

    Also found a nice little MQTT utility that makes it easy to see the messages being sent from the broker/openhab.

    I'm sure I'll have more questions but most of my hardware is still on a boat from china so will be a little while till I discover them.



  • @celonunes In the Mqtt broker sketch, Ethernet.h was included. I suppose it should be UIPEthernet.h for me? So I tried that but nothing.

    I had better luck with the UIPEthernet examples, there my arduino shows up with an ip and mac adress.. Hmmm.

    edit:

    So after using UIPEthernet "Advanced chat server" sketch, the MAC and IP showed up in my router. When I then tried with the MQTT sketch with UIPEthernet.h it would not work. So then I tried to copy the MAC and IP I used in the chat server sketch into the Mqtt sketch and bom! I can now ping it, so I guess it works now?

    edit2: Should it say anything more then "Started!" on serial monitor? Like "on ip 192.168.1.197" or something like that? Since Im now trying the MQTT in pidome as I know how to use pidome better. Pidome states;
    Connected: Yes, with 192.168.1.197:1883 at topic: MyMQTT/# (without subscribe promise)
    Last receive time: 00-00-0000 00:00
    Last send time: 00-00-0000 00:00

    This is what Serial monitor says http://i61.tinypic.com/i252kn.png

    But when I use device discovery it cannot find the temperature sensor that could be found using the serial gateway 😕



  • Hi everyone,

    Finally got this working but had a couple of quetions

    Does the MQTT Broker gateway not handle requests for time? I currently have a node that I'm using as an alarm clock which has a RTC module. I had hoped to be able to update the time via the gateway and polling the time from one of my computers which are connected to NTP servers but the message never seems to get put on a MQTT message so I can't have a computer respond to it.


  • Code Contributor

    @msebbe It doesn't print your ip, those numbers after "Started!" is related to mqtt packages showing that PiDome is connected.
    For the device discovery, there are probably a lot of other people who can help you with that because I don't know much about PiDome.


  • Code Contributor

    @Chaotic MQTT Broker gateway doesn't handle time requests.



  • @celonunes Ok, thanks! I got the discovery working by just rebuilding the same sensor from scratch!

    Sorry for so many questions.. But I have now changed to Openhab and got it working with my MQTT gateway. Now Another problem appear:

    http://i60.tinypic.com/2d2eqzk.png[/IMG

    I would like to display the temperature in °C like in your guide sketch (wich I am using) but instead it looks like in the picture. Same thing about humidity, why is it like this?

    Edit: For anyone wondering, I solved the issue with the degree symbol not showing up properly by replacing "°C" with "& deg;C" without space between & deg



  • Hi Folks,

    New to mysensors and am impressed. I've been playing with OpenHAB and MQTT so this sounds like an interesting project. My question though, which might have been answered but I'm finding it hard to find the answer, is - is this bidirectional? As in if I had a 'sensor' on the Arduino network and that went over the radio network, hit the gateway and then got picked up by OpenHAB, could I then, if I had a 'actuator' or a 'do-er' node on the network, send a message to MQTT from OpenHAB to change the status of that actuator device? So for instance to start a motor controlling blinds for instance? Or is it a read only system?

    Thanks



  • @Brett-Jenkins

    It works both ways.



  • Thanks 🙂



  • How can I implement MQTT for MQ-2 Gas sensor the correct way? In the mysensor sketch there is only one child ID and one V_VAR1 but 3 different outputs: LPG, CO and Smoke? I'm only receiving CO value and not all 3 in openhab.



  • @kunall There is V_VAR1-5 actually

    V_VAR1	24	Custom value
    V_VAR2	25	Custom value
    V_VAR3	26	Custom value
    V_VAR4	27	Custom value
    V_VAR5	28	Custom value
    

    Personally I would set up each value you want as a S_CUSTOM if you can't figure out another sensor type that fits.

    For smoke you can use S_SMOKE
    For Air Quality S_AIR_QUALITY
    Not sure what you'd want to use for CO2 through

    http://www.mysensors.org/download/serial_api_14



  • @Chaotic Thanks! I will try this and get back with result.



  • @Damme
    how to run MySensors ( MQTT gateway) on the arduino due + Wiznet5100 + NRf24l01?
    Get the error:

    Arduino: 1.5.8 (Windows 8), Board: "Arduino Due (Programming Port)"
    
    In file included from Z:\arduino-1.5.8-new\libraries\DigitalIO/DigitalIO.h:31:0,
                     from EthernetGateway.ino:41:
    Z:\arduino-1.5.8-new\libraries\DigitalIO/DigitalPin.h:30:20: fatal error: avr/io.h: No such file or directory
     #include <avr/io.h>
                        ^
    compilation terminated.
    Ошибка компиляции.
    
      This report would have more information with
      "Show verbose output during compilation"
      enabled in File > Preferences.
    
    
    


  • @hooraysimpsons this solved my problem too! Everything else in my setup was a quick job but problem solving this issue took half a day. It should be more widely circulated..



  • Hi guys,

    I dind´t read all comments so I hope this wasn´t answered before: I would like to know how to setup an arduino + NRF24L01 Node:

    • how to initialize the node
    • what should the Arduino sketch look like to start MQTT

    Thanks for your help!!



  • Ok,forget my last post, I have a new problem:

    When I uplaod the EthernetGW Sketch to my arduino nano I can see MQTT messages coming in from one node int the arduino serial monitor. So now I uploaded the MQTTGW sketch to my nano because I would like to use openhab. But after uploading the sketch all info I get from serial monitor is "Started!", nothing else is showing up.
    I can still ping the MQTT gateway but it seems like it´s not receiving any mqtt message, at least no the state of my node. Could you please help and support me here? Thanks in advance!



  • nobody experiencing this problem? Any idea how I could start fixing this? Pls help!



  • Hello,

    I have made this gateway with W5100.
    Everything looks OK, except random connection failures.
    Clients - MyMQTT (android), Openhab are loosing contact with the broker time after time.
    The issue can occur every 5 - 60 mins.

    Any ideas what could be the problem?

    Thank you in advance.



  • Hi,

    Was hoping someone could help a MQTT and openHab newb here. i have Openhab configured and running with Phillips Hue and Wemo, and trying to integrate MySensors. I build the 1.5 version MQTT gateway using the W5100 module, and all is working (can ping the gateway noproblem, and receiving data from a sensor). The problem is, i'm not sure how to add the line into the items and sitemap file....

    Here is the output that I am getting from the MQTT serial monitor. The sensor I have connected is a 3-in-1 with motion PIR, and DHT22 temp/humid and a hard configured Node_ID of 3 (or, should be).

    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=1,c=1,t=0,pt=7,l=5,sg=0:23.3
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.1
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=1,c=1,t=0,pt=7,l=5,sg=0:23.2
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:43.9
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=1,c=1,t=0,pt=7,l=5,sg=0:23.3
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.1
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=1,c=1,t=0,pt=7,l=5,sg=0:23.2
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:43.9
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=1,c=1,t=0,pt=7,l=5,sg=0:23.3
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.1
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.1
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.1
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.1
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.1
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=1,c=1,t=0,pt=7,l=5,sg=0:23.4
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
    

    Can someone help me get the information to display in OpenHab? Please.



  • Contact contact_99        "Contact node 99 sensor 3: [MAP(de.map):%s]"        { mqtt="<[mysensors:sensor-gw1-out/99/3/1/0/16:state:MAP(mqttToCloseOpen.map)]" }
    

    this is an item which
    reads a message from mqtt broker:

    • < input, reads message
    • mysensors => mqtt connection as decribes in opnehab.cfg
    • sensor-gw1-out => topics as configured in your mqtt gateway sketch
    • 99/3/1/0/16 have a look at serial api: node 99, child 3 etc

    I found it very helpful to subscribe myself to the mqtt broker and read the incoming messages there



  • Hi @dakky

    Thanks for the help. So far, I can get my temperature and humidity to update, but I cannot get my motion sensor on the same node to update at all.

    Here are the lines I have in default.items

    /* MySensors MQTT */
    Number		node1_temp					"Temp [%.1f °C]"     						(node1)		{mqtt="<[mysensor:MyMQTT/1/1/V_TEMP:state:default]"}
    Number		node1_humid					"Humid [%.1f %%Rh]" 						(node1)		{mqtt="<[mysensor:MyMQTT/1/0/V_HUM:state:default]"}
    Contact 	node1_motion        		"Motion Sensor 3: [MAP(1on0off.map):%s]"     (node1)	{ mqtt="<[mysensors:MyMQTT/1/2/V_TRIPPED:state:MAP(1on0off.map)]" }
    

    And here is my default.sitemap file

    Frame label="Sensor Data" {
            Text label="Sensors" icon="mysensors" {
    		Group item=node1 label="Man Cave Climate" icon="temperature" 
    		Chart item=node1_humid period=W refresh=10000
    		}
    

    And finally, this is what I am reading from screen when the message appear on the MQTT broker sketch. The node_id is 1, not 3 like I originally though.

    >>30 17 00 14 4D 79 4D 51 54 54 2F 31 2F 32 2F 56 5F 54 52 49 50 50 45 44 30
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5,sg=0:47.1
                                                        MyMQTT/1/0/V_HUM
    >>30 16 00 10 4D 79 4D 51 54 54 2F 31 2F 30 2F 56 5F 48 55 4D 34 37 2E 31
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
                                                      MyMQTT/1/2/V_TRIPPED
    >>30 17 00 14 4D 79 4D 51 54 54 2F 31 2F 32 2F 56 5F 54 52 49 50 50 45 44 30
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
                                                      MyMQTT/1/2/V_TRIPPED
    >>30 17 00 14 4D 79 4D 51 54 54 2F 31 2F 32 2F 56 5F 54 52 49 50 50 45 44 30
    0;0;3;0;9;read: 1-1-0 s=1,c=1,t=0,pt=7,l=5,sg=0:21.8
                                                        MyMQTT/1/1/V_TEMP
    >>30 17 00 11 4D 79 4D 51 54 54 2F 31 2F 31 2F 56 5F 54 45 4D 50 32 31 2E 38
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
                                                      MyMQTT/1/2/V_TRIPPED
    >>30 17 00 14 4D 79 4D 51 54 54 2F 31 2F 32 2F 56 5F 54 52 49 50 50 45 44 30
    0;0;3;0;9;read: 1-1-0 s=2,c=1,t=16,pt=0,l=1,sg=0:0
                                                      MyMQTT/1/2/V_TRIPPED
    >>30 17 00 14 4D 79 4D 51 54 54 2F 31 2F 32 2F 56 5F 54 52 49 50 50 45 44 30
    

    Any ideas on what I am missing? Also, when trying to implement persistence, I went with MySQL as per directions here but the data doesn't actually go into the chart. Other than adding mysql to the openhab.cfg file, what else is there? The log isn't showing any errors from what I can see.

    Thanks!



  • Typing from tablet => short Version

    Contact items needs Open or Closed not On vor Off. Make a new map translating 0 to closed etc and it should work. or use the correct item: switch seems a better choice
    https://github.com/openhab/openhab/wiki/Explanation-of-items#itemtype



  • Hi @dakky

    well, some luck. I made a new map contact.map with
    0=Closed
    1=Open
    -=unknown

    so far the swtich now shows "Unknown" all the time; but no status updates from the sensor (even though it is showing in serial console as 1, and 0 when it is off).

    Not sure why it isn't updating like it should now. Might have to reboot the server.



  • Ok, got it. Had to do the following to my items and sitemap to get a PIR to work right:

    entry in default.items

    Switchnode6_motion	 "LR Motion Test [MAP(motion.map):%s]"  (FF_Living,All) {mqtt=">[mysensor:MyMQTT/6/1/V_TRIPPED:command:ON:1],>[mysensor:MyMQTT/6/1/V_TRIPPED:command:OFF:0],<[mysensor:MyMQTT/6/1/V_TRIPPED:command:MAP(motion.map)]"}
    

    and default.sitemap

    Text item=node6_motion label="PIR Test LR [%s]" icon="pir"
    

    And last, the transform file (named motion.map)

    1=ON
    0=OFF
    

    At least now it registers the data in text as On or Off. Thanks again @dakky



  • Is there a way to redirect all the messages from the serial console of the wifi gateway to some tcp port so they can be read via putty?


  • Hardware Contributor

    Hello, sorry to reopen this post, but maybe someone can help me! I'm still waiting the arrival of my arduinos to make my nodes and gateways, but I already installed openhab to start configuring the layout and MQTT. All is working, I can post to MTQQ from openhab and used the tutorial on this post to make the same button send and recieve.

    The problem is that when I click the button with the code "sw2 send + recieve example" openhab enters in loop mode, it seems that keeps sending and reviving the same MTQQ request. I use MQTT.fx to test the MTQQ posts, and when I click the button, the program also crashes and takes my CPU to max.

    Can any one help me?
    Best Regards
    Soloam


  • Hardware Contributor

    Hello, the problem persists, the map function keeps sending the same request over and over again, If I make a click in a few seconds my mqtt client is full of requests, over 500 with the same message. Wasn't it supposed to send only one message for click?



  • I don't believe you can put both inbound and outbound mqtt messages in the switch definition. This is what creates the infinite loop since you are both sending and receiving on the same message topic. Every time the broker receives the message, it publishes it out to all subscribers. Since your switch item is also a subscriber it picks it up again and the loop continues.

    Use only inbound in the definition then either a rule and/or proxy item to handle the outbound command. Set your rule definition "when item received command". That way it will only fire when you click on the switch item in openHAB. If you use any other option, ie. received update or changed, it will also continue the infinite loop.

    Hope this makes sense.


  • Hardware Contributor

    That makes perfect seance, I was only mirroring the solution presented on the 1st post of this topic. I will try your approach!

    Thank You


  • Hardware Contributor

    It didn't worked, the rule also changes when I receive the MQTT in openhab:

    rule "Send Requst"
    when
        Item node2_sw2 received command
    then
    	if(node2_sw2.state == ON){
    		sendCommand(node2_sw1,ON)
    	}
    	else{
    		sendCommand(node2_sw1,OFF)
    	}
     end
    

    I don't believe this is a new problem to the forum, didn't any one made, a switch on the openhab with inptut and output.


  • Hardware Contributor

    Found the solution tanks to watou user in OpenHab Forum.

    Switch node2_sw2  "sw2 send + recieve example"  (node2,all)	  {mqtt=">[mysensor:MyMQTT/21/2/V_LIGHT:command:OFF:0],>[mysensor:MyMQTT/21/2/V_LIGHT:command:ON:1],<[mysensor:MyMQTT/21/2/V_LIGHT:state:MAP(1on0off.map)]"}
    

    The secret is in the :state: declaration on the MAP!

    Thank you all


Log in to reply
 

Suggested Topics

  • 2
  • 6
  • 75
  • 2
  • 10
  • 17

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts