Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can retrofit a UPS with an ESP8266 and PCF8591 to report mains presence and battery voltage over Wi-Fi, then use home-automation software to shut down a server when backup power is running low. The project is a monitor and automation add-on—not a change to the UPS’s core backup function—and its sample voltage conversion and shutdown threshold need to be verified for your specific hardware.

What the retrofit does

MyHomeThings’ January 2021 project addresses a UPS whose network interface no longer reported status to the ioBroker server it powered. An ESP8266-01 and PCF8591 ADC monitor two conditions: battery voltage and whether mains power is present. The ESP8266 sends those values over Wi-Fi using MQTT; an ioBroker JavaScript script can then act on them.

The design has two distinct sensing paths. A resistor divider scales battery voltage for the PCF8591’s analog input. A mains-derived 5 V signal and optocoupler provide a mains-presence indication while separating that signal path from the ESP8266 side. The project names a HI-Link HLK-PM01 as an example 230 V-to-5 V supply and PC817 or TPL621 as optocoupler examples; those example parts do not certify the assembled circuit or make it safe by themselves. See the original project and its wiring and code.

Parts and software in the example build

The project’s parts list is specific to its implementation, not a universal bill of materials for UPS retrofits.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Hosyond 3Pcs ESP8266 ESP-12E CP2102 NodeMCU Lua Wireless Module Development Board for Arduino IDE/Micropython
  • Not only it is easy to program for this controller by using the CP2102-USB interface,but also unnecessary to press the flash and reset buttons before each flash operation.
  • NodeMcu is an open source Lua based firmware for the ESP8266, ultra low cost wireless modules, development boards for rapid prototyping, integrated with ESP8266 chips.
  • The ESP8266 has powerful on-board processing and storage capabilities, and can be integrated with sensors and other application-specific devices through its GPIOs.
  • It is compatible with Arduino IDE,works great with the latest Mongoose IoT/Micropython.
  • Modern Internet development tools can use the built-in API to instantly put your idea on the fast track.
  • One old UPS, one ESP8266 ESP-01, and one PCF8591 ADC converter.
  • Three 4.7 kΩ resistors, one 15 kΩ resistor, one 1 kΩ resistor, and one 470 Ω resistor.
  • One HI-Link HLK-PM01 supply module, one LM2596S DC-DC module, and one TPL621 optocoupler. The instructions also name the PC817 as an optocoupler example.
  • Arduino IDE for programming; Wi-Fi, Wire/I2C, and PubSubClient/MQTT are used in the firmware. The automation example uses ioBroker.

Before adapting the circuit, check the exact ESP-01 board, ADC breakout, supply, logic levels, and connections against their documentation and your UPS. The project does not establish compatibility across UPS models or ADC breakouts.

How the monitoring firmware works

In the sample sketch, ESP8266 GPIO0 and GPIO2 serve as I2C SDA and SCL for the PCF8591, addressed at 0x48. The code converts the ADC reading with ain0 * (13.73 / 255) and publishes the resulting battery-voltage value and mains state to the MQTT topics UPS/battery_voltage and UPS/Network_voltage.

Rank #2
AEDIKO 5pcs ESP8266 Breakout Board GPIO 1 into 2 for ESP8266 ESP-12E NodeMCU Development Board Compatible with ESP8266 ESP-12E
  • ESP8266 Breakout Board GPIO 1 into 2 Terminal Screw Board is Fully Compatible with ESP8266 ESP-12E
  • GPIO 1 into 2: ESP8266 Breakout Board Can Expand 1 GPIO Pin to 2, Which is Convenient for Users to Reuse Pins for Large-Scale Smart Home Projects
  • Double-Layer PCB: ESP8266 Breakout Board is a Double-Layer Board. One Pin is Wired On Both Sides. Therefore, the Circuit is Stable and Highly Reliable
  • 2 Type Connections:ESP8266 Breakout Board Designed with Two Connection Methods: Pin Header Connector & Screw Terminal. Just Select Connection According to Your Need
  • Convenient to USE: Compared with the Previous Version, Updated Version ESP8266 Breakout Board Has Been Soldered Completely. No Need to Solder Parts,Very Convenient to Use

The sample reports every five seconds while its state indicates mains loss and every thirty seconds when mains is present. These are intervals configured in that project’s code, not required or recommended polling rates for every installation. Likewise, the 13.73 / 255 scaling factor is an implementation parameter: the project supplies no calibration dataset or measured error. Verify the voltage reading against an appropriate meter over the range you expect to use before relying on it for automation.

How the example shuts down a server

Shutdown is handled by a separate ioBroker JavaScript script, not by the ESP8266 itself. The example watches the battery-voltage object and, when the mains-state object is the string false and battery voltage is below 11.0, runs sudo shutdown -h now and disables the script.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
HiLetgo 3pcs ESP8266 NodeMCU CP2102 ESP-12E Development Board Open Source Serial Module Works Great for Arduino IDE/Micropython (Large)
  • Built-in Micro-USB, with flash and reset switches, easy to program
  • Arduino compatible, works great with the latest Arduino IDE/Mongoose IoT/Micropython
  • Data download access to the website: http://www;nodemcu;com

