A Prometheus Exporter for 52pi UPS Boards

Home, Bangkok, Thailand, 2021-07-10 18:27 +0700

#observability #opensource #iot

 

I’m waiting for a final part (specifically 10 meters of four-core telephone cable) so that I can continue my weather station build, but one part that has finally arrived is the replacement UPS board. I got a 52pi EP-0118 EPS “UPS with RTC and Coulometer”.

The install was uneventful and went according to the documentation so there’s nothing much to add there.

Their docs provide a sample Python script for reading the energy values via the I2C bus and this was also easy to get going. After getting the sample running I decided to put together a Prometheus exporter based on the script_exporter by Rico Berger. This is fully working now:

curl http://localhost:9469/probe?script=piups

# HELP script_success Script exit status (0 = error, 1 = success).
# TYPE script_success gauge
script_success{script="piups"} 1
# HELP script_duration_seconds Script execution time, in seconds.
# TYPE script_duration_seconds gauge
script_duration_seconds{script="piups"} 0.280330
# HELP piups_bus_voltage_volts The voltage supplied to the connected device(s)
# TYPE piups_bus_voltage_volts gauge
piups_bus_voltage_volts 5.208
# HELP piups_bus_current_milliamps The current drawn by the connected device(s)
# TYPE piups_bus_current_milliamps gauge
piups_bus_current_milliamps 136.805
# HELP piups_power_milliwatts The power consumed by the connected devices in milli-watts
# TYPE piups_power_milliwatts gauge
piups_power_milliwatts 737.561
# HELP piups_shunt_voltage_millivolts TBD
# TYPE piups_shunt_voltage_millivolts gauge
piups_shunt_voltage_millivolts 7.080

In my weather station dashboard I’ve added a side-bar showing the energy consumption of the station as queried every 15 seconds from the UPS board:

I have packaged my solution as piups_exporter on GitHub and the README in that project elaborates on how to get it setup, which is very easy.

It was only after I got my UPS board that I realized there’s a newer model than the one that I ordered - the EP-0136 “UPS Plus” which provides a lot more metrics - so naturally I’ve ordered one of those and once I have it I will come back and update piups_exporter to also ship those metrics.