Thursday, September 12, 2013

Basic Light and Temperature Sensing

Here I use two cheap analog sensors for temperature and light:
http://www.adafruit.com/products/165
http://www.adafruit.com/products/161

And convert their analog values to digital values using an Analog to Digital convertor (ADC)
http://www.adafruit.com/products/856

To make things easy I wire these up on an external breadboard connected to the Pi using a Pi cobbler:
http://www.adafruit.com/products/914

Tutorials for installing and using these components can be found on Adafruit's website and I used them heavily. I could explain the technical details of all these components but Adafruit probably does a more elegant job and has tons of documentation so please follow the links for more information. Also the temperature sensor and the ADC are used by TONS of people so a quick google search will give lots of results as well!



Also a quick note about the light sensor:
I use a 1K resistor to change by values a bit. This resistor gives me a nice range when the light is bright. If you use a larger resistor (say 10k) it will be better at resolving lower light level differences. Play around with it and use a resistor that gives you a nice dynamic range for the light levels you are interested in sensing.

Basic Twitter Code using the Tweepy API

So this is a super simple script that allows me to tweet from the command line which is pretty cool! I call the file tweeter.py and can tweet by saying...

$sudo python tweeter.py 'Message I want to tweet'



I can't show you the sensitive information from Twitter for obvious reasons, but you should plug your information into those spots and it should work for you. You do need to visit the developer Twitter website to set up the API, link it to your account, and have they give you your appropriate numbers. Here is the tutorial I followed to get this done.

http://c-mobberley.com/wordpress/index.php/2013/04/26/raspberry-pi-connect-to-twitter-account-using-tweepy-installation-and-tweet-cpu-temperature-example/