How do I connect MQTT to Two Arduino Gateways

I’m running OpenHAB & Mosquitto service on Windows 7.

I’ve successfully created an RFM69 wireless network where an Arduino RFM69 Gateway bridges between several Arduino RFM69 nodes & MQTT/OpenHAB.

However for more expansion capability, I want to add a second network of a second Gateway plus nodes.

I created a second network of a Gateway & one node. & when ONLY that network is running, it connects fine with MQTT & OpenHAB.

When I run both networks at the same time, both Gateways sort of connect to MQTT, but obviously interfere with each other & bog down communication that is seen in the OpenHAB logging.

How can I configure things so both Arduino Gateways / Networks connect to MQTT & not interfere with each other?

Thanks

The interference you are seeing is likely the RFM69 wireless signals blocking each other. There is no reason why the broker or OH would have any problems with two or any number a clients posting and subscribing.

I’m not expert in RFM69 so I don’t know in detail how the gateways work, but from your description it may not support having more than one gateway. You may be able to add some logic to the gateway so it ignores the messages from the other network and does not send them on to MQTT, but that will not stop both gateways from receiving and having to process all transmissions from all nodes in both networks.

Unfortunately this is not going to be something the bulk of the users on this forum will have much experience with so if you don’t find an answer here you might try elsewhere like the LowPowerLab forums.

Thanks for a response, Rich.

I would also think “There is no reason why the broker or OH would have any problems with two or any number a clients posting and subscribing.”

However, each gateway has an LED & supported code that indicates whether the gateway is connected to MQTT. Either gateway on its own connects & stays connected to MQTT. With both gateways on, I can see the MQTT LEDs briefly & rapidly blipping with connect & disconnect. Each gateway & its network have their own gateway id, network id, & network encryption key so they should be able to ignore signals from the other network. I am pretty sure that it is the two gateways bumping each other from connecting to MQTT via Ethernet, not wireless signals interference.

I am looking & asking at a variety of sites including LowPowerLabs. I’m just giving openhab community readers a short as well. In another forum, we’ve talked about more than one gateway / network as a way to expand capacity, but I’ve never seen anyone describe more than one or OR say that more than one is not possible.

The way MQTT is designed and built you can have hundreds or thousands of clients connected to the same broker. So having three clients (oh and the two gateways) is no problem. I myself and running with six clients with no problems.

The only thing I can think of is to try making each gateway post to a different topic to see if that makes a difference. If there is any sort of collision going on it will be at the topic on the broker.

Hello,

When I run both networks at the same time, both Gateways sort of connect to MQTT, but obviously interfere with each other & bog down communication that is seen in the OpenHAB logging.

What do you mean by “bog down” do you mean that there is Ntuples infos?

From an architecture point of view, my main interrogation about your system is; if both gateway are able to receive the signal coming from one unique sensor how to handle this unicity.

My thoughts about that would be to bypasse the issue at gateway level or OpenHAB level,

  • At gateway level by adding a kind of signal repetition avoidance program, for instance if the gateway A received a signal send the info to gateway B to be able to filter it.
  • At openHAB level you could with a timer don’t take into account Ntuples nodes infos.

If I had to do that I will do it at OpenHAB level, in fact my sensors (not my gateway) are already sending Ntuples and I’m handling this with a timer.

Just for my curiosity why do you need to have two gateways?

Regards

Thanks for more responses to my problem. I must go elsewhere shortly, but will try later to respond more than the following:

Besides " Each gateway & its network have their own gateway id, network id, & network encryption key," as I said before, each gateway has its own MAC & IP address connecting to my home Ethernet network.

AND Rich, each gateway has its own topic.

1technophile, in a windows cmd box, I can see OpenHAB logging in real time. With my one regular network in operation, I see steady log posts. When both gateways are powered connected & connected the the home ethernet network, the OpenHAB logging messages go from regular posts to very few & do not show errors.

OK, I solved it. It should be pretty simple to solve if one knows what they are doing about MQTT, which I don’t know much. I just knew somethings connect, then something subscribes & some things publish.

I’m getting to know the node code possibilities much more, but I have not done much with gateway code because to this point (after a few settings covered), it has worked.

However I am dogged about analyzing, asking help, & trying things until I often find a solution or a dead end.

There were clues embedded in our communications about my problem on this forum & a couple others:

I kept saying it seemed like a problem mainly with MQTT from the two gateways fighting each other & knocking each other off.

In a general sense, some of you would talk about MQTT clients.

So the solution came down to the one necessary MQTT thing that I did not have different on the two gateways.

I needed to give the second gateway … a different clientName. The gateways were fighting because they kept trying to connect with the same clientName.

Now I have a one Gateway plus its several nodes AND a new second Gateway plus its one node both connected to the same MQTT server & the same openHAB UI & its all working together just fine.

Now I see that one can spread the load of node communication & expand the network capability by using more than one gateway. (That’s why I tried to solve this.)

2 Likes

Sometimes it is the simplest thing. Glad you got it to work.

Thanks, Rich. Yes, sometimes, maybe even often in my experience, it is the simplest thing that blocks success. Then again, it’s not simple UNTIL we or someone else notices it.

I’m still getting a good crisp response between the new gateway & it’s one node & between the original gateway & its several nodes (no degradation noticed from the added gateway) AND both gateways are reliably bridging their communications between their nodes & MQTT/OpenHAB.