Using Raspberry PI access point where no physical network is available for MQTT based project

Thread Starter

zazas321

Joined Nov 29, 2015
936
Hello. I want to develop a little project for my garden.
The core of the system would be the Raspberry PI 4 with a 7" inch display sitting in my greenhouse. I would like to use MQTT ( with NODE-RED or python I havent decided yet but I think using node-red would be the most convenient as you can make quite neat user interfaces there). I will have multiple esp32 devices scattered across my garden doing various tasks ( measuring temperature of various places, humidity, soil humidity, smart watering system and etc) and I want those ESP32 devices to communicate to my Raspberry PI using MQTT so I can avoid wiring everything together which would be extremely inconvenient.

My main concern:

1. Since the Raspberry PI and ESP32 devices will be sitting somewhere outdoors outside my home WiFi range, is it possible to use MQTT? I read that MQTT does not actually need physical internet connection, it just needs IP network. Can I somehow create an access point on my Raspberry PI where no physical internet is available and connect to that access point on my ESP32 devices so I can send publish/receive MQTT packets between the devices? If not, are there any other ways to achieve this?

Thanks in advance.
 

Ya’akov

Joined Jan 27, 2019
9,164
The MQTT daemon doesn't require a connection to any particular network. There is no dependency on the Internet inherent in it. It will work on an ad hoc network, or with the RPi in AP mode. There is no concern at all.
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
In the past, I have used MQTT with the mousquito client. Would that client not work where the internet is not available? I would need to use a client such as daemon?
 

Ya’akov

Joined Jan 27, 2019
9,164
In the past, I have used MQTT with the mousquito client. Would that client not work where the internet is not available? I would need to use a client such as daemon?
Mosquito will work perfectly, the daemon I referred to was the MQTT service, no matter which product you choose.

MQTT simply needs to connect via TCP/IP between the client and server. It doesn't care at all, has no concern with, the presence or absence of gateways to any other networks.
 

MarkGoepel

Joined May 24, 2021
1
Mosquito will work perfectly, the daemon I referred to was the MQTT service, no matter which product you choose.

MQTT simply needs to connect via TCP/IP between the client and server. It doesn't care at all, has no concern with, the presence or absence of gateways to any other networks.
Sounds like you're setting yourself up for loads of fun.

The couple of comments I would make are
1.
RPI4 and ESP32s are almose certainly overkill.
I have been running more than 20 ESP8266s on my home WiFi network for over three years, measuring everything from Temperature/Pressure/Humidity with the BME280s, Lux Levels, Electricity Import from the grid with a pulse counter on the flashing light on my Electricity Meter using an LDR, Temperatures usind DS18B20s, and various digital input and output to drives relays for hardwired lights, etc
The ESPs also drive a bunch of digital NTP accurate clockes scattered about the place
The "back end" to all this is a Raspberry PI 2, running nodered and mosquitto (MQTT Broker)
Even with nodered and mosquitto and some pretty complex nodered integration rules for control and to make webAPI call to historize my data, there is plenty of spare capacity on the RPI2.

I power all my ESP8266s with old USB power supplies, plugged into MAINs supply, so I don't have to worry about batteries.

Heat dissipation might become an issue with an RPI4.

2.
Take a look at the ESPEASY (LetsControllIt) opensource firmware
and
Tasmota

Have Fun!!

</mytwocents>

make
Mosquito will work perfectly, the daemon I referred to was the MQTT service, no matter which product you choose.

MQTT simply needs to connect via TCP/IP between the client and server. It doesn't care at all, has no concern with, the presence or absence of gateways to any other networks.
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
Hello. I have sucesfully made a prototype using Raspberry PI 3 and esp32 device. ESP32 has a temperature sensor connected to it and I am publishing the data to my Raspberry PI which is running MQTT mosquitto on a Node-red. I am able to receive the data sucesfully.

I am connected to my home wifi at the moment for testing.


However, it is still not clear to me how can I do the same thing where no internet access is available. Perhaps you could point me in the right direction how to setup an access point on my raspberry PI to which I could connect on my ESP32 device?

Most guides such as: https://www.raspberrypi.org/documentation/configuration/wireless/access-point-routed.md show that I need my Raspberry PI connected to a network either using a wired cable or Wi-Fi.
 

Ya’akov

Joined Jan 27, 2019
9,164
Hello. I have sucesfully made a prototype using Raspberry PI 3 and esp32 device. ESP32 has a temperature sensor connected to it and I am publishing the data to my Raspberry PI which is running MQTT mosquitto on a Node-red. I am able to receive the data sucesfully.

I am connected to my home wifi at the moment for testing.


However, it is still not clear to me how can I do the same thing where no internet access is available. Perhaps you could point me in the right direction how to setup an access point on my raspberry PI to which I could connect on my ESP32 device?

Most guides such as: https://www.raspberrypi.org/documentation/configuration/wireless/access-point-routed.md show that I need my Raspberry PI connected to a network either using a wired cable or Wi-Fi.
The “routed” part is superfluous for you. You can use the guide and omit the WAN connection.
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
Can you clarify what do you mean omit the WAN connection?

From what I understand, the following part is not necessary for me:
1622022813698.png

as well as
1622022859500.png



Also, I am not certain how DHCP will work if I have not set the static IP for my Raspberry Pi,


1622022964220.png

If I understand this correctly, The Raspberry PI will give IP addresses to my remote clients ( ESP32 ) from rnage 192.168.4.2 to 4.20, but the rapsberry PI must have the static IP set to 192.168.4.1 for this to work right?
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
Okay issue solved. The only part that I do not care about from the guide is the following:
1622023821739.png

The rest is needed. I have made an access point on my RPBI with ip address 192.168.4.1 and can connect to it from my ESP32 device without any issues. My mqtt is working. Thanks
 

ronsimpson

Joined Oct 7, 2019
3,037
I just want to understand.
It looks like you want a network with RPi and some ESP32s. No more than that.
From the data provided you could have a network for PCs and a network for ESP32s with a RPi as a bridge in-between.
My question is why have the ESP32s off on their own network? Why not have everything, PCs and ESPs, lumped together?
In my case I have four routers used as range extenders to cover a larger area.
1622033427996.png
 

Ya’akov

Joined Jan 27, 2019
9,164
I just want to understand.
It looks like you want a network with RPi and some ESP32s. No more than that.
From the data provided you could have a network for PCs and a network for ESP32s with a RPi as a bridge in-between.
My question is why have the ESP32s off on their own network? Why not have everything, PCs and ESPs, lumped together?
In my case I have four routers used as range extenders to cover a larger area.
View attachment 239656
He said earlier that this is a standalone network, outside, and away from any other network. So, he's using the RPi as an AP with no connection to any other network.
 
Top