WiFi gateway, MQTT, openhab



  • I have finished building a wifi gateway as instructed. Now facing a simple problem as it seems a small lack of documentation is in there.

    Sensors transmit data via nrf24 to the wifi gateway. Which than encapsulates it into some tcp-ip and sends it straight to the network?
    So to make this work with openhab i need some intermidiate translator which will receive the data and transfer it into MQTT which openhab can understand?

    Can this translator be installed onto the same system as openhab? Any plans onto bringing MQTT into the wifi esp code?



  • http://www.mysensors.org/controller/openhab

    OpenHab support only Serial GW or mqtt. So this leaves you to 3 options:

    1. Use the serial GW: connect your arduino GW directly to yout openhab host (raspi?)
    2. Use the Mqtt sketch: In this setup the arduino serves as mqtt broker
    3. Use the mqtt CLIENT sketch: IN this setup, your arduino acts as mqtt client and delivers message (sensors values and commands) to an external mqtt broker

    I personally prefer option 3:

    • easier to debug (read messages directly on the broker)
    • more flexible, u can send 3dparty messages to the broker (from scripts, hardware which supports mqtt etc) and deliver them to openhab


  • Well 3 seems the way to go than..
    So all i need to do is compile (with options in the sketch changed) and upload the sketch to ESP8266?

    Sketch:
    https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino



  • I did not use wlan module (see my signature), but should be the same + wlan settings.
    And, of course, setup an external mqtt broker. I used mosquitto, simple apt-get get foo on the openhab host.

    @hek posted a howto:
    http://forum.mysensors.org/topic/2352/guide-setting-up-and-testing-mqtt-client-gateway



  • Well the 3rd otion compiled just nicely. The only problem is that as an MQTT client - the gateway doesn't assign any Node ID.

    I think this can be overcome by hardcoding the ID's for every sensor.

    I wonder if we will see some mysensors binding in openhab or a proper MQTT+ESP gateway with NODE ID assignment in the near future



  • @moskovskiy82 said:
    The only problem is that as an MQTT client - the gateway doesn't assign any Node ID.

    I think this can be overcome by hardcoding the ID's for every sensor.

    Hi, is there any guide how to hardcode IDs for Node and sensors?
    My MQTT client gateway is talking to Mosquitto broker, my DHT sensor is talking to gateway but I never get correct data from sensor even if it measure and always send same information - see log from debug :

    Starting sensor (RNNNA-, 2.0.0-beta)
    Radio init successful.
    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=fail:
    req id
    send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=fail:
    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:
    Init complete, 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:
    T: 28.30
    req id
    send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
    H: 80.70
    

    and same time log from MQTT gateway client:

    HHQA8~hl,|.i:p0;255;3;0;9;Starting gateway (RNNGE-, 2.0.0-beta)
    0;255;3;0;9;Radio init successful.
    scandone
    state: 0 -> 2 (b0)
    .state: 2 -> 3 (0)
    state: 3 -> 5 (10)
    add 0
    aid 8
    pm open phy_2,type:2 0 0
    cnt 
    ..
    connected with KAKV005, channel 2
    ip:192.168.1.210,mask:255.255.255.0,gw:192.168.1.1
    .IP: 192.168.1.210
    0;255;3;0;9;Init complete, id=0, parent=0, distance=0
    IP: 192.168.1.210
    0;255;3;0;9;Attempting MQTT connection...
    0;255;3;0;9;MQTT connected
    0;255;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
    0;255;3;0;9;Sending message on topic: mg1-out/255/255/3/0/3
    0;255;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
    0;255;3;0;9;Sending message on topic: mg1-out/255/255/3/0/3
    0;255;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
    0;255;3;0;9;Sending message on topic: mg1-out/255/255/3/0/3
    0;255;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
    0;255;3;0;9;Sending message on topic: mg1-out/255/255/3/0/3
    0;255;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
    0;255;3;0;9;Sending message on topic: mg1-out/255/255/3/0/3
    0;255;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
    0;255;3;0;9;Sending message on topic: mg1-out/255/255/3/0/3
    
    


  • Hi, it is fixed, I'm just blind. I did not see how to initialize mysensors in development branch example. I switched to master branch and can set gw.begin(NULL,nodeID);
    Can someone explain me how to do same for humidity sketch in development branch?
    Thanks



  • @Kukulin said:

    Hi, it is fixed, I'm just blind. I did not see how to initialize mysensors in development branch example. I switched to master branch and can set gw.begin(NULL,nodeID);
    Can someone explain me how to do same for humidity sketch in development branch?
    Thanks

    #define MY_NODE_ID xx



  • Thank you.



  • Hi. I know this topic is a few months old now, but I'm wondering if you were able to accomplish what you wanted to do. I have a wifi gateway set up and would like to do something similar but with Home Genie as the broker running on a Raspberry PI. Did you have to modify the MQTT Client code much to fit your needs? I'm new to MySensors, but I've been researching topics as much as possible before I dive into the code. Can you point me to the version of the client code that worked for you? I would appreciate any help or tips as I am eager to set up several sensors around the house and perhaps a relay to control a garage door. Thanks.


Log in to reply
 

Suggested Topics

  • 4
  • 9
  • 2
  • 274
  • 9
  • 1

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts