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.
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.
There’s a patch if you want to use WebIOPi with a Raspberry Pi B+, 2 or 3.
Nano can be used to edit the WebIOPi config file. Under Scripts the myscript location must be specified. Under HTTP specify the doc-root and welcome-file. Under Devices uncomment DS18B20.
Use sudo to run the WebIOPi program and tack C to specify the config file location.
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.
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.
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.
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.
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.
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.