MQTT Binging - Possible two MQTT broker?



  • Hello to all!
    I'm using OpenHAB with an arduino network powered by mysensors.org project.
    OpenHAB is working well using a MQTT connection to this arduino gateway. Until here all works fine.
    I would like to add a second MQTT broker on the mysensors network, because I would like to add a second arduino gateway with a different radio hardware. Actually I'm using all nodes with nRF24L01+ nodes. I would like to add a RFM69 network as well.
    Can Openhab handle the same time comunication to TWO MQTT brokers?
    I cannot try because I need to buy the needed hardware and I would like to do it only if I know it's working.

    Or In case do you suggest a different approach? Using in example the new gateway with a serial gateway?
    Any suggestion would be really appreciated!

    Many thanks for the help!

    Simon



  • maybe the solution is to use an alternative setup:
    Not using the mqtt gateway from the example, but using the mqtt CLIENT gateway (currently on the development branch)

    This allows u to set up an mqtt broker (mosquitto) on your openhap host and the two gateways are sending their messages to this broker instead of being the broker themselves.

    Edit:
    narf. i see the client gateway examples are only for w5100 and ESP8266



  • Hello @dakky ,
    I've asked the same on OpenHAB and the answer was that it is possible to add a second MQTT Instance:

    https://community.openhab.org/t/mqtt-binging-possible-two-mqtt-broker/5193

    BTW could you give me some other informations on your solution?
    Could I already implement this setup? How?

    Thanks!

    Simon



  • The setup itself is working. The problem is, that you're using the RFM69 module as network device. There is no client gateway example for that device and i think i've read somehere here, that it won't become implemented (to large footprint?).

    EDIT:
    in case u're still interested, here a small impression how simple this setup works:

    • install mosquitto on raspbian
      quite simple apt-get install and ready to run
    • modify gateway client example (mac, ip, mqtt broker ip) and uplaod it
      this is a little bit annoying: I needed to upgrade to an arduino mega because the uno was too small for softISP, message singing and debug. But nevertheless ...
    • subscribing to all moqsuitto messages on rasbian:
      mosquitto_sub  -v -t '#'
      
      results in appearing messages from the node
      sensor-gw1-out/99/255/3/0/11 Test Sensor
      sensor-gw1-out/99/255/3/0/12 0.1
      sensor-gw1-out/99/3/1/0/16 1
      
    • item in openhab listening to that event:
      String  sketch_name_99    "Sketch name 99 (Test Item) [%s]"  (sketch,all) { mqtt="<[mysensors:sensor-gw1-out/99/255/3/0/11:state:default]" }
      

    Thats it



  • @dakky, you mean there is not a controller gateway working with the radios RFM69?
    The doc is mentioning it:

    http://www.mysensors.org/build/connect_radio
    "Wiring the RFM69 Radio"

    Then, on the MQTT gateway side, I've seen in the code:

    (...)
    #include <MyTransportRFM69.h>
    (...)
    // NRFRF24L01 radio driver (set low transmit power by default) 
    MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW);  
    //MyTransportRFM69 transport;
    (...)
    

    So I think it shoud be enough to commet out the MyTransportNRF24 and uncomment the MyTransportRFM69, right??

    Then, I'm not understanding your instructions:

    modify gateway client example (mac, ip, mqtt broker ip) and uplaod it
    this is a little bit annoying: I needed to upgrade to an arduino mega because the uno was too small for softISP, message singing and debug. But nevertheless ...

    Which gateway client? The arduino gateway? It's in listening mode AFAYK also, as soon there is a subscription on it, it would comunicate with it, not?

    And why you need an arduino mega? Isn't it using the same PINS like them on a gateway using the NRF24?

    I would expect that the final result would be, from the controller up to the sensors

    • OpenHAB with two MQTT instances pointing to two MQTT Broker, one for the NRF24 sensors, second for RFM69 sensors
      • Gateway MQTT for the NRF24 sensors
        • NRF24 sensors and repeaters
      • Gateway MQTT for RFM69 sensors
        • RFM69 sensors and repeaters

    So I cannot understood why I need mosquito server 😓

    Thanks again for the help!

    Simon



  • I use a different kind of setup. I'm not using the mqttGateway example but die mqttClientGateway.
    This means the arduino gateway is not the messagebroker (server) itself, but is forwarding the messages to another broker (mosquitto)

    This allows me to post non-mysensors messages to the broker and openhab can consume them. A external broker is nessecary, because the mqttClientGateway can handle only one single connection (openhab, so no new messages from external tools, no debugging while openhab is connected etc) and i'm much more experienced in using software on the linux side instead on arduino => external broker

    When looking in the examples of mysensors, there are only 2 examples for mqttClientGateways (development branch):

    • GatewayESP8266MQTTClient (wlan afaik)
    • GatewayW5100MQTTClient (shield/module with w5100 chip)

    The Mega is nessecary, because the sketch size with optiboot was 108% of the allowed size without debugging (as far as i remember)
    And Yes the pins are other ones on the mega, but that requires just changing the sketch.



  • Ok @dakky, it means simply that with your setup you have more control and debug over the mqtt broker. And you are using the mega256 because the soft-spi uses more space.
    My only limitation is I need the MEGA256 and I would like to use my own arduino boards and the network shield I've already purchased.

    BTW my setup should work as well, right?

    Then I could move to your setup when the library will be optimized to stay on an arduino uno/nano/promini... 🙂

    Thanks!

    Simon



  • As long as openhab supports (u did already verify that) 2 mqtt connections, you should be fine.



  • Thanks @dakky for the support!!! 🙂

    Simon



  • You're welcome


Log in to reply
 

Suggested Topics

  • 22
  • 132
  • 5
  • 4
  • 3
  • 1

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts