Sensors Dashboard (MQTT Raspberry PI+ESP32+FastHTML)
This guide explains how to set up an ESP32 microcontroller with an LM35 temperature sensor to send real-time data via MQTT to a Raspberry Pi running a Mosquitto broker. The data is then visualized using a sensor dashboard with an interactive UI. We'll walk through: Setting up Mosquitto on a Raspberry Pi Configuring the ESP32 to send sensor data via MQTT Deploying a real-time web-based dashboard for visualization 1️⃣ Install Mosquitto on Raspberry Pi (Raspbian) Run the following commands to install Mosquitto: sudo apt update -y sudo apt install mosquitto 2️⃣ Configure Mosquitto Broker Edit the Mosquitto configuration file: sudo vi /etc/mosquitto/mosquitto.conf Copy and paste the following configuration: pid_file /run/mosquitto/mosquitto.pid persistence true persistence_location /var/lib/mosquitto/ log_dest file /var/log/mosquitto/mosquitto.log include_dir /etc/mosquitto/conf.d allow_anonymous false # Change to 'true' for public connections password_file /etc/mosquitto/passwd listener 1883 0.0.0.0 # Allow binding to the network Save and exit, then restart Mosquitto: sudo systemctl restart mosquitto 3️⃣ Enable and Start Mosquitto sudo systemctl enable mosquitto sudo systemctl start mosquitto 4️⃣ (Optional) Set a Username and Password If allow_anonymous false is set, create a username and password: sudo mosquitto_passwd -c /etc/mosquitto/passwd myUsername Restart Mosquitto: sudo systemctl restart mosquitto 5️⃣ Test the MQTT Server Install Mosquitto Clients sudo apt install mosquitto-clients Publish a Message Without authentication: mosquitto_pub -h localhost -t "test/topic" -m "Hello, Raspberry Pi!" With authentication: mosquitto_pub -h localhost -u "myUser" -P "myPassword" -t "test/topic" -m "Hello, Raspberry Pi!" Subscribe to a Topic Without authentication: mosquitto_sub -h localhost -t "test/topic" With authentication: mosquitto_sub -h localhost -u "myUser" -P "myPassword" -t "test/topic" Tip: For better performance, set a static IP on your Raspberry Pi:

This guide explains how to set up an ESP32 microcontroller with an LM35 temperature sensor to send real-time data via MQTT to a Raspberry Pi running a Mosquitto broker. The data is then visualized using a sensor dashboard with an interactive UI.
We'll walk through:
- Setting up Mosquitto on a Raspberry Pi
- Configuring the ESP32 to send sensor data via MQTT
- Deploying a real-time web-based dashboard for visualization
1️⃣ Install Mosquitto on Raspberry Pi (Raspbian)
Run the following commands to install Mosquitto:
sudo apt update -y
sudo apt install mosquitto
2️⃣ Configure Mosquitto Broker
Edit the Mosquitto configuration file:
sudo vi /etc/mosquitto/mosquitto.conf
Copy and paste the following configuration:
pid_file /run/mosquitto/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
allow_anonymous false # Change to 'true' for public connections
password_file /etc/mosquitto/passwd
listener 1883 0.0.0.0 # Allow binding to the network
Save and exit, then restart Mosquitto:
sudo systemctl restart mosquitto
3️⃣ Enable and Start Mosquitto
sudo systemctl enable mosquitto
sudo systemctl start mosquitto
4️⃣ (Optional) Set a Username and Password
If allow_anonymous false
is set, create a username and password:
sudo mosquitto_passwd -c /etc/mosquitto/passwd myUsername
Restart Mosquitto:
sudo systemctl restart mosquitto
5️⃣ Test the MQTT Server
Install Mosquitto Clients
sudo apt install mosquitto-clients
Publish a Message
Without authentication:
mosquitto_pub -h localhost -t "test/topic" -m "Hello, Raspberry Pi!"
With authentication:
mosquitto_pub -h localhost -u "myUser" -P "myPassword" -t "test/topic" -m "Hello, Raspberry Pi!"
Subscribe to a Topic
Without authentication:
mosquitto_sub -h localhost -t "test/topic"
With authentication:
mosquitto_sub -h localhost -u "myUser" -P "myPassword" -t "test/topic"
Tip: For better performance, set a static IP on your Raspberry Pi: