Back to Projects
Raspberry Pi IoT Notification System: Cross-Platform Hardware Integration
Low-resource IoT system with custom C++ TCP server, Python GPIO management, and Windows toast notification integration
Visuals pending coffee intake
Cross-Platform Hardware Notification Gateway
Raspberry Pi 1 IoT system with optimized Python GPIO control, custom C++ TCP server with Windows system tray integration, and PowerShell toast notification system.
Technical Architecture
Hardware Layer (Raspberry Pi)
- Raspberry Pi Model 1 with BCM GPIO pin mapping
- RGB LED with PWM control via GPIO 23 (Red), 24 (Green), 25 (Blue)
- Tactile button on GPIO 17 with pull-up resistor (GPIO.PUD_UP)
- Active-low LED configuration with voltage regulation
Software Stack
- Python 3 - RPi.GPIO library with state machine for LED control
- C++ Windows Server - Winsock2 API, Windows Shell API, hidden window message pump
- PowerShell - Windows Runtime toast notifications via Windows.UI.Notifications
- Custom TCP Protocol - Port 10709 with UTF-8 message encoding
Core Technical Implementation
Python GPIO Management (Raspberry Pi)
- RGB LED state machine with set_rgb(r, g, b) function using active-low logic
- Button debouncing algorithm with 200ms delay and edge detection
- Connection state management with color coding:
- Yellow (1,1,0) - Connection attempt in progress
- Green (0,1,0) - Connection established
- Red (1,0,0) - Connection error
- Blue (0,0,1) - Idle state blinking
- Heartbeat mechanism with null byte transmission every 3 seconds
C++ Windows Server Architecture
- Winsock2 TCP server with INADDR_ANY binding on port 10709
- Hidden window (WinAPI) for system tray integration with custom window class
- NOTIFYICONDATA structure for tray icon management with WM_APP_TRAYICON messages
- Multi-threaded design: main thread handles Windows message pump, worker thread handles TCP connections
- ShellExecuteW for launching PowerShell scripts with hidden window (SW_HIDE)
Communication Protocol
- TCP socket connection with 10-second connection timeout
- Message format: "DEFAULT MESSAGE" string trigger with UTF-8 encoding
- Heartbeat: Empty byte array transmission for connection validation
- Error handling: Exponential backoff with 3-second retry intervals
Windows Toast Notification System
- PowerShell script using Windows.UI.Notifications ToastTemplateType::ToastText02
- Custom XML template manipulation with text node injection
- Windows Runtime type loading via [Windows.UI.Notifications.ToastNotificationManager]
- Custom notifier registration: "Raspberry Pi Notifier"
Technical Specifications
Hardware: Raspberry Pi 1 Model B, RGB LED, GPIO 17 Button, Resistor Network
Software Versions:
- Python 3.7+ with RPi.GPIO library
- C++11 with Winsock2, Windows API, Shell API
- PowerShell 5.1+ with Windows Runtime support
- Windows 10/11 for toast notifications
Key Algorithms & Patterns:
- Button debouncing using time-based filtering (200ms delay)
- LED state machine with color blending and blink patterns
- TCP socket connection pooling with keep-alive heartbeat
- Windows message pump for system tray event handling
- PowerShell script parameter injection for dynamic notifications
Performance Optimizations:
- Minimal Python footprint with selective GPIO module usage
- C++ server with detached threads for non-blocking TCP operations
- PowerShell script pre-loading of Windows Runtime types
- Efficient memory management in resource-constrained Raspberry Pi 1 environment
Protocol Details: TCP Port 10709, UTF-8 Encoding, 1024-byte buffer
Status: Production • Home Automation System
Metrics: <100ms button-to-notification latency, 2W power consumption
Technologies
PythonC++Raspberry PiInternet of ThingsAutomationHardware IntegrationAPI DevelopmentEmbedded SystemsWindows API
Project Info
- TypePython
Interested in building something similar?
Get in Touch