A real-time sensor dashboard shows live data from sensors so you can watch changes as they happen. It helps you make quick decisions based on current information.
0
0
Real-time sensor dashboard in Raspberry Pi
Introduction
Monitoring temperature and humidity in a greenhouse to keep plants healthy.
Tracking air quality in a room to ensure safe breathing conditions.
Watching machine vibrations in a factory to prevent breakdowns.
Checking water levels in a tank to avoid overflow or shortage.
Syntax
Raspberry Pi
1. Collect sensor data using Raspberry Pi sensors. 2. Send data to a dashboard app or web page. 3. Update the dashboard display in real-time using a refresh method or WebSocket. 4. Visualize data with charts, gauges, or numbers.
Use simple Python scripts on Raspberry Pi to read sensor values.
Choose a dashboard tool that supports live updates, like Grafana or a custom web page.
Examples
This Python script simulates reading temperature every second and prints it.
Raspberry Pi
import time import random while True: temperature = random.uniform(20, 30) print(f"Temperature: {temperature:.2f} °C") time.sleep(1)
This JavaScript code updates a web page element every second with new temperature data from the server.
Raspberry Pi
<script>
setInterval(() => {
fetch('/sensor-data')
.then(res => res.json())
.then(data => {
document.getElementById('temp').textContent = data.temperature + ' °C';
});
}, 1000);
</script>Sample Program
This Python Flask app simulates sensor data and serves it to a simple dashboard web page that can request updates every second.
Raspberry Pi
import time import random from flask import Flask, jsonify, render_template app = Flask(__name__) @app.route('/') def index(): return render_template('dashboard.html') @app.route('/sensor-data') def sensor_data(): temperature = round(random.uniform(20, 30), 2) humidity = round(random.uniform(40, 60), 2) return jsonify({'temperature': temperature, 'humidity': humidity}) if __name__ == '__main__': app.run(debug=True)
OutputSuccess
Important Notes
Make sure your Raspberry Pi has network access to serve the dashboard.
Use simple charts or numbers for clear, quick understanding.
Test sensor readings separately before integrating with the dashboard.
Summary
A real-time sensor dashboard shows live sensor data to help you watch changes instantly.
Use Raspberry Pi to collect data and a web app to display it with automatic updates.
Keep visuals simple and update frequently for best results.