src="https://cdn.jsdelivr.net/npm/chart.js"></script> </head>
<body> <h1>Power Usage Dashboard</h1> <canvas id="myChart"
width="400" height="200"></canvas> <script> var ctx =
document.getElementById('myChart').getContext('2d'); var myChart
new Chart(ctx, { type: 'line', data: { labels: [], datasets: [{
label: 'Battery Voltage', borderColor: 'rgb(75, 192, 192)', data:
[] }, { label: 'Solar Power', borderColor: 'rgb(255, 159, 64)',
data: [] }, { label: 'House Power', borderColor: 'rgb(54, 162,
235)', data: [] }] }, options: { scales: { x: { type: 'realtime',
realtime: { duration: 20000, refresh: 2000, delay: 2000,
onRefresh: function(chart) { fetch('/data') .then(response =>
response.json()) .then(data => {
chart.data.labels.push(Date.now());
chart.data.datasets[0].data.push(data.battery_voltage);
chart.data.datasets[1].data.push(data.solar_power);
chart.data.datasets[2].data.push(data.house_power);
chart.update('quiet'); }); } } } } } }); </script> </body> </html
Step 4: Run the Flask Application
1. Start the Flask Application:

bash
Copy code
python3 app.py
2. Access the Dashboard: Open a web browser and go to
http://<Raspberry_Pi_IP>:5000 to view the dashboard.
Summary
Setup: Install necessary libraries and create Python scripts for data collection and a Flas
application for the dashboard.
Data Collection: Use sensors and MQTT to collect and publish data.
Web Dashboard: Create a simple web dashboard using Flask and Chart.js to display re
time power usage data.
Access: View the dashboard on any device connected to the local network by navigating
to the Raspberry Pi's IP address.
This setup provides a web-enabled dashboard for real-time monitoring of power usage, helpin
the landlord manage multiple homes efficiently.

Sample Code for low power management
import RPi.GPIO as GPIO import time import paho.mqtt.client as mqtt
import Adafruit_ADS1x15 # For ADC to read current sensors # GPIO setu
RELAY_PIN_SOLAR = 17 RELAY_PIN_GRID = 27 RELAY_PIN_BATTERY = 22
RELAY_PIN_AC = 23 # Additional relay for AC GPIO.setmode(GPIO.BCM)
GPIO.setup(RELAY_PIN_SOLAR, GPIO.OUT) GPIO.setup(RELAY_PIN_GRID,