Skip to content
dev-pmallappPublic

About

SMART UPS Monitor

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

UPS Monitor Project

A PlatformIO-based embedded project for monitoring UPS (Uninterruptible Power Supply) status using ESP32 in a DevContainer environment.

Project Structure

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

Features

  • 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

Getting Started

Prerequisites

  • Docker Desktop installed and running
  • Visual Studio Code with the Dev Containers extension

Setup Instructions

  1. Clone and Open Project:

    git clone <your-repo-url>
    cd UPS-Monitor
    code .
  2. Open in DevContainer:

    • Press Ctrl+Shift+P (or Cmd+Shift+P on Mac)
    • Type "Dev Containers: Reopen in Container"
    • Wait for the container to build (first time takes a few minutes)
  3. Build the Project:

    • Press Ctrl+Shift+P and run "Tasks: Run Task"
    • Select "PlatformIO: Build"
    • Or use the terminal: pio run
  4. Upload to Board:

    • Connect your ESP32 board
    • Run: pio run --target upload
    • Or use PlatformIO IDE interface

Hardware Configuration

Default Pin Configuration

  • 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)

Wiring Diagram

ESP32           UPS Interface
GPIO 2    -->   Status LED
GPIO 4    -->   UPS Status Signal
A0        -->   Voltage Divider (Battery Voltage)
GND       -->   Common Ground
3.3V      -->   Logic Power

Development

Available Tasks

  • Build: Ctrl+Shift+P → "Tasks: Run Task" → "PlatformIO: Build"
  • Upload: Use PlatformIO IDE upload button or pio run -t upload
  • Monitor: pio device monitor for serial output
  • Clean: pio run -t clean

Key Files

  • src/main.cpp: Main application logic
  • include/ups_monitor.h: Project header definitions
  • platformio.ini: Board and library configuration
  • .devcontainer/: Development environment setup

Adding Libraries

Edit platformio.ini and add dependencies under lib_deps:

lib_deps = 
    ArduinoJson@^6.21.2
    WiFi@^1.0.0

Monitoring Features

The 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

Customization

Changing Target Board

Edit platformio.ini to change the target:

[env:your_board]
platform = espressif32
board = your_board_name
framework = arduino

Adding WiFi/Network Features

  1. Add WiFi library to lib_deps
  2. Implement network monitoring in main.cpp
  3. Add configuration for WiFi credentials

Troubleshooting

Container Issues

  • Ensure Docker Desktop is running
  • Try rebuilding container: "Dev Containers: Rebuild Container"

Upload Issues

  • Check USB cable connection
  • Verify correct port in PlatformIO settings
  • Try different baud rates in platformio.ini

Build Errors

  • Check library dependencies in platformio.ini
  • Verify board configuration matches your hardware
  • Clear build cache: pio run -t clean

Contributing

  1. Make changes in your feature branch
  2. Test in the DevContainer environment
  3. Ensure code builds without errors
  4. Submit pull request with clear description

License

This project is open source. Add your license information here.

Hardware Requirements

  • 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

About

SMART UPS Monitor

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages