A multi-platform IoT project that controls LEDs via Blynk mobile app and syncs data to Adafruit IO cloud dashboard.
This project consists of three Python scripts that work together:
- blynk_control_RPI.py - Controls physical LEDs on Raspberry Pi
- blynk_control_VH.py - Virtual hardware version for testing without Pi
- adafruit_monitor.py - Syncs LED states to Adafruit IO cloud
# Create virtual environment (if not already created)
python3 -m venv bonus.venv
# Activate it
source bonus.venv/bin/activatepip install -r requirements.txt# Copy the example config file
cp config.example.py config.py
# Edit config.py and add your credentials
nano config.pyYou'll need:
- Blynk credentials: Get from https://blynk.cloud/dashboard
- Adafruit IO credentials: Get from https://io.adafruit.com/
On Raspberry Pi (with physical LEDs):
# Terminal 1 - Run the Blynk controller
python blynk_control_RPI.py
# Terminal 2 - Run the Adafruit monitor
python adafruit_monitor.pyFor Testing (Virtual Hardware):
# Terminal 1 - Run the virtual hardware controller
python blynk_control_VH.py
# Terminal 2 - Run the Adafruit monitor
python adafruit_monitor.pyConnect 4 LEDs to your Raspberry Pi:
- LED 1 (Top): GPIO 17
- LED 2 (Right): GPIO 27
- LED 3 (Bottom): GPIO 22
- LED 4 (Left): GPIO 10
Don't forget current-limiting resistors! (220Ξ© - 330Ξ© recommended)
- Create a new project in Blynk app
- Add 4 switch widgets
- Assign them to Virtual Pins: V0, V1, V2, V3
- Copy your Auth Token to
config.py
- Create 4 feeds in Adafruit IO:
led-topled-rightled-bottomled-left
- Copy your Username and Key to
config.py
4ledsrpi/
βββ blynk_control_RPI.py # Raspberry Pi hardware controller
βββ blynk_control_VH.py # Virtual hardware controller
βββ adafruit_monitor.py # Adafruit IO sync service
βββ config.py # Your credentials (DO NOT COMMIT!)
βββ config.example.py # Template for credentials
βββ requirements.txt # Python dependencies
βββ .gitignore # Git ignore file
βββ led_state.json # Generated at runtime
βββ bonus.venv/ # Virtual environment
- NEVER commit
config.pyto GitHub (it's in.gitignore) - Use
config.example.pyas a template for others - Keep your API keys private!
"ModuleNotFoundError: No module named 'config'"
- Make sure you created
config.pyfromconfig.example.py
"RPi.GPIO not found" on laptop/desktop
- This is normal! Use
blynk_control_VH.pyinstead
Adafruit IO rate limit errors
- The code has built-in protection, but if you see errors, increase
MONITOR_INTERVALin config
LEDs not turning on
- Check GPIO pin numbers in
config.py - Verify wiring and resistors
- Test with a simple GPIO test script
Educational project for ECEN430 course.
Created by Marcelino Saad, NU - BS of Engineering