Power & Temperature Monitoring System

Power and Temperature monitoring system header

I developed a power and temperature monitoring system for work a few months ago. It’s based around a Raspberry Pi, some other components and a program I wrote in Python. This was a lot of fun for me, as it gave me a chance to combine my “day job” skills as an IT administrator and programmer with my interest in hobby electronics. The resulting system turned out really well and has worked great so far. In this article I’ll cover what the system does, the parts that went into building it, and of course the source code and related information will be provided for those wishing to build upon what I did.


When there is an extended power outage where I work, several people need to be notified via email or text. But we don’t want to get a notification every time there’s a quick “blip” in the grid that causes the power to drop for just a few seconds. This was a problem with the previous solution we used, and the result was that the notifications were often ignored, especially in the summer when brownouts frequently occur. The system I created addresses this by including a delay before sending notifications.

Another problem we’ve had at work is the air conditioning system for the server room failing and nobody knowing about it. So I decided to add temperature monitoring to this system as well.

System Features

Top view from back with case open

Power Monitoring

Power is monitored by a Python program (powmon.py) via a GPIO pin on the Raspberry Pi, which is connected to the 5VDC Power Supply’s output via a voltage divider. Any time the power goes out or comes back on, the event is logged by the program. If the power remains out for 10 minutes, then an email is sent by the program. This delay ensures that emails are sent only when there is an extended outage. Once power has been restored for at least 15 minutes, another email is sent indicating power is back on. The reason for this delay is to provide time for the email server and network equipment to come back online so the email can be sent successfully.

Sample of notifications sent

Temperature Monitoring

Temperature is monitored by the same Python program via a Maxim DS18B20 temperature sensor. The program has two defined temperature thresholds: TARGET_TEMP, which is the maximum preferred temperature, and WARNING_TEMP, which is the maximum temperature that is considered “acceptable”. For our purposes, these values are set to 87 and 92 degrees Fahrenheit respectively. The program checks the temperature every minute, and if it exceeds WARNING_TEMP, an email is sent. Once the temperature drops below TARGET_TEMP, another email is sent letting users know it’s back under control.

There are no time delays for the temperature notification emails. Instead, the TARGET_TEMP and WARNING_TEMP values are set far enough apart to ensure warnings are not triggered too easily or quickly.

User Interface

Front of system with LEDs

The front of the system has three LEDs. A color-changing LED (which is purple in the above photo) indicates if the 5VDC power supply is on, which lets the user know that the system is receiving power. Two additional LEDs, one green and one red indicate the current power status as seen by the Python program. Green indicates that mains power is present, and red that it’s off.

Web interface

In addition to the LEDs, a web interface is provided which runs in a separate python program (powweb.py). It displays the status of the power monitoring service, memory usage and the ambient temperature as seen by the DS18B20 sensor. In addition, it also displays the most recent entries from the power monitoring program’s log file. The web interface was developed using flask and waitress.

Other Noteworthy Features

For either power or temperature notifications, if the system cannot successfully send an email it will continue to retry until it succeeds. The failures are recorded in the log for troubleshooting purposes.
The power and temperature state, as well as if any notifications have been sent is stored in a settings file so it can be reloaded after the system comes back online after an extended power outage. This is done so the Python program knows if the power was actually out, to prevent a normal reboot of the system from triggering an email to be sent. If the file is corrupt or missing the program will automatically rebuild it.

The Hardware

system layout

Raspberry Pi

My first thought was to go with an Arduino, since that’s what I was familiar with. But after quickly realizing the limitations of email on the Arduino, I moved to the Raspberry Pi. This ultimately made things much easier, and allowed me to quickly add a web interface to the project later on. I used a 1st generation Raspberry Pi Model B, because I already had a couple of them and this project doesn’t need the additional power of the newer models.

Raspberry Pi in case

The Pi is installed in a plastic case which attached to the project case by Velcro. Two posts behind the Pi prevent it from moving when a USB or network cable is plugged in. I admit it’s a hack, but it works and it made mounting the Pi with the ports accessible fairly easy.

Power Supply

Adafruit PowerBoost 1000C

Power to the RasPi is provided by an Adafruit PowerBoost 1000C connected to a 6,600mAh Li-ion battery. This combination acts as an Uninterruptible Power Supply. The battery size is overkill, and can run the system for several hours. A 2,200mAh battery would have been more than enough but I didn’t know what to expect when I was building the system so I went with the biggest battery available. Power to the PowerBoost is provided by a Mean Well RS-15-5 power supply, which provides 5v up to 3amps, easily meeting the 2 amp requirement of the PowerBoost.


Dell switch case

Finding a sturdy but affordable “general-purpose” rack mount case proved difficult. I decided to repurpose the case from an old Dell 10/100 network switch instead, which was inspired by this project by Scott Wegner. It would have been nice if I’d been able to utilize the Dell’s original power supply too, but unfortunately it wasn’t 5VDC so I couldn’t.

Modified Dell switch case

To prepare the case, I removed the label from the front and cut and ground some of the stand-offs that supported the original circuit board. There are two large openings at the front of the case where the network ports were previously located. One is filled by the Raspberry Pi computer, and the other I filled in with a ventilated plastic cover taken from an old Dell server.

Schematic and Other Components


I used a Maxim DS18B20 temperature sensor, which provides digital output via the OneWire interface. This is a popular temperature sensor for the Raspberry Pi since the Pi can’t directly interface with analog sensors such as the TMP36. The first batch of DS18B20 sensors I purchased were counterfeit, which I previously wrote about on my site.

The 2.2KΩ and 3.3KΩ resistors form a voltage divider that brings the 5VDC output of the power supply down to a 3.3VDC level so it can be fed into one of the Pi’s GPIO pins for monitoring purposes.

PCB Board

I mounted the various resistors and wires on an Adafruit Perma-Proto PCB Board since it provides an easy connection to the Pi.


I wrote two python programs that run the system: powmon.py, which is the actual power monitoring program, and powweb.py which provides the web interface. All development and testing was done with CPython 3.4.2. This was my first time writing software in Python, and it probably shows. But it’s a pretty good first effort IMHO, And yes, I did read PEP8 (well, a summary of it anyways.)

I utilized several Python packages. powmon.py utilizes rpi.gpio and retrying, and powweb.py utilizes flask, waitress and psutil.

The operating system is Raspian Jesse Lite, since this system doesn’t need a GUI.


This ZIP archive contains the python programs and related files, as well as the schematic and some very basic setup instructions.

Back of case

Potential Improvements

Like all my projects, there’s always a few things I wish I’d done different or hope to improve upon in the future.

Final Thoughts

Do not unplug warning sign

This was a lot of work, but I’m very happy with how it turned out. I especially had a blast learning Python! It was the most fun I’ve had with programming in many years. I look forward to utilizing it more in the future.

And best of all, the system works! It’s already alerted us to one air conditioning system failure, which allowed us to respond much quicker than we would have in the past. If you find this project useful or adapt it for your own use in someway, let me know! I’d love to see it.

Back to Electronics Projects | Back to Main Menu

Originally posted August 4, 2017 on my old site; posted here April 17, 2018.