Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. General Discussion
  3. MQTT: Can somebody explain Gateway to a beginner?

MQTT: Can somebody explain Gateway to a beginner?

Scheduled Pinned Locked Moved General Discussion
11 Posts 4 Posters 6.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MSchmidke
    wrote on last edited by
    #2

    Ah, I've found the Arduino MQTT library, With the simple example provided there, I really managed to send MQTT message to my broker (and display it on command line). But in that example, I had to provide the IP address of my broker.

    I will further investigate MyMQTT.cpp to find out what my basic misunderstanding is. Perhaps I will manage to combine MyMQTT.cpp and the MQTT library.

    Marcus.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TommySharp
      wrote on last edited by
      #3

      Marcus, did you get this working ever?

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TommySharp
        wrote on last edited by
        #4

        A while back I tried this approach to setup a MQTT Client Gateway but I never got it fully working.

        At the moment I'm using the MQTT Gateway and it works well for receiving readings from sensors. Although I'm having some problems sending commands to things like relays etc

        I'm probably going to try the "client gateway" again and make it talk to my Mosquitto MQTT broker.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          paul
          wrote on last edited by
          #5

          I always had a problem with ethernet gateway. So i used serial gateway instead to connect with my nodejs application on my RPI. Inside that node js application, i converted all messages into my own MQTT topics and publish them to a MQTT server(Mosquitto) on my RPI. On the openhab side, i just bind items to these MQTT topics.
          You can take a look at my system diagram.
          Capture.PNG

          1 Reply Last reply
          0
          • TD22057T Offline
            TD22057T Offline
            TD22057
            Hardware Contributor
            wrote on last edited by
            #6

            This i my understanding (which could be totally wrong of course): the MQTT gateway implements a very limited MQTT broker. You connect a client into it and it will send the sensor messages out. I'm going to do something similar to your drawing (using RabbitMQ as a central clearing house for messages). In that case, I think you need to either connect the RabbitMQ broker to the gateway broker (if broker->broker is possible) or write a thin client that connects to the gateway broker and republishes messages to the RabbitMQ broker.

            1 Reply Last reply
            0
            • P Offline
              P Offline
              paul
              wrote on last edited by
              #7

              The MQTT gateway is not a broker. It is a client.

              Let me try to explain MQTT architecture to my understanding. MQTT is just a protocol for which clients talk to each other. However, in order for clients to talk, they need a server. This server is called the broker which can be mosquitto or RabbitMQ, etc.

              MQTT gateway is a client(A publishing one) which publishes messages to the server(RabbitMQ). Any other clients(Subscribing ones) who wish to receive messages will have to subscribe to the topic through the server(RabbitMQ). In any case, if a subscribing client wants to listen to a publishing client, the subscribing client has to subscribe to the same topic the publishing client publishes to. Both clients have to connect to a broker(RabbitMQ).

              I have already implemented my design as in the diagram above and it works. =) I guess what you mean is that if your client does not understand the messages coming from the MQTT gateway by MySensors, then you would need another client who republishes the message in a format that your clients understand.

              TD22057T 1 Reply Last reply
              1
              • P paul

                The MQTT gateway is not a broker. It is a client.

                Let me try to explain MQTT architecture to my understanding. MQTT is just a protocol for which clients talk to each other. However, in order for clients to talk, they need a server. This server is called the broker which can be mosquitto or RabbitMQ, etc.

                MQTT gateway is a client(A publishing one) which publishes messages to the server(RabbitMQ). Any other clients(Subscribing ones) who wish to receive messages will have to subscribe to the topic through the server(RabbitMQ). In any case, if a subscribing client wants to listen to a publishing client, the subscribing client has to subscribe to the same topic the publishing client publishes to. Both clients have to connect to a broker(RabbitMQ).

                I have already implemented my design as in the diagram above and it works. =) I guess what you mean is that if your client does not understand the messages coming from the MQTT gateway by MySensors, then you would need another client who republishes the message in a format that your clients understand.

                TD22057T Offline
                TD22057T Offline
                TD22057
                Hardware Contributor
                wrote on last edited by
                #8

                https://github.com/mysensors/Arduino/blob/master/libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino

                In that gateway code is the TCP_IP and TCP_PORT the external broker IP and port numbers? The comments say those are the static IP and a port to listen on. I read that as saying it's the static IP of the gateway and the port for the broker to listen on but perhaps they mean the remote IP/Port of the broker to connect to.

                P 1 Reply Last reply
                1
                • TD22057T Offline
                  TD22057T Offline
                  TD22057
                  Hardware Contributor
                  wrote on last edited by
                  #9

                  See here: http://forum.mysensors.org/topic/1034/mqtt-gateway-openhab-mosquitto/2 which connects mosquitto to the gateway using the bridge input. Bridging is used for connecting two brokers together (see http://mosquitto.org/man/mosquitto-conf-5.html "configuring bridges").

                  P 1 Reply Last reply
                  0
                  • TD22057T TD22057

                    https://github.com/mysensors/Arduino/blob/master/libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino

                    In that gateway code is the TCP_IP and TCP_PORT the external broker IP and port numbers? The comments say those are the static IP and a port to listen on. I read that as saying it's the static IP of the gateway and the port for the broker to listen on but perhaps they mean the remote IP/Port of the broker to connect to.

                    P Offline
                    P Offline
                    paul
                    wrote on last edited by
                    #10

                    @TD22057 said:

                    https://github.com/mysensors/Arduino/blob/master/libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino

                    In that gateway code is the TCP_IP and TCP_PORT the external broker IP and port numbers? The comments say those are the static IP and a port to listen on. I read that as saying it's the static IP of the gateway and the port for the broker to listen on but perhaps they mean the remote IP/Port of the broker to connect to.

                    I have'nt used MySensors's MQTT Gateway, but if I am not wrong, TCP_IP is the IP you want your arduino to have. TCP_Port is the port you want others to connect to your arduino. Using these two parameters, your arduino will create a ethernet server for others to connect to.

                    1 Reply Last reply
                    0
                    • TD22057T TD22057

                      See here: http://forum.mysensors.org/topic/1034/mqtt-gateway-openhab-mosquitto/2 which connects mosquitto to the gateway using the bridge input. Bridging is used for connecting two brokers together (see http://mosquitto.org/man/mosquitto-conf-5.html "configuring bridges").

                      P Offline
                      P Offline
                      paul
                      wrote on last edited by
                      #11

                      @TD22057 said:

                      See here: http://forum.mysensors.org/topic/1034/mqtt-gateway-openhab-mosquitto/2 which connects mosquitto to the gateway using the bridge input. Bridging is used for connecting two brokers together (see http://mosquitto.org/man/mosquitto-conf-5.html "configuring bridges").

                      I think MySensor's MQTT Gateway is already a broker by itself where clients like OpenHab can connect to. However, if there is a need, you can use a bridge which forwards the messages from a remote broker(MySensor's MQTT Gateway) to a local broker(Mosquitto). Then clients could now also connect to Mosquitto.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      10

                      Online

                      11.7k

                      Users

                      11.2k

                      Topics

                      113.1k

                      Posts


                      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • MySensors
                      • OpenHardware.io
                      • Categories
                      • Recent
                      • Tags
                      • Popular