Computer Room Environmental Monitor w/SMTP email - Photon


Just finished the initial build and software for an environmental monitoring system for a computer room. It will use a DHT-22 for temperature and humidity, a Panasonic PIR for motion detection and a water leak detection circuit. The Photon inits everything including code which keeps the clock aligned with DST and the proper timezone. The temp/humidity, water status and motion status is also displayed locally on a 20x4 blue LCD screen.

A high and low temperature threshold is configured and if either of these conditions are met, a front-mounted LED (tri-color) turns red (normal state is green). The LED shows blue during the init phase. Emails are sent using native SMTP (no third-party providers needed) via smtp2go. Emails are currently sent every 15 minutes for the following conditions, as long as they exist:

  1. High temperature
  2. Low temperature
  3. Water leak
  4. Motion detection

The Panasonic PIR gives us about 15-18’ of coverage. The water leak detection circuit is connected via a 15’ cable with a plastic box that sits on the concrete floor below the raised flooring for the computer room.

All of the output if uploaded to Freeboard which has indicators for temperature, humidity, the last boot time, the last system reset reason (SRR), and indicator lights for high/low temp, water leak and motion. Another indicator light turns on if the unit doesn’t check in at least every 30 seconds, which is 4-5 times the normal processing loop time.

A second unit will be built with two water detection cables so two different rooms can be monitor. I originally wrote code to allow the high and low temperature thresholds to be set via CURL using functions but since I can access the device through the cloud I can always update through the IDE.

I had originally included a piezo buzzer but since these systems are not in populated rooms there wasn’t anyone to hear it.



I would switch that DHT-22 sensor to something more accurate and reliable like the SHT-31.


Thanks RWB.

Thanks for the suggestion. For this usage I’m comfortable with the results. We used a temperature calibration tool and found that by subtracting 1.3F we stayed within a tenth of a degree over multiple days. For a simple environmental tool in a computer room I’m OK with the resolution.

I have always been a big fan of Adafruit and their breakout board looks top quality.


Added a function so you temporarily disable the motion detection function in the event you’re working around the unit. You can either send the enable/disable via a DOS batch file using CURL or via POSTMAN.


After spending dozens of hours writing and re-writing the native SMTP code, including coding individual retries and time-outs for each part of the SMTP transaction, I switched over to a webhook using MailGun. I pass in the body and I can send emails and text messages.

I also added a Particle function to enable/disable DST. Until I get some code that I’m 100% comfortable with, I can simply use Postman and switch between the two time settings without having to recompile the code.

Thinking of adding a reset function in the event something weird happens and the only option is either a soft or hard reset. I would always try the soft reset first since the device is going to be at the client’s location and nobody wants to drive in the middle of the night if they don’t have to. Of course, being a security guy, I figured I might as well “two-factor authentication” to the reset function. Through Postman, I would call a resetInit() function which would generate a random token similar to the access token. The function would then send me a text message with the code. I would then call the real resetSystem() function providing this token. At that point the unit would reset. I know, way overkill but really cool.