0% found this document useful (0 votes)
9 views8 pages

Raspberry Pi 5 Fireboard 2 Setup Guide

This document outlines a complete Fireboard 2-style program for Raspberry Pi 5, enabling multiple temperature sensors, real-time web dashboard, fan control, Wi-Fi remote monitoring, and MQTT support. It includes installation instructions, code for temperature sensors, fan control, a Flask web dashboard, and MQTT integration. Additionally, it provides a list of required components and their estimated costs, along with suggestions for future enhancements.

Uploaded by

Kenny Hebert
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views8 pages

Raspberry Pi 5 Fireboard 2 Setup Guide

This document outlines a complete Fireboard 2-style program for Raspberry Pi 5, enabling multiple temperature sensors, real-time web dashboard, fan control, Wi-Fi remote monitoring, and MQTT support. It includes installation instructions, code for temperature sensors, fan control, a Flask web dashboard, and MQTT integration. Additionally, it provides a list of required components and their estimated costs, along with suggestions for future enhancements.

Uploaded by

Kenny Hebert
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Here's a complete Fireboard 2-style program for Raspberry Pi 5, supporting:

✅ Multiple temperature sensors (DS18B20 & DHT22)


✅ Real-time web dashboard (Flask & WebSockets)
✅ Fan control via GPIO PWM
✅ Wi-Fi remote monitoring
✅ MQTT support for cloud control

1️⃣ Install Required Software


Before running the code, install necessary libraries:

sudo apt update && sudo apt upgrade -y


sudo apt install python3-pip python3-gpiozero python3-flask python3-flask-
socketio python3-paho-mqtt
pip3 install Adafruit_DHT matplotlib

2️⃣ Enable DS18B20 (1-Wire Sensor)


1. Open Raspberry Pi Config:
2. sudo raspi-config
3. Go to Interfaces → Enable 1-Wire
4. Reboot:
5. sudo reboot

3️⃣ Temperature Sensor Code ([Link])


This script reads DS18B20 and DHT22 sensors.

import os
import glob
import time
import Adafruit_DHT

# DS18B20 Sensor Setup


[Link]('modprobe w1-gpio')
[Link]('modprobe w1-therm')

# Locate DS18B20 Sensor


device_folder = [Link]('/sys/bus/w1/devices/28*')[0]
device_file = device_folder + '/w1_slave'

def read_ds18b20():
with open(device_file, 'r') as f:
lines = [Link]()
while lines[0].strip()[-3:] != 'YES':
[Link](0.2)
with open(device_file, 'r') as f:
lines = [Link]()
temp_str = lines[1].split("t=")[-1]
return round(float(temp_str) / 1000.0, 2)

# DHT22 Sensor Setup


DHT_SENSOR = Adafruit_DHT.DHT22
DHT_PIN = 4 # Change to your GPIO pin

def read_dht22():
humidity, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
return round(temperature, 2) if temperature else None

4️⃣ Fan Control Code ([Link])


This script controls a fan using PWM (Pulse Width Modulation).

import [Link] as GPIO


import time
import temperature

FAN_PIN = 17 # Change this to your fan GPIO pin


TEMP_THRESHOLD = 30 # Adjust the temperature trigger point

[Link]([Link])
[Link](FAN_PIN, [Link])
fan = [Link](FAN_PIN, 100) # 100Hz PWM frequency

def control_fan():
while True:
temp = temperature.read_ds18b20()
if temp > TEMP_THRESHOLD:
[Link](100) # Full speed
else:
[Link]()
[Link](5)

try:
control_fan()
except KeyboardInterrupt:
[Link]()
[Link]()

5️⃣ Flask Web Dashboard ([Link])


This provides a web interface to view real-time temperature updates.

from flask import Flask, render_template, jsonify


import temperature
import time

app = Flask(__name__)

@[Link]('/')
def index():
return render_template('[Link]')

@[Link]('/temperature')
def get_temperature():
temp_ds18b20 = temperature.read_ds18b20()
temp_dht22 = temperature.read_dht22()
return jsonify({'ds18b20': temp_ds18b20, 'dht22': temp_dht22})

if __name__ == '__main__':
[Link](host='[Link]', port=5000, debug=False, threaded=True)

6️⃣ Web Interface (templates/[Link])


This shows live temperature updates in a browser.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Temperature Monitor</title>
<script>
async function updateTemperature() {
const response = await fetch('/temperature');
const data = await [Link]();
[Link]('ds18b20').innerText = data.ds18b20 + "
°C";
[Link]('dht22').innerText = data.dht22 + " °C";
}
setInterval(updateTemperature, 2000);
</script>
</head>
<body>
<h1>Temperature Monitoring</h1>
<p>DS18B20 Sensor: <span id="ds18b20">Loading...</span></p>
<p>DHT22 Sensor: <span id="dht22">Loading...</span></p>
</body>
</html>

