Using MQTT without a stationary router

Hello,

I have a problem and I hope that anyone can help me with it. I am setting up a home automation system, where the different devices communicate via MQTT. There is no stationary router in the house as I am using my mobile phone as a hotspot. So basically when I’m out, there is no Internet in the house.

Installing, setting up and configuring the Raspberry is done over the phones hotspot and works fine. However, as soon as I turn of the hotspot, MQTT does not work anymore.

Is there any way that that could be fixed? Googling it brought only basic explanations about how to set up MQTT unfortunately.

Kind regards
Nina

Where is your MQTT server?

Hello nickrout,

it is running on Home Assistant (Mosquitto)…

Nina

You need a router and at least one wireless access point (usually in the same box at consumer level). You do not need an internet connection, however.

Your wifi devices cannot connect directly to your Home Assistant box — that’s not how networks work.

1 Like

Hello Troon,

thank you for your help. I think I left out an important point here: I have the Raspberry connected to a switch via a cat-6 cable. My sensors are either: A: connected to that switch via cat-6 as well, or B: connected via Zigbee (zigbee2mqtt using Slaesh’s CC2652RB stick).

So I was wondering what I had to do to keep them functioning after I switched off the Wifi.

Thanks
Nina

I’m not sure what is stopping them continuing in that case, but if the devices are using mDNS rather than IP addresses, that would cause problems with no DNS server on the network.

Perhaps try setting up Pi-Hole as a DNS and DHCP server? That’s just a guess, though: I’d still recommend keeping things “standard” by installing a real router.

Hello Troon,

that goes into the direction of what I was thinking… My idea was to:

  1. Set up Raspberry via Wifi (copying “my-network” with the Wifi-Credentials into “ROOT\CONFIG\network\my-network” before the first start)
  2. Installing Zigbee2MQTT and Mosquitto and setting it up
  3. SOMEHOW tell the Raspberry to act as a router from now on → see below
  4. Changing the Wifi-Password. From then on the Raspberry should work completely offline. If I want to update, I’d have to change the Wifi-password again and the Raspberry would immediately come back online.

About #3: I thought, something like Using Raspberry Pi as a Wired Router – Linux Hint would be exactly what I needed to do, what do you think?

Thanks
Nina

I don’t have enough experience of this to advise further, sorry. Why are you so keen not to have a router, though? I would have thought you could find an old ISP-supplied one for almost no money — if it’s not connecting to the internet, you don’t have any security or performance concerns: all of the point-to-point traffic will be via your switch.

Hello Troon,

you’re right. The reason for that is, that I want as few devices as possible. The whole setup is running on solar/batteries, so I’m tight with power.

Thanks
Nina

Username checks out.

Perhaps replace the switch with something like a MikroTik hEX Lite then? Only 2W, 5 10/100 ports.

Hello Troon,

^^

So,

I have something that looks exactly like that: https://www.ebay.de/itm/353495044374 . If I understand you correctly, the difference between mine and yours is, that your’s will take care of giving an IP to all devices connected?

Thanks
Nina

Yes, exactly. The MicroTik I suggested is a router / gateway / switch, whereas your switch is just a switch.

I see! Is there something like that with a few more ports? What do I have to look for? I searched for “ethernet router” so far…

If I get this right, that could completely replace my switch, correct?

Thanks
Nina

Yes, that’s correct. You might find that the bigger routers draw more power than a small router plus your existing switch though.

10-port MikroTik that draws 6W (I’m only suggesting them as they are relatively well-regarded “proper” routers as opposed to consumer ones that can be… variable in quality). This one has gigabit ports.

8-port D-Link at 7.5W here, only 10/100Mbps if that matters.

I might have missed something, but why not configuring the RPI as a dhcp on the wired network?
The RPI could as well act as a router between the WiFI/hotspot and the wired network.

Not quite an out-out-the-box solution, ofc.

Thanks so much, Troon,

I will look into these! However, maybe I found a different solution where I’m a bit more versatile on the components I’d need. See my next post, replying to koying.

Curious about what you think!

Nina

Hello koying,

I like the idea, and it is similar to what I was looking into just now. I found GitHub - joaofl/hassio-addons: More add-ons for your Hass.io. , which would do exactly what you suggested, just for Wifi, right?

If that’s correct, maybe there is a way to - as you suggested - also configure the RPI as a DHCP on the wired network. Then my Arduinos would be able to communicate via Ethernet, and I could put a tablet on the wall which would connect to the Wifi-Network that the Raspberry created. Would that work?

Thanks
Nina

Not really. That addon creates a wifi hotspot of its own, which is not what you want if your mobile is the gateway to the internet.

You want addons/dhcp_server at e933cba5a457a492fec458dcb2629e9dbadeb569 · home-assistant/addons · GitHub for the dhcp part (gives ip to your wired network)

The routing part will be trickier, as I don’t think there is any addon for that.
You might take the linuxhint page as a reference.
Start at the “Configuring the Firewall and Enable Packet Forwarding”. Whatever comes before would be provided by Hassio and the addon.

Hello koying,

I was thinking of “almost never” connecting the Raspberry to the internet after the initial setup. So I thought, that Add-on would allow me to wirelessly connect a tablet to the Raspberry for the dashboard. However, there should be 2 ways of doing this though:

  1. Have the Raspberry create a Wifi-Network, and connect to that with the tablet
  2. Have the Tablet create a Wifi-Network (without internet), and set up the Raspberry to connect to that

The Advantage of #2 would be, that I could easily “give” internet to the Raspberry if I wanted to update anything: I just had to disable the Wifi on the “Wifi-without-internet-tablet” and open up a Wifi with my phone with the same credentials…

Which one do you think is best?

Nina

Yep #2 is preferable.
If you go #1, the RPI will never have access to Internet, so doing HA updates will be tricky.