Saturday, June 8, 2013

SmartThings to ThingSpeak Python Script

So, I have been meaning to do this for a really long time. In fact, I purchased all the XBee radios, temperature sensors, and various breakout boards to be able to do this project and have yet to get around to it!
To make things a little easier, back in August, I backed a project on Kickstarter that would give me a base for measuring temperature throughout the house. It was the SmartThings project.
It's a great home automation setup and although I'm basically using only motion sensors and temperatures sensors for most things, it still got the basic network set up in the house. Their app for iOS works really well and I'm beta testing their Android app, which works well for a beta.
The only gripe is that I can't really see the history of the data, just the real-time information, which is good at a glance, but I want to be able to log and see what's going on. Their developer website allows me to see that information but it's just a bunch of numbers. Not only that, I have to log in each time, go to each device, and then do a few more clicks to see what I want.
I finally decided I had had enough and jumped in and learned how to write a script in Python that would allow me to grab that information. Not only could I grab it, I could also post it to a website that will track it all for me at ThingSpeak!
I'm not sure the best way to post the file so I made my first git repository! It's probably way overkill but I didn't want to put something in my DropBox, make it public, and then post it up.
Here's the link.
I also made a video showing a little bit of the information. The YouTube video is here.

Enjoy and let me know what you think for those 1 or 2 people that may actually read this!

Tuesday, August 14, 2012

My Own Thermal Camera

Okay, here's a fun project I just finished up. I still have a little bit of testing and minor calibration to do but it's an extremely fun project.
I always wondered what it would be like to have my own Flir IR imaging camera to see where we have hot/cold leaks around the doors and also to see what the heat signature of things look like.
Here's an example I took from Flir's website showing weather stripping issues around a door.

See how awesome that is? The problem is, the cheapest camera, even at closeout, is $1100. That's a lot of money. Maybe if I sold the imaging services to friends, it would eventually pay for itself but then who wants to charge their friends money for helping them out?
Anyway, I was poking around the internet when I saw an article about a DIY project that could do something similar for much less. They pointed me to this website where a few teenagers took a nice sensor and created a thermal camera on the cheap. I was determined to make my own! One problem though, I didn't have time or the money to put down $60 on a sensor so it sat on the backburner for a year or so.
As some of you may know, we bought a house recently and we really like it. However, for whatever reason, our basement is like an oven. It's unfinished and should be in the 65-70 F range for temperature (according to our plumber who just unclogged our stubborn bathroom drain that I tried hard to clear myself). Anyway, last summer and this summer, the basement has been a balmy 75-78 F and because of it, it's hard to keep the rest of the house cool, especially with no central air. We can have fans blowing the cool air from the one a/c unit we have downstairs but even if we can get it to 75 F, the basement is warmer so it's a battle that has frustrated me. Is it the dryer? Dehumidifier? Maybe it's the gas furnace that heats our water? Thinking it might be the furnace, I put insulation around all the hot water pipes, the water tank, and everything I could. However, it's still a balmy 77 as I write this AND IT'S ONLY 74 OUTSIDE!!! ARE YOU KIDDING ME???
Okay, so you can see it's quite frustrating as I can't figure out what's causing our hot basement issue.

Seeing that I was really frustrated, I remembered that I had wanted to make this cheap thermal camera. Over the last year, I had amassed enough parts that all I had to do was buy the sensor so I bit the bullet and finally bought one.
You'll remember in my Tonka Summit post that I used something called ServoBlocks for the pan on my camera. Well, my project was chosen as one of the monthly winners so I won two more sets! As they are incredible to work with to make simple pan/tilt setups, I decided to use what I won for this project! Except for one problem, I only had one servo that would fit so I had to improvise a little.

I present to you my own thermal camera!
Front view
Side view
Back view
Kind of a rats nest but not that bad

I wanted to keep it small and portable so I could easily transport it with a laptop to take images. Seeing I had several SparkFun boxes, I found one that would fit just right. I took the bulky casing off the webcam and hot glued it into the hole I made for it on the side of the box. I made openings just big enough for the USB connector on the Arduino UNO and for the webcam cable as well as the servo and sensor cables. Oh, I guess I did cut out a hole for the pan servo too. It looks kind of crazy but it works! The documentation from Max's website were great and really helped get everything together.
For those interested in making one, just know you'll need to be able to solder and do a little programming. I had to change some of the servo parameters to make sure it panned from left to right and would tilt from bottom to top. Once I got that working, then it was a matter of making sure all the connections showed up properly in the computer. I still struggle with that part as sometimes it recognizes the camera or Arduino but for whatever reason, it doesn't sometimes.

So, does it work? Well, I'm not exactly sure how accurate it is but it seems to be pretty good. I only have one image from it so far and it's of the wall and front door. Here's the image.
What I'm not quite sure of yet are if the corners of the thermal image correspond to the corners of the webcam image. I have an old laser pointer from a college project that I'll soon mount onto it to see where it's pointing while it scans and I can report back then. As for accuracy of the data points, I don't know yet. You can see where the sun shines through the door is the warmest. The wall at the lower left is cool because the fan is blowing cool air from the a/c in another room into the living room. While the general values look good, I don't know if it's really accurate. My plan is to remove the servo cables, have it point in one spot for the "scan" and put an ice pack in front of it to see if it registers around 32 F. The sensor is supposed to be accurate to about 1 F or so so I would assume it's close but being the engineer that I am, I want to know better and thats probably the best way I can check.
If you want 64x48 resolution as shown above, it takes about 8 minutes for it to scan and make the image. For a 32x24 image, it takes about 2 minutes. Apparently, there's another project in the works by Max that will take the 64x48 images in about 3 seconds and display it on a portable LCD screen so as soon as that is out, I'll look into making that to have an even better camera for analyzing things.
Stay tuned for some interesting shots. Kind of like my "Will it dry" posts on our family blog, I'll be doing some interesting pictures.
Now, to find that heating gremlin in the basement...

UPDATE 8/27/12
So I finally figured out the problem with the sensor. Apparently, you don't want to change the filter settings using the EEPROM code given at Leave those stock and only change the max/min temperature settings and you should be good to go. It sounds like Melexis changed something in their sensor processor and that fixed it.
Here are a couple of pictures for you that I have taken.
The dryer while it was on

The furnace, which I think is the culprit

Saturday, August 11, 2012

My Review of The Manga Guide to Linear Algebra

Moved to here

Tuesday, July 24, 2012

My Review of Safe C++

Moved to here

Saturday, June 23, 2012

My Review of Make: School's Out Summer Fun Guide

Moved to here

Thursday, June 14, 2012

My Review of Make: Technology on Your Time Volume 30

Moved to here

My Review of Android Cookbook

Moved to here