Advanced ESP32 firmware designed to transform the Oukitel P800E Power Station into a smart, network-connected device. This project provides remote monitoring, web-based control, home automation integration (Home Assistant, MQTT), and advanced UPS functionalities for safe shutdown of connected devices.
- Key Features
- Hardware Requirements
- Wiring Guide
- Software Installation
- Initial Configuration
- Web Interface Guide
- Calibration Guide
- Integration Examples
- API Documentation
- Advanced Features
- Troubleshooting
- Contributing
- License
- 📊 Real-time Monitoring: Live dashboard showing voltage, current (In/Out), power consumption, battery state of charge (SoC), and runtime estimates
- 🌐 Responsive Web Dashboard: Modern, mobile-friendly web interface accessible from any device
- 🔌 Remote Control: Turn USB, DC, AC outputs, and flashlight on/off via WiFi
- ⚡ Energy Management: Track daily/monthly consumption with 12-month history
- 🔋 Battery Management: Advanced battery monitoring with low/critical voltage warnings and automatic shutdown
- 🏠 Home Assistant Integration: Native integration with automatic MQTT discovery for seamless setup
- 📡 MQTT Support: Full MQTT client support for integration with any home automation system
- 🔔 HTTP Notifications: Configurable HTTP shutdown notifications for custom integrations
- 🖥️ NUT Protocol (Network UPS Tools): Emulates a standard UPS server compatible with:
- Synology NAS (DSM)
- QNAP NAS
- Linux/Unix systems with NUT client
- Windows with NUT client
- 🛡️ Safe Shutdown: Automatic shutdown of connected devices at critical battery thresholds
- 📊 UPS Status Reporting: Real-time battery status, voltage, and load information
- 🌅 Auto Power On: Automatically power on AC Output when the powerstation is on
- 📝 Data Logging: Persistent logging of sensor data and events
- 🔧 Advanced Calibration: Fine-tune sensor readings for maximum accuracy
- 📊 Log Levels: Configurable logging system (DEBUG, INFO, WARNING, ERROR, NONE)
| Component | Specification | Quantity | Notes |
|---|---|---|---|
| Microcontroller | ESP32 DevKit V1 (or compatible) | 1 | ESP32-WROOM-32D recommended |
| Current Sensors | SCT013-100A (split-core current transformer) | 2 | One for input, one for output |
| Burden Resistors | 22Ω (or 33Ω) | 2 | One per SCT013 sensor |
| Pull-up Resistors | 100kΩ | 2 | One per SCT013 sensor (to 3.3V) |
| Bias Resistors | 100kΩ | 2 | One per SCT013 sensor (between nodes) |
| Filter Capacitors | 10µF (electrolytic or ceramic) | 2 | One per SCT013 sensor |
| Voltage Divider | Custom resistive divider or 0-25V module | 1 | For battery voltage (0-30V range) |
| Voltage Divider Resistors | 220kΩ, 27kΩ (1% tolerance) | 2 | For battery voltage divider |
| Optocouplers | PC817 or similar (4-pin) | 5 | For button control isolation |
| Optocoupler Resistors | 220Ω | 5 | One per optocoupler LED |
| Power Supply | Step-down converter 24V→5V | 1 | To power ESP32 from battery |
| Power Station | Oukitel P800E | 1 | Target device |
- Enclosure: Weatherproof box for outdoor installations
- Fuses: Protection fuses for power lines
- Terminal Blocks: For secure wire connections
- Heat Shrink Tubing: For wire protection
- Soldering iron and solder
- Multimeter
- Wire strippers
- Screwdrivers
- Breadboard
- Remove the pads on the bottom of the power station.
- Remove the screws as shown in the image below.
- Slide off the top cover.
The ESP32 interfaces with the Oukitel P800E through:
- Current Sensors (SCT013): Clamp around power cables to measure current
- Voltage Divider: Connected to battery terminals to measure voltage
- Optocouplers: Isolated connections to physical buttons for remote control
| ESP32 Pin | Component | Function | Notes |
|---|---|---|---|
| GPIO 18 | Optocoupler → Power Button | Unit power ON/OFF | Long press (3s) simulation |
| GPIO 16 | Optocoupler → USB Button | USB output control | Toggle on/off |
| GPIO 17 | Optocoupler → DC Button | 12V DC output control | Toggle on/off |
| GPIO 19 | Optocoupler → Flashlight Button | Torch control | Toggle on/off |
| GPIO 21 | Optocoupler → AC Button | AC Inverter control | Toggle on/off |
| GPIO 34 | SCT013 (Input) | Input current measurement | ADC1_CH6 (input only) |
| GPIO 35 | SCT013 (Output) | Output current measurement | ADC1_CH7 (input only) |
| GPIO 36 | Voltage Divider | Battery voltage reading | ADC1_CH0 (input only) |
| 5V | Step-down converter output | ESP32 power supply | 3A minimum |
| GND | Common ground | Ground reference | Connect all grounds |
The SCT013 sensors require a conditioning circuit to convert the current transformer output to a voltage readable by the ESP32 ADC.
Circuit Components (per sensor):
- SCT013 current transformer (split-core)
- Burden resistor: 22Ω (or similar, typically 22-33Ω)
- Pull-up resistor: 100kΩ (to 3.3V)
- Bias resistor: 100kΩ (between nodes)
- Filter capacitor: 10µF (electrolytic or ceramic)
- Connection to ESP32 GPIO (GPIO34 for Input, GPIO35 for Output)
Physical Connections:
-
SCT013 Wires: The two wires from the SCT013 clamp come to your breadboard/protoboard
-
Burden Resistor (22Ω):
- Connect one end to one SCT013 wire
- Connect the other end to the second SCT013 wire
- The burden resistor is in parallel with the SCT013 output
-
Define Nodes:
- Node A: Junction where burden resistor, first SCT wire, and other components connect
- Node B: Other side of burden resistor, second SCT wire, connected to GND
-
From Node A:
- Wire to ESP32 GPIO34 (Input sensor) or GPIO35 (Output sensor) - this is the signal
- 100kΩ resistor to ESP32 3.3V (pull-up)
- Positive terminal (anode) of 10µF capacitor
- 100kΩ resistor to Node B (bias resistor)
-
Node B:
- Direct connection to ESP32 GND
- Negative terminal (cathode) of 10µF capacitor
Complete Circuit Diagram:
SCT013 Clamp
│
├── Wire 1 ──┬── Node A ──[100kΩ]── 3.3V (ESP32)
│ │ │
│ [22Ω] [100kΩ]
│ Burden │
│ │ │
│ └── Node B ────┴── GND (ESP32)
│ │ │
└── Wire 2 ──┘ │
[10µF]
Capacitor
│
Node A ────────────────────→ GPIO34/GPIO35 (Signal)
Node B ────────────────────→ GND
Input Sensor (AC Input):
- Clamp the SCT013 around the input power cable
- Connect Node A to GPIO 34
- Connect Node B to GND
Output Sensor:
- Clamp the SCT013 around the output power cable (to connected devices)
- Connect Node A to GPIO 35
- Connect Node B to GND
Important Notes:
- The burden resistor (22Ω) converts the current transformer output to a voltage
- The 100kΩ pull-up to 3.3V provides DC bias for the AC signal
- The 100kΩ bias resistor between nodes creates a voltage divider
- The 10µF capacitor filters noise and stabilizes the signal
- Both sensors use identical circuits, only the GPIO connection differs
The battery voltage (24-29V) must be reduced to ESP32-safe levels (0-3.3V).
Component Values:
- R1 = 220kΩ (upper resistor)
- R2 = 27kΩ (lower resistor)
- Divider ratio ≈ 9.15:1
Wiring:
Battery+ ──[220kΩ]──┬──[27kΩ]── Battery-
│
└──→ GPIO36 (ESP32)
└──→ GND (ESP32)
Calculation:
- Battery voltage range: 20-29V
- Divided voltage: 20/9.15 ≈ 2.18V to 29/9.15 ≈ 3.17V
- Safe for ESP32 ADC (0-3.3V range)
Each button requires an optocoupler for electrical isolation.
Optocoupler Wiring (PC817 example):
ESP32 GPIO ──[220Ω]── LED+ ── LED- ── GND
│
│ (isolated)
│
Button Circuit ──────────── Transistor ── Button Signal
Complete Optocoupler Circuit:
For each button (5 total):
ESP32 GPIO → 220Ω resistor → Optocoupler LED+ → Optocoupler LED- → GND
│
│ (isolation barrier)
│
Button Signal → Optocoupler Transistor Collector → Optocoupler Transistor Emitter → GND
Button Mapping:
- GPIO 18 → Power Button (3-second press simulation)
- GPIO 16 → USB Button
- GPIO 17 → DC Button
- GPIO 19 → Flashlight Button
- GPIO 21 → AC Button
The ESP32 requires 5V power. Use a step-down converter from the 24V battery.
Wiring:
Battery+ (24V) ──→ Step-down Input+
Battery- (GND) ──→ Step-down Input-
│
│
Step-down Output+ ──→ ESP32 5V
Step-down Output- ──→ ESP32 GND
Important: Ensure the step-down converter can supply at least 3A for stable operation.
- Disconnect Power: Always disconnect the power station before wiring
- Fuse Protection: Add fuses to power lines for protection
- Isolation: Use optocouplers to isolate ESP32 from power station circuits
- Voltage Limits: Never exceed ESP32's 3.3V input limits
- Polarity: Double-check all connections before powering on
- Testing: Test each component individually before final assembly
┌───────────────────────────────────────────┐
│ Oukitel P800E │
│ │
│ Battery ──[Voltage Divider]──→ GPIO36 │
│ Input ────[SCT013]───────────→ GPIO34 │
│ Output ───[SCT013]───────────→ GPIO35 │
│ Buttons ──[Optocouplers]─────→ GPIO16-21 │
└───────────────────────────────────────────┘
│
│
┌──────────┴───────────┐
│ ESP32 DevKit │
│ Powered by 5V PSU │
└──────────────────────┘
-
Download Arduino IDE: Get the latest version from arduino.cc
- Minimum version: 1.8.19 or 2.x
- Recommended: Arduino IDE 2.x for better performance
-
Install ESP32 Board Support:
- Open Arduino IDE
- Go to File → Preferences
- Add to Additional Board Manager URLs:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json - Go to Tools → Board → Boards Manager
- Search for "ESP32" and install "esp32 by Espressif Systems"
- Select version 3.3.0 or later
-
Select Board:
- Go to Tools → Board → ESP32 Arduino
- Select "DOIT ESP32 DEVKIT V1" (or your specific ESP32 board)
Install the following libraries via Tools → Manage Libraries:
| Library | Author | Version | Purpose |
|---|---|---|---|
| ArduinoJson | bblanchon | 7.4.2+ | JSON parsing for API |
| PubSubClient | knolleary | 2.8+ | MQTT client |
| EmonLib | openenergymonitor | 1.1.0+ | SCT013 current sensor |
| WebSockets | Markus Sattler | 2.7.1+ | WebSocket server |
Built-in ESP32 Libraries (automatically available):
WiFiWebServerSPIFFSHTTPClientAsyncUDP(for NTP)
-
Clone Repository:
git clone https://github.com/yourusername/oukitel-p800e-smart-controller.git cd oukitel-p800e-smart-controller -
Open Project:
- Open
oukitel-p800.inoin Arduino IDE - All other files will be automatically loaded
- Open
-
Verify Installation:
- Click Verify (✓) to check for compilation errors
- Fix any missing library errors
Before first compilation, review config.h for default settings:
// Web Interface
#define WEB_USERNAME "admin"
#define WEB_PASSWORD "P800e"
// API Password
#define API_PASSWORD_DEFAULT "oukitel2025"
// WiFi Access Point (if no WiFi connection)
#define AP_SSID "Oukitel-P800A"
#define AP_PASSWORD "" // Open network
// Development WiFi (remove in production!)
#define DEFAULT_WIFI_SSID "Set-your-SSID"
#define DEFAULT_WIFI_PASSWORD "Set-your-Password"- Default Mains Voltage:
MAINS_VOLTAGE 230.0(adjust for your region) - NTP Server:
NTP_SERVER_DEFAULT "pool.ntp.org"
-
Connect ESP32:
- Connect ESP32 to PC via USB cable
- Select correct COM port in Tools → Port
-
Upload Settings:
- Upload Speed: 115200 (default)
- CPU Frequency: 240MHz (default)
- Flash Frequency: 80MHz
- Flash Size: 4MB (3MB APP/1MB SPIFFS)
- Partition Scheme: Default 4MB with spiffs
-
Upload Firmware:
- Click Upload (→) button
- Wait for compilation and upload to complete
- Monitor Serial Monitor (115200 baud) for initialization messages
-
First Boot:
- Open Serial Monitor (Ctrl+Shift+M)
- You should see initialization messages
- Note the IP address if WiFi connects, or connect to AP
Oukitel-P800A
- Power On: Connect ESP32 to power (via step-down converter from battery)
- Serial Monitor: Open at 115200 baud to see boot messages
- WiFi Connection:
- If default WiFi credentials are configured, it will connect automatically
- If not, an Access Point
Oukitel-P800Awill be created - Connect to this AP and navigate to
192.168.4.1
-
Find Device IP:
- Check Serial Monitor for:
"IP Address: x.x.x.x" - Or connect to AP and check router DHCP table
- Check Serial Monitor for:
-
Open Web Interface:
- Navigate to
http://x.x.x.xin your browser - Login with default credentials:
admin/P800e
- Navigate to
-
Change Passwords (First Priority):
- Go to Settings → System
- Change web password and API password immediately
- Go to Settings → WiFi
- Enter your WiFi SSID and password
- Click Save
- Device will restart and connect to your network
- If WiFi connection fails, device creates AP
Oukitel-P800A - Connect to this network (no password)
- Navigate to
192.168.4.1 - Configure WiFi credentials
- Device will restart and attempt connection
For initial testing, default calibration values should work. For accurate readings, see Calibration Guide.
The main dashboard provides real-time monitoring of all system parameters.
- Power State: ON/OFF indicator
- Battery State: Charging / Discharging / Rest / Bypass
- Connection Status: WiFi and MQTT connection indicators
- Voltage: Real-time battery voltage (V)
- Percentage (SoC): State of Charge percentage
- Remaining Capacity: Estimated remaining energy (Ah)
- Status Indicators: Low battery warning, critical battery alert
- Input Power: Power from AC adapter (W)
- Output Power: Power consumed by connected devices (W)
- Net Power: Difference (Input - Output) indicating charge/discharge rate
- Current Readings: Input and output current (A)
- Daily Consumption: Energy used today (kWh)
- Monthly Consumption: Energy used this month (kWh)
- 12-Month History: Historical monthly consumption graph
- Visual representation of power flow
- Battery voltage over time
- Energy consumption trends
Remote control of all power station functions.
- POWER Button: Long press (3 seconds) to toggle unit power on/off
⚠️ Warning: This will turn off the entire power station
- USB Output: Toggle USB ports on/off
- DC Output: Toggle 12V DC output on/off
- Flashlight: Toggle built-in flashlight on/off
- AC Output: Toggle AC inverter on/off
- Enable/Disable: Toggle automatic power-on feature
- Function: When enabled, unit automatically powers on when charging voltage is detected
- Use Case: Ideal for power loss restart
- Current Status: Display current WiFi connection or AP mode
- SSID: Enter WiFi network name
- Password: Enter WiFi password
- Scan Networks: Button to scan and select available networks
- Save: Apply new WiFi credentials (device will restart)
For generic MQTT integration (Home Assistant, Node-RED, etc.)
- Enable MQTT: Toggle MQTT client on/off
- Broker: MQTT broker IP address or hostname
- Port: MQTT port (default: 1883)
- Username/Password: MQTT authentication credentials
- Client ID: Unique MQTT client identifier (auto-generated from MAC address)
- Base Topic: MQTT topic prefix (default:
oukitel_p800e_<MAC>)
MQTT Topics (auto-discovered by Home Assistant):
oukitel_p800e_<MAC>/sensor/battery_voltageoukitel_p800e_<MAC>/sensor/battery_percentageoukitel_p800e_<MAC>/sensor/power_inoukitel_p800e_<MAC>/sensor/power_outoukitel_p800e_<MAC>/switch/usb_outputoukitel_p800e_<MAC>/switch/dc_outputoukitel_p800e_<MAC>/switch/ac_outputoukitel_p800e_<MAC>/switch/flashlight
Direct HTTP integration with Home Assistant.
- Enable Integration: Toggle Home Assistant integration
- Server: Home Assistant server IP or hostname
- Port: HTTP port (default: 8123)
- Long-Lived Access Token: HA API token (generate in HA → Profile → Long-Lived Access Tokens)
- Auto-Discovery: Automatically creates sensors and switches in Home Assistant
Configure Network UPS Tools server for NAS integration.
- Enable UPS Server: Toggle NUT server on/off
- Port: NUT server port (default: 3493)
- Shutdown Threshold: Battery percentage at which shutdown command is sent (default: 20%)
Compatible Devices:
- Synology NAS (all models)
- QNAP NAS (all models)
- Linux/Unix systems with NUT client
- Windows with NUT client
- NTP Server: Network Time Protocol server for time synchronization (default:
pool.ntp.org) - GMT Offset: Timezone offset in seconds (default: 3600 for GMT+1)
- Daylight Saving: Daylight saving offset in seconds (default: 3600)
- Beep Alerts: Enable/disable beep sounds for alerts
- Log Level: Set logging verbosity (DEBUG, INFO, WARNING, ERROR, NONE)
Configure HTTP notifications for custom shutdown scripts.
- Enable HTTP Shutdown: Toggle HTTP shutdown notifications
- Server: Target server IP or hostname
- Port: HTTP port (default: 8080)
- Password: Authentication password
- Threshold: Battery percentage threshold for shutdown notification
Critical for accurate sensor readings. See Calibration Guide for detailed instructions.
- SCT013 Input Calibration: Calibration factor for input current sensor
- SCT013 Input Offset: Offset correction for input sensor (zero current adjustment)
- SCT013 Output Calibration: Calibration factor for output current sensor
- SCT013 Output Offset: Offset correction for output sensor
- Battery Divider Ratio: Voltage divider ratio (default: 8.925)
- ADC Calibration: ADC calibration factor (default: 1.0125)
- Voltage Offsets: State-specific voltage offsets (Charge, Discharge, Rest, Bypass)
- Mains Voltage: AC mains voltage for power calculations (default: 230V)
- Adjust for your region (110V, 120V, 220V, 230V, 240V)
For expert users and fine-tuning.
- Power Threshold: Minimum power (W) to detect charge/discharge states
- Power Filter Alpha: Smoothing factor for power readings (0.0-1.0)
- Minimum Safe Voltage: Battery voltage threshold for safety shutdown
- Battery Low Warning: SoC percentage for low battery warning
- Battery Critical: SoC percentage for critical battery alert
- Auto Power On Delay: Delay before auto power-on activates (ms)
- Warmup Delay: Sensor warmup time before readings are valid (ms)
- Max Power Reading: Maximum valid power reading (W) - readings above this are discarded
- This feature automatically activates the AC output every time the P800 is turned on. If the PowerStation runs out of power, the AC output will be disconnected. When the P800 restarts, the AC output will be active again.
Configuration:
- Enable in Control Panel → Auto Power On
- Adjust delay in Advanced Settings → Auto Power On Delay (default: 10 seconds)
System logs sensor data and events to SPIFFS for analysis.
Log Files:
/logs/daily_YYYYMMDD.csv- Daily sensor logs/logs/events.log- System events
Access: Via web interface or SPIFFS file system
Configurable logging system for debugging and production.
Levels:
- DEBUG: All messages (development)
- INFO: Normal operations (default)
- WARNING: Warnings and errors only
- ERROR: Errors only
- NONE: No logging
Configuration: Settings → System → Log Level
12-month energy consumption history with automatic rollover.
Features:
- Daily consumption tracking
- Monthly consumption tracking
- Automatic day/month rollover
- Historical data persistence
- Filtered invalid data (1970 dates, etc.)
Advanced algorithm detects battery state:
- Charging: Input power > Output power + threshold
- Discharging: Output power > Input power + threshold
- Bypass: Input ≈ Output (power passing through)
- Rest: No significant power flow
Smoothing algorithm reduces noise in power readings.
Configuration: Advanced Settings → Power Filter Alpha
- Lower values (0.1): More smoothing, slower response
- Higher values (0.5): Less smoothing, faster response
- Default: 0.2 (balanced)
Contributions are welcome! Please follow these guidelines:
- Fork the Repository: Create your own fork
- Create Feature Branch:
git checkout -b feature/amazing-feature - Follow Code Style: Match existing code formatting
- Test Thoroughly: Test your changes before submitting
- Submit Pull Request: Describe your changes clearly
- Clone repository
- Install all required libraries
- Configure
config.hfor development - Test on hardware before submitting
When reporting issues, please include:
- Firmware version
- Hardware setup
- Steps to reproduce
- Serial monitor output (if applicable)
- Expected vs actual behavior
This project is licensed under the GNU General Public License v3.0 (GPL-3.0) - see the LICENSE file for details.
This means:
- ✅ You are free to use, modify, and distribute this software
- ✅ You must share your modifications under the same license (copyleft)
- ✅ You must include the original license and copyright notice
- ✅ Commercial use is allowed, but modifications must be shared
For more information, visit GNU GPL v3
This is a hobby project. The author is not responsible for:
- Hardware damage caused by misuse or incorrect wiring
- Data loss from device failures
- Incorrect readings leading to battery damage
- Any consequences of using this firmware
Handle batteries and mains power with expertise and caution.
- Always follow safety guidelines
- Use appropriate fuses and protection
- Test thoroughly before deployment
- Understand the risks involved
- EmonLib: For SCT013 current sensor library
- ArduinoJson: For JSON parsing
- ESP32 Community: For excellent documentation and support
- Home Assistant: For inspiration and integration examples
For questions, issues, or contributions:
- GitHub Issues: Create an issue




