Tuesday, August 11, 2015

Cabin Fever - A Temperature Sensor and Alert for A Cabin Away From Home

Part 1 of a multiple part story...

I wanted to help out someone I know by making a temperature sensor that would alert them if they were away from their cabin and the temperature went below freezing (which could cause the pipes to freeze). I through it would be fun to use the term "Cabin Fever" as the name of this project.

I started with an Arduino Uno Microcontroller. Arduino is open source hardware, so I have a clone.

There are three components to this project:
1. Temperature - we want to measure temperature
2. Email for notifications - we want to send a notification when the temperature is below a certain point (and, if possible, receive email so we can get commands to send a report or change the setpoint temperature)
3. Time - we want to record the time of when we get the temperature (we want to have an option of sending a report of past hourly temperatures with their corresponding time)

And, maybe (if possible) we might add a 4th component:  Sensing a power outage because this unit won't be too helpful if the power goes out too!

Parts to Buy:
  • Arduino Uno
  • Ethernet Shield (this allows the Uno to be connected to the internet to send and receive emails)
  • DS18B20 Temperature sensor
  • Power supply
  • Case to hold it all in
  • a few extra parts:  4.7K Ohm Resistor, Connecting wires

Here's how I tackled the project:
1. Temperature
I found a "sketch" (program) for the Arduino uno for the DS18B20 temperature sensor.  To connect the hardware, I looked at the diagram there. I found another article that helped me understand the pinout a bit better. I connected up the hardware and had it printing out the temperature through the serial monitor. You can see the three wires and resistor I connected in the photo above.

This worked really well and I had temperature readings working within and hour of starting!

Since the sensor reports in Centigrade, I did add some code to convert it to Fahrenheit.

  Serial.print(" Degrees C, ");
  temperature = (temperature * 9.0) /5.0 +32.0;
  Serial.println(" Degrees F");
 delay(1000); //just here to slow down the output so it is easier to read

Originally, I was getting the wrong conversion to Fahrenheit, so I found this article that taught me to use 9.0, 5.0, and 32.0 which fixed the conversion error.

Here's the output I'm getting:
24.69 Degrees C, 76.44 Degrees F
Our thermometer here says it's 75 degrees, so that's pretty close.

So, now I'm getting the temp readings.

My next task is to get the function working to send emails. That will be in my next post.

No comments: