Using Arduino, Raspberry Pi and Android to monitor your home

Chris Brooker
July 4, 2013

Hey all,

Just thought I’d write an update to my post “Internet connected computer controlling a dumb fan. Inefficiencies of the modern gas forced-air furnace“. It’s been a while and I’ve been busy. In that post I made the comment “Ideally, there would be a wireless temp sensor in each room, and an independent, discrete, heat source in every room that could adjust to the constant needs of the household.”.

With that in mind I started down a long road of discovery, building and hacking that lead me to where we are now, this screen shot:

Screenshot_2013-07-03-22-31-10

What you’re looking at is a shot of the home screen of my Android phone (Galaxy S4). I’d like to direct your attention to the small white text beside the weather widget. This is a little widget I wrote myself last night that displays the temperature from the 6 wireless temperature sensors I build and have around the house.

What I’ve built and put together is a network of internet connected wireless sensors. Let me go through each piece.

1) Wireless Sensor:

Here is what I’ve come up with so far for the final sensor.

_DSC0497 _DSC0499 _DSC0501

I owe pretty much everything to Nathan Chantrell who created what is called the TinyTX. An open source set of PCB diagrams, Arduino code and tons of know-how. You can find all the information about the TinyTX on his post here.

The sensor is pretty simple, it’s:

  • a custom PCB I had created in china (with the plans from Nathan Chantrell) (built by seeedstudio.com)
  • an ATtiny84 MCU
  • the RFM12B wireless transceiver
  • the DS18B20 temperature sensor
  • a resistor and a battery pack

The best thing about this V3 board design is that it exposes all of the ATtiny84’s IO pins. In this configuration only 2 are being used but it makes it so easy to use the platform to attach pretty much any sensing probe. Temp, humidity, air quality, pretty much anything.

So far I’ve only seen people using this platform to send sensor data back to a base station. I’ve been doing some playing around and have found ways to also have this receive a signal. For instance you could have this setup to read and transmit the temp but also have it connected via the free pins to wirelessly turn on and off an exhaust fan or operate lights. You just need to build a switching circuit that’s triggered by 3.3v. I breadboarded a test of this and had a transistor switching a set of 12v PC fans.

The base code for the ATtiny84 can be found on github.

 

2) The Base Station (Receiving the sensor data)

_DSC0503 _DSC0507

The next piece in the puzzle is a way to receive the sensor data, as there is insufficient power and resources for each sensor to be connected to the internet directly.

The base station consists of:

The hardware is pretty straight forward. I ordered the RFM12Pi module as a kit and got it up and running pretty quickly. Installed Linux and the RFM12Pi modules.

 

3) The software

emoncmsMulti emoncmsFeed emoncmsDash

There is a fantastic open source project OpenEnergyMonitor.org that built a system called emoncms. It’s an MVC patterned PHP, MySQL system to log and visualize all the data that comes in through the sensors. As it’s open source, it’s extremely hacker friendly with all its code and modules on Git. I have this running on the Raspberry Pi.

emoncms is extremely flexible and a great way to capture and log all sorts of sensor data. It shows you the raw inputs from the sensors that you then map to a Feed. Allowing you to do any adjustments to the raw data as needed before being logged. In the case of temperature, I’m sending the float temp data as Int through the wireless transceiver, I then multiply the input by 0.01 to arrive back a the original float then log it to a feed.

You can also build dashboard as I did with the screen shot above. It’s very flexible and has been working very well, I did however, start playing with using it to send data back to the sensors. Nothing final yet, but when I have it working I’ll post some code to a forked repo.

 

4) The Android Widget (pictured above)

The last piece of the puzzle is the quickly hacked together Android Widget I wrote so I could see the temps on my phone all the time. emoncms exposes each feed through a REST API, using that API the app queries for the last feed value and displays it in the widget.

The code is in this Git Repo. It’s very rough but as there are no Apps or widgets for emoncms I’ll probably be building it out a little more over the next little while.

 

There you have it a full end to end system for monitoring pretty much anything you want wirelessly. It’s awesome and amazing. If anyone has any questions or comments I’m happy to chat. My next steps from here are to expand upon the simple node to base data flow and make the sensors wireless nodes that control things through emoncms. Stay tuned.

 

 

Update

The range is about 120 metres (~400 ft) line of sight. I’m running at 433Mhz which is nice and low and penetrates walls well. I have no signals problems anywhere in and around my house. 2 AA batteries will last upwards of 6 months (estimated) as none of my nodes have died yet. In the screen shot for emoncms there is a shot of the dashboard. Under each temp there is a dial is showing the millivolts left in each battery pack.

I love cell phones and want to test your new smartphone!

Chris Brooker
June 4, 2009

palm_2dpre_2dsize_2dcomparison

Hi manufacturers of smartphones, Rim, Apple, Palm, Google, (sorta) Nokia. I’m a huge lover of cell phones and have been through more than my fair share in the quest for the perfect phone. Which inevitably leads me to making a list of all the things I would really like to have in a smart phone and I’m always left staring at an impossible list.

Quick sample of my list;

  • Powerful CPU (Atom or better equivalent performance)
  • Full featured OS. (Multitasking, Full browsing with flash at minimum, ability to install any apps I want without an approval process or having to hack the device, push email is a full featured email client.)
  • OS must remain quick and responsive at all times.
  • Ability to plug in USB devices like videos camera, cameras and external HDs.
  • Non-crippled Bluetooth. Support all Bluetooth profiles.
  • Excellent 10MP AF camera with 720p video recording with a Flash. Support for Bluetooth mics.
  • GPS, Accelerometer, compass, proximity sensor, ambient light sensor, etc (the usual)
  • Large vibrant capacitive touchscreen with a Transflective TFT LCD and e-ink display 4″- 6″? Pocketable.
  • Ability to playback 1080p h.264 video on screen and via Wireless HDMI as well as gfx accelerated flash.
  • Ability to play 3d games and run gfx accelerated applications. (perhaps the entire UI)
  • 2 full days of battery life with actual use.
  • Integration to major social networking sites (Facebook, twitter, etc)
  • Unified messaging framework for SMS, IM, email (Maybe Google Wave can help)

Essentially a full PC designed for a touchscreen with an all day battery that will fit in my pocket.

So ya, an impossible list. I’m tired of carrying around so many devices and all the devices I carry around are small.

  • 11″ Tablet-PC (for computing)
  • Ultra compact HD camcorder
  • iPhone
  • all the chargers and cables (the most weight, just so I can use these things for more than an hour)

I just want to carry 1 device that does it all.

What I’m really asking, to anyone out there listening, is can I please test your new smartphone? I’ve used them all Blackberries, iPhones, Nokias,  WinMo, etc. I’ve played with the Google G2 (HTC Magic). I’d love to try the Palm Pre if it were in Canada and on a GSM network.

Let me test your smartphone.

Related Posts with Thumbnails