Skip to content

0xJonaseb11/paho.sensor.mqtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instructions for setting up and running the project.

# Sensor Monitoring and LED Control System

## Requirements
- Arduino UNO
- Analog sensor (e.g., potentiometer) connected to A0
- LED connected to pin 13
- PC with Python 3.7+, Arduino IDE, and a modern web browser
- VPS broker at 157.173.101.159 (MQTT:1883, WebSocket:9001)

## Setup
1. **Arduino**:
   - Connect the sensor to A0 and LED (with resistor) to pin 13.
   - Open `arduino/sensor_led.ino` in Arduino IDE.
   - Upload the sketch to the Arduino UNO.

2. **Python Scripts**:
   - Install required libraries: `pip install pyserial paho-mqtt`
   - Update `SERIAL_PORT` in `mqtt_publisher.py` and `mqtt_subscriber.py` to match your Arduino's port (e.g., `COM3` or `/dev/ttyUSB0`).
   - Run both scripts in separate terminals:
     ```bash
     python mqtt_publisher.py
     python mqtt_subscriber.py
     ```

3. **Web Interface**:
   - Open `web/index.html` in a web browser (e.g., Chrome).
   - The interface will display real-time sensor data and allow LED control.

## Project Structure
- `arduino/`: Contains the Arduino sketch (`sensor_led.ino`).
- `python/`: Contains Python scripts for MQTT communication.
- `web/`: Contains the browser interface files (`index.html`, `script.js`, `style.css`).

## Notes
- Ensure the VPS broker is running and accessible.
- The WebSocket server is assumed to handle JSON messages with `{type: 'subscribe/publish', topic: string, payload: string}` format.
- If WebSocket fails, check the server address and browser console for errors.
- Both Python scripts must be running simultaneously for full functionality.

## Troubleshooting
- Verify Arduino is connected and the correct port.
- Check MQTT broker and WebSocket server availability.
- Ensure no firewall blocks ports 1883 or 9001.
- Confirm Python libraries are running correctly.

About

A Sensor build with paho library to detect changes

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published