CSC 591/791, ECE 592 — Homework 2 (Fall 2025)
This repository contains a complete reference implementation for the MQTT-based multi-device system described in the assignment. It includes:
- Broker setup for Laptop #1 (Mosquitto via Docker Compose)
- Raspberry Pi A sensor publisher (LDR + potentiometer via ADC0831)
- Raspberry Pi C decision node (compares light vs threshold, publishes
LightStatus) - Raspberry Pi B LED controller (drives LED1/LED2/LED3 based on topics)
- Laptop #2 logger (subscribes to all topics, logs with duplicate reasoning and LED1 on/off timestamps)
All publications/subscriptions use QoS 2 and required retained messages.
Project layout
broker/— Mosquitto configuration and Docker Compose for Laptop #1raspberry_pi_a/— Sensor publisher for Pi Araspberry_pi_b/— LED controller for Pi Braspberry_pi_c/— Decision node for Pi Claptop2_logger/— Subscriber/logger for Laptop #2 or smartphonesubmission/— Templates and placeholders for your report/wiring diagrams
Quick start
- Start broker on Laptop #1
- Install Docker Desktop
- In
broker/, run:docker compose up -d
- Prepare Raspberry Pis (A, B, C)
- Raspberry Pi OS Bookworm or later, Python 3.10+
- Pi A deps:
sudo apt update && sudo apt install -y python3-pip python3-rpi.gpio
- Install Python deps per component
- On each device component directory, run:
pip3 install -r requirements.txt
- Run components (replace
<BROKER_HOST>with Laptop #1 IP)
- Pi A:
python3 publisher.py --broker <BROKER_HOST> --adc0831-clk 11 --adc0831-dout 9 --ldr-cs 8 --pot-cs 7 - Pi C:
python3 decision_node.py --broker <BROKER_HOST> - Pi B:
sudo python3 led_controller.py --broker <BROKER_HOST> - Laptop #2 logger:
python3 logger.py --broker <BROKER_HOST>
- Graceful shutdown
- Press Ctrl+C in each process; Pi A and Pi C will publish retained
offlinebefore disconnect.
Notes
- Topics used:
lightSensor(retained, QoS 2)threshold(retained, QoS 2)LightStatus(retained, QoS 2)Status/RaspberryPiA(retained, QoS 2)Status/RaspberryPiC(retained, QoS 2)
- Default GPIO mapping on Pi B:
- LED1: GPIO17, LED2: GPIO27, LED3: GPIO22
- ADC0831 wiring on Pi A (BCM): CLK=11, DOUT=9, LDR CS=8, POT CS=7