A PlatformIO-based embedded project for monitoring UPS (Uninterruptible Power Supply) status using ESP32 in a DevContainer environment.
UPS-Monitor/
├── .devcontainer/ # DevContainer configuration
│ ├── devcontainer.json # VS Code DevContainer settings
│ └── Dockerfile # Container image definition
├── .github/ # GitHub configuration
│ └── copilot-instructions.md
├── .vscode/ # VS Code workspace settings
│ └── tasks.json # Build and upload tasks
├── include/ # Header files
├── lib/ # Private libraries
├── src/ # Source code
│ └── main.cpp # Main application
├── test/ # Unit tests
├── platformio.ini # PlatformIO project configuration
└── README.md # This file
- DevContainer Support: Complete development environment in Docker
- ESP32 Platform: Configured for ESP32 development board
- UPS Monitoring: Basic framework for monitoring UPS status
- Status LED: Visual indication of UPS status
- Serial Monitoring: Debug output via serial console
- Docker Desktop installed and running
- Visual Studio Code with the Dev Containers extension
-
Clone and Open Project:
git clone <your-repo-url> cd UPS-Monitor code .
-
Open in DevContainer:
- Press
Ctrl+Shift+P(orCmd+Shift+Pon Mac) - Type "Dev Containers: Reopen in Container"
- Wait for the container to build (first time takes a few minutes)
- Press
-
Build the Project:
- Press
Ctrl+Shift+Pand run "Tasks: Run Task" - Select "PlatformIO: Build"
- Or use the terminal:
pio run
- Press
-
Upload to Board:
- Connect your ESP32 board
- Run:
pio run --target upload - Or use PlatformIO IDE interface
- LED Pin: GPIO 2 (built-in LED on most ESP32 boards)
- UPS Voltage Monitor: A0 (analog input for voltage sensing)
- UPS Status Pin: GPIO 4 (digital input for power status)
ESP32 UPS Interface
GPIO 2 --> Status LED
GPIO 4 --> UPS Status Signal
A0 --> Voltage Divider (Battery Voltage)
GND --> Common Ground
3.3V --> Logic Power
- Build:
Ctrl+Shift+P→ "Tasks: Run Task" → "PlatformIO: Build" - Upload: Use PlatformIO IDE upload button or
pio run -t upload - Monitor:
pio device monitorfor serial output - Clean:
pio run -t clean
src/main.cpp: Main application logicinclude/ups_monitor.h: Project header definitionsplatformio.ini: Board and library configuration.devcontainer/: Development environment setup
Edit platformio.ini and add dependencies under lib_deps:
lib_deps =
ArduinoJson@^6.21.2
WiFi@^1.0.0The current implementation provides:
- Periodic UPS Status Checks: Every 5 seconds
- Visual Status Indication: LED blinks based on UPS status
- Slow blink (1 second): UPS online/normal
- Fast blink (200ms): UPS offline/on battery
- Serial Logging: Status messages via USB serial
Edit platformio.ini to change the target:
[env:your_board]
platform = espressif32
board = your_board_name
framework = arduino- Add WiFi library to
lib_deps - Implement network monitoring in
main.cpp - Add configuration for WiFi credentials
- Ensure Docker Desktop is running
- Try rebuilding container: "Dev Containers: Rebuild Container"
- Check USB cable connection
- Verify correct port in PlatformIO settings
- Try different baud rates in
platformio.ini
- Check library dependencies in
platformio.ini - Verify board configuration matches your hardware
- Clear build cache:
pio run -t clean
- Make changes in your feature branch
- Test in the DevContainer environment
- Ensure code builds without errors
- Submit pull request with clear description
This project is open source. Add your license information here.
- ESP32 Development Board
- UPS with status output (optional)
- Voltage divider circuit for battery monitoring (optional)
- USB cable for programming and power
- Breadboard and jumper wires for prototyping