Pi Temperature Monitor

I’ve been having some issues with the AC in my server room. I figured this would be a good excuse to try out the Raspberry Pi. I’ve been working with AVR microcontrollers for a long time and they are very powerful and inexpensive. However, it has always been a pain to implement networking which is a breeze on the Pi. Using WebIOPi, I easily created a web-based temperature monitoring system with just a small amount of HTML and Python code.

 

In addition to a web interface, the project has a 16×2 LCD display with a negative RGB backlight. Using pulse width modulation (PWM) the text color of the LCD display will change to highlight temperature fluctuations. Green is good, red is too hot and blue is too cold.

LCD Displays

I couldn’t find the exact datasheet for this display. The closest one I found shows a minimum Vdd of 4.5V. However, I’m running the LCD display at 3.3V because I tested it and found no issues. The contrast is just right at this voltage, it is simpler to interface and there is no chance of accidently putting 5V into a GPIO pin which could damage the Pi. Still, other modules could have reliability issues at 3.3V. At 5V, make sure you use transistors to control the PWM and variable resistor to lower the contrast.

I’m using a DS18B20 one wire temperature sensor. WebIOPi has native support for this sensor so I only had to uncomment 1 line in the config file to get it up and running. The DS18B20 runs at 3-5.5V so it is easily powered from the Pi. Only 1 external 4.7k resistor is required between the data line and Vdd.

DS18B20

Blinky 7/26/2015 – The latest Pi update broke the WebIOPi 1-wire code. Here’s the fix:
Edit boot/config.txt:

sudo nano /boot/config.txt

Add the following to the end of the file:

# w1-gpio
dtoverlay=w1-gpio-pullup,gpiopin=4

Save the changes and reboot the pi.

 

I’m using the following GPIO pins on the Pi. Since I’m running the LCD display and the sensor at 3.3V there are no other components needed except for 1 resistor for the DS18B20.

Pinout Pinout

Here is my test breadboard with a Raspberry Pi connected to an RGB LCD Display and a DS18B20. The only software required to get this test up and running was WebIOPi by Trouch and lcd.py which came from Raspberry Pi Spy.

Test Breadboard

I mounted the Pi in an aluminum rack mount project case. The button on the front of the case resets the temperature high/low range. The front panel is removable which makes it much easier to cut and drill.

Rack Enclosure

I used my Romaxx HS1 to cut out the front panel for the 16×2 LCD Display. The V-carve and g-code is available below.

CNC Cutting Rack Panel LCD Display Cut-out

WebIOPi serves a web page and provides custom controls to interact with the GPIO pins and control custom python scripts. I created a simple page that displays the current temperature in my server room. I also added button to get the temperature and high/low range, a button to reset the high/low range and a button that lights up when the reset switch on the front of the case is pressed.

WebIOPi Webpage

I looked at several Python solutions for email notification, but all the ones I found involved storing clear text passwords in code which I think is a very bad practice with respect to security. Implementing a secure solution from scratch using salting and a modern hash algorithm seemed like too much trouble. Therefore I decided to leverage existing infrastructure on my network. I had initially omitted my solution because I didn’t think it would be applicable to most users, but I received several requests for my code so I decided to make a quick video outlining my approach. The video shows 2 methods. The first uses a Syslog server and is relatively easy. The second is more advanced. I created a WCF web service on an IIS SMTP server in my office. I then use a Python module called Suds which is a lightweight SOAP client for consuming web services. This allows my Pi to send email notifications if there is possible AC failure in my server room and it does not require any stored passwords on the server or client. The web service only allows emails to my domain and there is no need for SMTP relay because the service is hosted on the same server. The web service also stores my temperature logs to a SQL Server Express database and provides data for a bar chart on my WebIOPi webpage.


Downloads:

HTML and Python code v.1.01 – 09/24/2013 (UTF Encoding Fixed)
HTML and Python code v.1.10 – 04/19/2014 (Added logging, notification & bar chart)
VCarve Pro aluminum enclosure cut out file and G-code – 09/24/2013


Please note that in order to subsidize my site, I’m an Amazon affiliate. If you click the Amazon links below and buy the item, I will get a commission. I have personally bought all the linked items below for this project from Amazon. I also recommend you check out Adafruit, because some of the items might be cheaper. I have no affiliation with Adafruit. Another way to support my site is to subscribe to my YouTube channel.
Parts List:

DescriptionQty
Raspberry Pi Model B+ 512MB1
Transcend 4 GB Class 6 microSDHC Flash Memory Card1
Adafruit 501 Power Supply1
Monoprice 3ft 24AWG USB Micro Cable w/ Ferrite Filter1
LCD Module 16×2 RGB Negative Backlight1
Stainless Steel Momentary Pushbutton 16mm1
DS18B20 Waterproof Temperature Sensor1
Resistor Carbon Film 4.7K Ohm 1/4 Watt 5%1
BUD Industries CH-14400 Aluminum Rack Mount Chassis1