What about a mini MQTT broker on the ESP32?

Place your projects here
User avatar
cicciocb
Site Admin
Posts: 2516
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 531 times
Been thanked: 1788 times
Contact:

Re: What about a mini MQTT broker on the ESP32?

Post by cicciocb »

Thanks for your feedback.
If I understand well that you using 3 clients with 7 topics.

Again, if I understand well the "broker" ESP32-S3 is also the one that receive the UDP messages from the sensors.
I suppose that the ESP32-S3 do not have a PSRAM (otherwise you should have much more memory free available) and this is a very good news .

Yes, in this case the broker has a quite small background activity and it should be able to handle the task without problems.

So, good news so far, I'm also happily surprised on how the broker works well inside Annex in parallel with other activities.
Next step is to test in parallel with the BLE and see if the broker can also exchange with a bluetooth application

edit:
how long are your json messages? Actually I limited the payloads at 256 characters (because I'm using a queue and the goal is to limit the ram memory usage) but I could increase this at 512
lyizb
Posts: 213
Joined: Fri Feb 12, 2021 8:23 pm
Has thanked: 103 times
Been thanked: 77 times

Re: What about a mini MQTT broker on the ESP32?

Post by lyizb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Mon Oct 28, 2024 9:23 amI am receiving data from approx 30 sensors via UDP in json strings, over 7 topics, I am also monitoring ramfree in another topic so I can graph it.
This is terrific and aspirational. Can you share the code for your "Annex House" graphic?
User avatar
cicciocb
Site Admin
Posts: 2516
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 531 times
Been thanked: 1788 times
Contact:

Re: What about a mini MQTT broker on the ESP32?

Post by cicciocb »

OK, I left the broker running for around 24 hours and I'm happy to say that there are no memory leaks and it still work great.

I tested the link with the Iot MQTT panel on my Iphone and also works perfectly.
peridot
Posts: 56
Joined: Mon Mar 08, 2021 4:54 am
Has thanked: 9 times
Been thanked: 106 times

Re: What about a mini MQTT broker on the ESP32?

Post by peridot »

Hi, Early morning here. Running some 12 hrs no errors or resets in the log, ramfree is same.

Actually your comment re my chip not having psram is a good one as I thought it should have. I have not wanted to stop it running at the moment to investigate. I guess I shouldn't have to do anything to use the psram? if it is present then Annex should use and recognise it?

2024-10-29 08_06_14-Lolin WeMos S3 Mini - ESP32-S3 Wifi Bluetooth IoT Development Board — Mozilla Fi.png
The longest json string I have is 161 char, that's for the Cumulus (Weather Software), actually its a good point you raise as 256 may not be sufficient for a full cumulus string as this currently is only testing. How difficult etc would it be to allow a larger string?

IOT Panel is a great program and now we have MQTT saves having to create an interface.

2024-10-29 07_41_47-MQTT Explorer.png
You do not have the required permissions to view the files attached to this post.
peridot
Posts: 56
Joined: Mon Mar 08, 2021 4:54 am
Has thanked: 9 times
Been thanked: 106 times

Re: What about a mini MQTT broker on the ESP32?

Post by peridot »

Hi Lyizb,
This is terrific and aspirational. Can you share the code for your "Annex House" graphic?
If I understand you? its not code its an Android program called MQTT IOT Panel, I find it very useful , easy to use and making a display is easy.

Mike
lyizb
Posts: 213
Joined: Fri Feb 12, 2021 8:23 pm
Has thanked: 103 times
Been thanked: 77 times

Re: What about a mini MQTT broker on the ESP32?

Post by lyizb »

Ah, Ok, thank you -- MQTT IOT Panel.
User avatar
cicciocb
Site Admin
Posts: 2516
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 531 times
Been thanked: 1788 times
Contact:

Re: What about a mini MQTT broker on the ESP32?

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Mon Oct 28, 2024 9:09 pm Hi, Early morning here. Running some 12 hrs no errors or resets in the log, ramfree is same.

Actually your comment re my chip not having psram is a good one as I thought it should have. I have not wanted to stop it running at the moment to investigate. I guess I shouldn't have to do anything to use the psram? if it is present then Annex should use and recognise it?


2024-10-29 08_06_14-Lolin WeMos S3 Mini - ESP32-S3 Wifi Bluetooth IoT Development Board — Mozilla Fi.png

The longest json string I have is 161 char, that's for the Cumulus (Weather Software), actually its a good point you raise as 256 may not be sufficient for a full cumulus string as this currently is only testing. How difficult etc would it be to allow a larger string?

IOT Panel is a great program and now we have MQTT saves having to create an interface.


2024-10-29 07_41_47-MQTT Explorer.png
Hi, the PSRAM is automatically taken into account, if installed.
In your case, with only 3/4 clients, the broker do not require too much RAM. In my test case, with 12 clients connected, I have plenty of RAM free (the PSRAM is 8MB) but the "very precious" RAM, the internal one used by the internal functions is also ~130KB.
I can say that, so far, the only limit I found is the max number of clients allowed simultaneously that is limited by the OS itself.

Increasing the size of the payloads is not a problem, is just a question of determine the good value or enabling the choice using an option somewhere.

My config still runs without any issues since 2 days ...
Monki
Posts: 61
Joined: Mon Feb 27, 2023 12:56 pm
Location: Berlin
Has thanked: 21 times
Been thanked: 13 times

Re: What about a mini MQTT broker on the ESP32?

Post by Monki »

Hello Francesco,
I did some tests today with my Shelly weather station and the Shelly motion sensor, and I noticed that some status messages in the Shelly's JSON format actually contain more than 256 characters.
It would be an advantage if you could optionally specify the buffer size for the messages.
Greetings
User avatar
cicciocb
Site Admin
Posts: 2516
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 531 times
Been thanked: 1788 times
Contact:

Re: What about a mini MQTT broker on the ESP32?

Post by cicciocb »

A little demo of the broker with 9 tasmota / openbeken.
In parallel, there are 3 additional ESP32 modules connected in MQTT (for a total of 12 devices)

Helmut_number_one
Posts: 145
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 92 times
Been thanked: 17 times

Re: What about a mini MQTT broker on the ESP32?

Post by Helmut_number_one »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Mon Oct 28, 2024 9:23 am OT Panel, was fantastisch ist.....
Yes, The app ( IO-Panel )is super good, a little poorly described, but great options.
Post Reply