Help needed - MQTT Ethernet gateway to Openhab



  • Hello everyone,

    I have run into a snag while trying to connect the MQTT Ethernet Gateway to Openhab. I hope this is the right location to post this. If not, let me know. The problem I have run into is in Openhab, the data that I am trying to get from the sensor and show up in Openhab is not showing. Any help would be greatly appreciated. I have tried to include as much information as possible.

    I have successfully built and compiled the MQTT Ethernet gateway and have connected the radio (nRF24L01+). I am using an Arduino UNO with a Wiznet W5100 Ethernet Shield. Opening the serial monitor shows the following:
    Started!
    <<10 12 00 06 4D 51 49 73 64 70 03 02 00 3C 00 04 4D 51 54 54

    20 02 00 00
    0;0;3;0;9;read: 20-20-0 s=1,c=1,t=0,pt=7,l=5:66.2
    MyMQTT/20/1/V_TEMP

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

    30 17 00 11 4D 79 4D 51 54 54 2F 32 30 2F 30 2F 56 5F 48 55 4D 34 38 2E 30
    <<C0 00

    D0 00
    0;0;3;0;9;read: 20-20-0 s=0,c=1,t=1,pt=7,l=5:47.0
    ...

    I also have a humidity/temperature sensor built using an Arduino Pro Mini 5V 16MHz, nRF24L01+ radio and a DHT11 sensor. When I open its serial monitor it shows the following:
    sensor started, id 20
    send: 20-20-0-0 s=255,c=0,t=17,pt=0,l=5,st=ok:1.4.1
    send: 20-20-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
    read: 0-0-20 s=255,c=3,t=6,pt=0,l=1:M
    send: 20-20-0-0 s=255,c=3,t=11,pt=0,l=8,st=ok:Humidity
    send: 20-20-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
    send: 20-20-0-0 s=0,c=0,t=7,pt=0,l=5,st=ok:1.4.1
    send: 20-20-0-0 s=1,c=0,t=6,pt=0,l=5,st=ok:1.4.1
    send: 20-20-0-0 s=1,c=1,t=0,pt=7,l=5,st=ok:64.4
    T: 64.40
    send: 20-20-0-0 s=0,c=1,t=1,pt=7,l=5,st=ok:41.0
    H: 41.00
    send: 20-20-0-0 s=1,c=1,t=0,pt=7,l=5,st=ok:66.2
    T: 66.20
    ...

    From these two outputs, I assume that the sensor is sending its data to the MQTT gateway and the gateway is receiving it but somewhere between the gateway and openhab running on my raspberry pi there is some kind of problem.

    Moving on to the OpenHAB configuration - currently running version 1.6.1 on my Raspberry PI
    In openhab.cfg in the section entitled MQTT Transport I have defined the following:

    URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883

    mqtt:mysensor.url=tcp://192.168.2.150:1883

    Optional. Client id (max 23 chars) to use when connecting to the broker.

    If not provided a default one is generated.

    mqtt:mysensor.clientId=MyMQTT

    I have added to the addons folder org.openhab.binding.mqtt-1.6.1.jar

    I think this is where the problem may lie... I could be wrong.
    In my .items file I have the following mqtt bindings:
    Number Temperature_MainFloor_Nursery_Office "Temperature [%.1f °F]" <temperature> (MainFloor_Nursery_Office) {mqtt="<[mysensor:MyMQTT/20/1/V_TEMP:state:default]"}
    Number Humidity_MainFloor_Nursery_Office "Humidity [%.1f %%]" <pressure> (MainFloor_Nursery_Office) {mqtt="<[mysensor:MyMQTT/20/0/V_HUM:state:default]"}
    String sketch20 "Sketch name for node id 20 is [%s]" (MainFloor_Nursery_Office) {mqtt="<[mysensor:MyMQTT/20/255/V_SKETCH_NAME:state:default]"}

    I am using the MySensors library 1.4 and Arduino IDE 1.0.6
    Any help would be greatly appreciated. Thanks.

    EDIT: sorry for the large font. I copied/pasted and cant figure out how to change it.



  • @brad.s A good place to start looking is the openhab log directory where you find the openhab.log and the events.log files. Those may give you an idea of what is going wrong.



  • On the RPi I used Mosquitto as a broker between the MQTTGateway and OpenHAB. Works perfectly.



  • I run Ópenhab on the Pi with the MQTT binding and the Mysensors MQTT gateway and it works fine for me with definitions similar to those shown in first post. The ópenhab log will show if the Openhab mqtt service has started or some other errors occured and the events log will show all recognized events As the first post do not mention anything about the content of these logs they may be best option for where to look first (if not already done)



  • @mbj Nice! I didn't get it work with OpenHAB directly to the MQTT GW, with a broker it worked like a charm.

    @brad.s Perhaps a stupid question, but did you remove the comments "#" before the mqtt:mysensor.url=tcp://192.168.2.150:1883 ?

    I would anyhow advise to install Mosquitto just for checking that the GW sends the correct things.



  • @gadu Sounds interesting. May try this solution sometime but of course it is another thing to learn. I am currently struggling to find info and learn about Openhab as well as Mysensors as well as MQTT as well as ...... :-). Open source stuff is not always well documented.



  • Don't want to lock myself into one solution (point-to-point, GW <-> OpenHAB) so I actually wanted a middleware between MySensors and OpenHAB just in case there's other devices (i.e non-arduino) that support MQTT.
    If I in the future get tired of OpenHAB and want to go for another "frontend" just simply delete OpenHAB and connect something else that supports MQTT to the Mosquitto broker.


  • Hardware Contributor

    @gadu I'm sorry to bring up a post from the dead, but could someone point me in the right direction to find the MQTTGateway file/files for the RaspberryPI, i can only find the arduino ones and the possibility of a RPi one, here, but with no MakeFile to compile it....

    Just a little background info and an ongoing topic located here at the forums of what I'm attempting to do and what is happening: Link


 

248
Online

8.9k
Users

9.6k
Topics

100.9k
Posts