The 11.0 V threshold is the author’s example setting, not a general UPS cutoff. The project does not characterize battery discharge or establish that this value gives every server enough time to shut down. Select and validate a threshold for the particular UPS battery, measurement circuit, and shutdown duration. Also ensure that the account running the script can execute the shutdown command as configured; a command that fails silently defeats the purpose of the automation.

Optional restart with Wake-on-LAN

The tutorial describes a separate Wake-on-LAN sketch for restarting a server after power returns. It joins Wi-Fi, waits 300,000 milliseconds (five minutes), sends a magic packet to the configured server MAC address, then enters deep sleep. This is a separate workflow from the UPS monitoring sketch, not an automatic consequence of reporting that mains power has returned.

Rank #4
HiLetgo 3pcs NodeMCU GPIO Board ESP8266 NodeMCU Pin Out IO Out 1 into 2 for ESP8266 ESP-12E NodeMCU Development Board
  • NodeMCU GPIO expansion board
  • NodeMCU can be connected through by Pin Header & Screw Terminal
  • GPIO 1 INTO 2

The project says the server must connect over Ethernet and support Wake-on-LAN. The server’s firmware, network adapter, and settings must also be configured to accept wake packets; otherwise the packet will not start it. The five-minute wait is the example’s chosen delay, not evidence that every UPS or server will be ready then.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Safety and important limitations

This build involves opening and modifying equipment connected to mains voltage and places a mains-derived supply inside the UPS. The project itself warns of fatal electric-shock and fire hazards and instructs builders to turn off and unplug the UPS and disconnect its battery before disassembly. Those steps do not remove every hazard or establish that the work is safe for an unqualified person. Do not proceed unless you are qualified to work on mains-voltage equipment and can design and verify the enclosure, wiring, isolation, and strain relief appropriately; an optocoupler alone is not a safety guarantee.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
HiLetgo 3pcs ESP8266 NodeMCU Lua ESP-12E CP2102 USB C Type-C Interface IOT Internet of Things Wireless WiFi Development Board Module
  • ESP8266 NodeMCU Lua ESP-12E CP2102 Development Board Module with USB C Type-C Interface, has a wider range of applications.
  • Adopting the original brand new CP2102 chip with powerful functions, developing a complete set of tools for ESP8266.
  • Built in Tensilica L106 ultra low power 32-bit micro MCU, with main frequency support of 80 MHz and 160 MHz
  • Supports RTOS.
  • Support many kinds of working modes like STAAP/STA+AP etc, support AT remote upgrade and cloud OTA , and upgrade for Smart Config function etc.

The 2021 project is a single DIY implementation, not an independently validated engineering study. It presents no bench-test results, voltage-error measurements, safety certification, battery-discharge characterization, or compatibility testing across UPS models. Treat its component choices, ADC scaling, reporting intervals, shutdown condition, and Wake-on-LAN timing as example implementation details that require hardware-specific verification. For broader context, the publisher’s English project index describes the original use case: a UPS with a faulty network interface that did not shut down its attached computer during a prolonged outage.

Quick Recap

Bestseller No. 1
Hosyond 3Pcs ESP8266 ESP-12E CP2102 NodeMCU Lua Wireless Module Development Board for Arduino IDE/Micropython
Hosyond 3Pcs ESP8266 ESP-12E CP2102 NodeMCU Lua Wireless Module Development Board for Arduino IDE/Micropython
It is compatible with Arduino IDE,works great with the latest Mongoose IoT/Micropython.
$13.99
Bestseller No. 3
HiLetgo 3pcs ESP8266 NodeMCU CP2102 ESP-12E Development Board Open Source Serial Module Works Great for Arduino IDE/Micropython (Large)
HiLetgo 3pcs ESP8266 NodeMCU CP2102 ESP-12E Development Board Open Source Serial Module Works Great for Arduino IDE/Micropython (Large)
Built-in Micro-USB, with flash and reset switches, easy to program; Arduino compatible, works great with the latest Arduino IDE/Mongoose IoT/Micropython
$16.39
Bestseller No. 4
HiLetgo 3pcs NodeMCU GPIO Board ESP8266 NodeMCU Pin Out IO Out 1 into 2 for ESP8266 ESP-12E NodeMCU Development Board
HiLetgo 3pcs NodeMCU GPIO Board ESP8266 NodeMCU Pin Out IO Out 1 into 2 for ESP8266 ESP-12E NodeMCU Development Board
NodeMCU GPIO expansion board; NodeMCU can be connected through by Pin Header & Screw Terminal
$9.49

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.