MQTT Binding - Possible two MQTT broker?

Hello to all!
I’m using OpenHAB with an arduino network powered by mysensors.org project. Mysensors has a central gateway with on one site an ethernet network and on the other side it comunicates with other arduinos via radio. The gateway has a library to handle MQTT.
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.
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.
Many thanks for the help!

Simon

Yes! The wiki page for the MQTT binding shows you how:

so you would repeat the parts for differerent brokers, like

mqtt:mysensors1.url=tcp://foo1.example.com:1883/
mqtt:mysensors1.clientId=openHAB
mqtt:mysensors2.url=tcp://foo2.example.com:1883/
mqtt:mysensors2.clientId=openHAB

Thanks a LOT for the fast answer.
Now I’ll look which RFM69 model to choose, but seems the differences are not so big.

Bye!!

Simon

Not sure why you need a second broker in this case? Can’t you just connect up the new gateway to the same broker on a different set of topics?

The gateway has on one part the hardware with Nrf24L01+ radio to talk with sensors, and the other side network connection.
I cannot add a second radio (RFM69) on the same gateway, so I need to add a second gateway.
Both gateways are then talking to openhab as MQTT broker, so I would need to add a second MQTT instance on OpenHAB. But if it works, than that’s enoug. i hope :smile:

Simon

That should work fine. I just don’t see why each gateway needs to be a broker, since that’s not really how MQTT is supposed to work.

Well @robconnolly, I’m using mostly the libraries without going in deep to apply some modifications.
I could install a mosquito server on openhab server and use the arduino MQTT gateways as MQTT client forwarder. This is something I’ve discovered now, but there is a problem.
Seems the MQTTclientForwarder is in development and not fully completed. In additcion the sketch exceed the maximum flash memory available, so I need to migrate my arduino UNO to a MEGA256 with more memory.
I would avoid to purchase new hardware because I already have my arduinos working well.
Apart of the memory issues, the client forwarder would be the best approach, I know. I could in this way handle troubleshooting and debug much more easier. Actually, the MQTT broker on Arduino handles only one connection. So I cannot subscribe on it manually. This causes the disconnection of the OpenHab client.
So, definetly for now I’ll stay on two MQTT broker on arduinos and I’ll handle on OpenHab two instances. Then, as soon the MQTT client forwarder would be more stable, I’ll try to use it.

Thanks :wink:

Simon

Ah, now it makes sense, although it is a very weird architectural choice by the mysensors developers. I agree with not buying any new hardware - especially if what you have is working.

Good luck!

Thank you @robconnolly!!

I’m using the mqtt client gateway from the development branch of mysensors on a uno and it works great. I run mosquito on the same rpi as openhab.
I find mosquito more reliable than the arduino broker.
This way you can just connect both gateways to the same broker.

I’m also using a gateway (serial) as a client connecting to a mosquitto broker on the Raspi with OpenHAB. The serial gateway is cheaper and easier to build and works great with the script from the post below:http://forum.mysensors.org/topic/996/mqtt-client-using-mysensors-serial-gateway

Thank you, arendst for the script:).

Note: you need to configure manually the node IDs.

Does this work with MySensors API 2.0 as well? Would be great!

Simon