7️⃣ MQTT Cloud Integration (mqtt_publish.py)


This sends temperature data to an MQTT broker for remote monitoring.

import [Link] as mqtt


import temperature
import time
BROKER = "[Link]" # Use your MQTT broker
TOPIC = "temperature/data"

client = [Link]()
[Link](BROKER, 1883, 60)

while True:
temp = temperature.read_ds18b20()
[Link](TOPIC, f"Temperature: {temp}°C")
[Link](10)

8️⃣ Running the Program


Run these commands on your Raspberry Pi 5:

Start the Web Server


python3 [Link]

Now, visit [Link] in your browser.

Start Fan Control


python3 [Link]

Start MQTT Publisher (If using cloud monitoring)


python3 mqtt_publish.py

🔥 Features & Benefits


✅ Multiple sensor support (DS18B20 & DHT22)
✅ Real-time web dashboard for temperature monitoring
✅ Wi-Fi remote access for easy control
✅ Fan control via GPIO (PWM)
✅ Cloud MQTT integration for remote logging

⚡️Next Steps

1️⃣ Auto-start scripts on boot


2️⃣ Add mobile notifications (Telegram or Email)
3️⃣ Data logging with SQLite
4️⃣ Touchscreen support (for Raspberry Pi display)

Would you like any of these added? 🚀

Complete List of Components for Fireboard 2-Style Raspberry Pi 5 Build

Here's everything you'll need for temperature monitoring, fan control, and a web dashboard
running on a Raspberry Pi 5.
🔌 1️⃣ Raspberry Pi & Accessories
✔ Raspberry Pi 5 (4GB or 8GB) – Main processing unit
✔ 32GB microSD Card (Class 10) – Storage for OS and data
✔ Official Raspberry Pi 5 Power Supply (5V 5A USB-C) – Stable power
✔ Heat Sink & Cooling Fan – Keeps Pi 5 cool
✔ HDMI to micro-HDMI Cable – For display (if needed)
✔ USB Keyboard & Mouse – For initial setup

2️⃣ Temperature Sensors


✔ DS18B20 Waterproof Digital Temperature Sensor (1-Wire)
✔ DHT22 (AM2302) Humidity & Temperature Sensor – Additional sensor
✔ 4.7kΩ Resistor (for DS18B20 pull-up)

⚡ 3️⃣Fan & Power Components


✔ 12V or 24V DC Fan (for airflow control)
✔ N-Channel MOSFET (IRLZ34N or IRF520) – For switching fan
✔ Diode (1N4007) – Protection against voltage spikes
✔ Resistors (10kΩ, 1kΩ) – For MOSFET gate control
✔ 12V or 24V Power Supply (if using high-power fan)

📡 4️⃣ Connectivity & Remote Monitoring


✔ Wi-Fi or Ethernet Connection – For web access
✔ MQTT Broker (e.g., Mosquitto or Cloud MQTT) – For remote monitoring

5️⃣ Display & Interface (Optional)


✔ 3.5-inch or 7-inch Raspberry Pi Touchscreen – For local display
✔ On-screen UI (via Flask/WebSockets)
🔗 6️⃣ Cables & Connectors
✔ Breadboard & Jumper Wires – For prototyping
✔ Aviation Connectors (5-pin, 16mm) – For sensor connections
✔ Screw Terminal Blocks – For secure wiring

🔧 7️⃣ Software & Libraries


✔ Raspberry Pi OS (64-bit recommended)
✔ Python 3 & PIP (Pre-installed on Pi OS)
✔ Flask – For web interface
✔ Flask-SocketIO – For real-time updates
✔ Paho MQTT – For cloud connectivity
✔ Adafruit_DHT – For DHT22 sensor readings
✔ Matplotlib – For graphing (optional)

🔹 Estimated Cost Breakdown

Component Estimated Cost (USD)


Raspberry Pi 5 (4GB) $60-$80
MicroSD Card (32GB) $10-$15
Power Supply (5V 5A) $10-$15
DS18B20 Sensor $5-$10
DHT22 Sensor $5-$10
MOSFET + Resistors $5
12V Fan $10-$20
Touchscreen (Optional) $40-$80
Cables, Connectors $10-$20

🔥 Next Steps

 Do you need a wiring diagram?


 Do you want to log data to a database?
 Would you like alerts via SMS or email?

Let me know, and I'll help refine the setup! 🚀

You might also like