Since I was unable to find a complete post on this I decided to write one. I found a lot of good information from other blogs and websites but nothing exactly what I wanted to do. I’m going to put together what I hope will be a complete guide for home temperature monitoring, power loss, and reporting/graphing (though that last piece will come in a later post). You are welcome to use any part of this or use it all. All code is open source under WTFPL.
Basically what I wanted was the ability to monitor the temperature at multiple points in my house. I also wanted to monitor the power and alert on a power outage. Since the Arduino board is plugged into a UPS it will stay running for a while after the power goes out. Obviously without a UPS your Arduino would be unable to alert on a power outage.
First things first, here is a parts list that I used to make this happen:
– 1 Arduino Uno R3
– 1 Arduino Ethernet Shield R3
– 1 4.7k Ohm resistor
– As many DS18B20 temperature sensors as you want. I will use 4 for this project.
– An LM35 analog sensor from here (optional)
– Wire – I am using spools of 2-pair telco wiring that I’ve had in my basement forever.
– Breadboard for connecting sensors and power to the Arduino board.
– ~9V Power adapter for Arduino board (only if you don’t have USB power nearby)
– 5V SWITCH MODE power adapter for power loss monitoring (optional)
– LAMP web server stack. If you want to run this on Windows I suggest XAMPP.
(Depending on where you go for this and what you already have you should be able to get away for about $100 US)
Additionally here are the skills you need:
– Basic soldering
– Basic web programming/LAMP skills
– Wire pulling
Final notes before I get started with the actually how-to. I will do my best to give enough details on everything (without going overboard) for you to make this work. If you get stuck though please feel free to leave a comment or message me. I also give no guarantees on the code. If it works for you, wonderful. If it sets your computer on fire, I’m not responsible. Oh and if your system gets hacked from use of this code also not my responsibility. All code provided AS-IS. I am also going to attempt to link to all the places I found parts of this project but I greatly apologize if I don’t cite your source. There were a TON of different sources so there is a good chance I will miss someone.
Alright – let’s get this show on the road!
Wiring things up is quite straightforward. I will mention that I’m using an analog sensor on the breadboard just because I was able to get a free sample here. I would not recommend using these for your whole project as the voltage drop across the cable runs will cause problems. I just stuck one with the board because it was free so I figured why not.
Alright connecting the DS18B20 sensors is really easy. We will be using normal mode (instead of parasitic) as this provides more consistency and allows for longer cable runs.
(I didn’t make these, they came from here)
Additionally if you are connecting up an analog sensor as I did the wiring is a slight bit different:
Alright so things are wired up, now you need the addresses of the digital sensors. As I found this wonderful post on obtaining the addresses so I will not cover it in the post. Please see that post for information on getting the addresses of the sensors.
Here are the files you will need to get started: Zipped Files Obviously the .ino file needs to be uploaded to the Arduino board after inputting the correct server IP , host, mac, and sensor addresses. The .sql file needs imported into your database. The write.php needs edited with your DynamicDNS host if you are doing this from home. You can sign up for an account here. You just have to make sure one of the devices on your network is updating the IP address. Additionally if you are writing to a local web server you can remove this part as it’s merely for security to prevent anyone from writing to the database. After you have edited this file upload it and the lib directory to your web server.
At this point you should be good to go. You can watch the output from the Arduino board on your PC to make sure that things are doing what they are supposed to. Also the logs on your webserver can be useful if you encounter problems. Hopefully this post helps someone and please feel free to leave a comment with additions/questions/problems! Thanks for reading!