Homeward light indicator with RaspberryPi and CommonSense

26 Feb 2013

I've been tinkering with my [raspberry-pi][raspberry-pi] for quite some time now. What I like about it because it is cheap ($25), it's run Linux (especially debian based) and most of all it's have General Purpose Input Output pin. Since I was a kid, I always wanted to control electronic appliance remotely. Luckily my friend [@pimnijdam][pimnijdam] thought me how to control a relay board. Basically it's just like an electric switch that connect/disconnect current when you supply a low voltage. So I connect one of the GPIO pin to the relay board and from the relay board to the lamp. Now I can control the desk lamp through my raspberry-pi by issuing a linux command. Had been successfully doing this, I wanted to the lamp not only from the raspberry pi but anywhere. The easiest way that I could think of is running a web server inside the raspberry-pi. The debian repository is quite awesome. So I could install a ruby/python and it only took a single command. So I did create a [project][pi-sinatra-github] with ruby/sinatra to control this light. Its really small (30 lines of code, 80 lines html + js) and with this project I can control up to 3 light, one of those eventually control the light. In case you are interested, I put the source on [github][pi-sinatra-github]. This project uses [pi-piper][pi-piper] a ruby library that wrap [wiringPi][wiringPi], which is library that is used to control the GPIO pin.
homeward indicator
The light will turn on whenever I leave the office at noon.


lamp off
Controlling Lamp with Raspberry-pi + ruby/sinatra
1
</div>

The phone open a web browser to the raspberry pi

Now, turning a desk lamp with pi is something; But it's quite boring and not really useful. Now let us make something a bit interesting. Instead of controlling it manually, The light be trigger on my activity. In this case I the light to turn on when ever I came back from the office on every working day. So at home my wife know exactly when I leave the office. I already have it running a web server, so basically I can control it from my mobile phone. But I don't want to do this every single day. And this is where ComonSense really makes thing easy for me.

CommonSense is a platform to store, retrieve, analyze and interpret our sensory data. What is a sensor ? well anything could be a sensor. From physical sensor on our mobile phone like accelerometer, noise, position, cell network, light, ambience and more sophisticated sensor like sensor that tell your quality of sleep. By using one or more sensor, it could create more intelligent sensor. For example a sensor that tell wether you are standing or sitting by analyzing the accelerometer data. CommonSense is Awesome!, but for this experiment we will be using a simple location sensor. It will tell where is my current location by GPS or wifi-network.

What is make it easy is I don't have to create an application on my mobile phone. CommonSense already have a platform that run on Android or iOs. The application act as an agent that collect and sample sensor data from the mobile phone. By it self it's not really doing much right now but combine with the CommonSense make it really easy for a developer like me to easily experiment with my data. So with this sense app, the raspberry-pi could easily get data from my mobile phone through the CommonSense API.

sense app
Sense Android App - Works as an aggent of CommonSense
1
</div>

biking out of the office
The light will turn on when I'm 200m away from the office

Again, my awesome colleague @pim create a prototype of python framework that make it very easy for me to implement my project. You should definitely chek it out!. I've created the homeward light indicator project using the early version of the framework. This is actually my first encounter with Python. Although I still prefer doing my project with Ruby, I'm really enjoying working with Python.



Site related post:
  • Testing go 1.5 cross compilation on raspberry pi
  • Safely sharing credentials with PGP
  • osx-push-to-talk App
  • My account just got hacked by Romanian (Possibly)
  • Tracking origin of bugs with git bisect

Archives

    2015

  • Aug Testing go 1.5 cross compilation on raspberry pi
  • May Telepon murah ke Indonesia dengan voip
  • Mar osx-push-to-talk App
  • Jan Tracking origin of bugs with git bisect
  • 2014

  • Oct Stubbing Time.Now() in golang
  • 2013

  • Jul My account just got hacked by Romanian (Possibly)
  • Jul berks upload core dump
  • Jul Safely sharing credentials with PGP
  • Feb Homeward light indicator with RaspberryPi and CommonSense
  • 2012

  • Mar Scale MongoDB dengan Sharding
  • Feb Ruby Fiber apaan sih ?
  • Feb Responsive Design
  • Jan Jekyll error utf-8 caracter
  • Jan Testing ruby code with benchmark_suite

Let each man exercise the art he knows

Welcome to my canvas. A place for me to explore and experiment on some stuff that I found interesting.

Ruby (and Rails)

Ruby is a neat language. People create clean, elegant and smart app with it. Rails is web framework built on top of ruby. In this category I will explore stuff related to ruby and also rails

Web

This is general category involving various aspect of web technology. I like to explore not only the programming and technology aspect of the web, but also the design

Labs.Yulrizka.com
    • Left Panel
    • No Panel
    • Right Panel
twitter github feed
  • Home
  • Ruby (and Rails)
  • Web

© Ahmy Yulrizka 2012. This site is made with Jekyll using Twitter Bootstrap and hosted on Github pages. All of the content is open and the source can be accessed here