Photos of the cleaned up final product!
Arduino Project!
Saturday, June 2, 2012
Friday, June 1, 2012
Thursday, May 31, 2012
Picture Time!
Google Code Project Page
We finally got ourselves a Google Code project page for everything. It is located here:- http://code.google.com/p/arduinosensor/
All the wiki and source code will be there as well. Enjoy!
All the wiki and source code will be there as well. Enjoy!
Temperature Sensor & ADC
In our project, we have 5 sensors in all and they are all connected to the ADC of the Teensy. What's an ADC? Read more here.
The cliff notes is that the arduino reads in voltage value from 0v to 5v and it relates this values to a number between 0 to 1023. 0v being 0, 5v being 1023 and everything inbetween is scaled appropriately.
Why the magic number of 1023? The answer: It has only a 10 bit resolution for the ADC. 2^10 = 1024.
For this entry, we will try to calibrate the Temperature Sensor. The data sheet is located here. Our Temperature Sensor is the TMP36 so we shall look at the appropriate section. To calibrate, we take a look at the "Output voltage vs Temperature" Graph.
We can see that line "b" is the sensor we are using and that it is linear. At 0 degrees celcius, it's roughly at 0.5v and at 100 degrees celcius it's at about 1.5v.
By calculating, 0 degrees should give an ADC value of about 102 and a 100 degrees should give 307.
Assuming there's some error of + or - 0.1 volt, the readings can go from 82 to 123 for 0 degrees and 287 to 327 for 100 degrees.
We then did a physical test by putting the sensor near a kettle of boiling water (aka 100 degrees celcius), the reading should an ADC value of 320. When we put the sensor near an ice cube (aka 0 degrees celcius) through a plastic bag, it read 226. The Ice value was expected to be between 82 to 123 but it was so much higher. This could be due to the insulation of the plastic bag preventing an accurate reading.
With this, we know it's linear and that 100 degrees is 320, we can then calculate 0 degrees and hence calibrate it.
Boiling water = 320/1023 = 1.56 volts
Therefore Ice = 1023/5 * (1.56 - 1) = 115 ADC value
This means that 320-115 = 205 ADC values to go from 0 to 100.
1 degree change = 205/100 = 2.05 ADC
Next:-
100 degrees celcius to readings = 320 ADC /2.05 ADC = 156 in temperature
0 degrees celcius to readings = 115 ADC /2.05 ADC = 56 in temperature
We can see it is off by 56, therefore the offset is set to 56. During physical testing, we found that the offset is actually 96 through trial and error.
We can now calibrate it in this method:-
valTemp = taken from ADC
tempOffset = 96
oneDegreeChange = 2.05 ADC
tempCel = (valTemp/oneDegreeChange)-tempOffset;
Cheers!
The cliff notes is that the arduino reads in voltage value from 0v to 5v and it relates this values to a number between 0 to 1023. 0v being 0, 5v being 1023 and everything inbetween is scaled appropriately.
Why the magic number of 1023? The answer: It has only a 10 bit resolution for the ADC. 2^10 = 1024.
For this entry, we will try to calibrate the Temperature Sensor. The data sheet is located here. Our Temperature Sensor is the TMP36 so we shall look at the appropriate section. To calibrate, we take a look at the "Output voltage vs Temperature" Graph.
By calculating, 0 degrees should give an ADC value of about 102 and a 100 degrees should give 307.
Assuming there's some error of + or - 0.1 volt, the readings can go from 82 to 123 for 0 degrees and 287 to 327 for 100 degrees.
We then did a physical test by putting the sensor near a kettle of boiling water (aka 100 degrees celcius), the reading should an ADC value of 320. When we put the sensor near an ice cube (aka 0 degrees celcius) through a plastic bag, it read 226. The Ice value was expected to be between 82 to 123 but it was so much higher. This could be due to the insulation of the plastic bag preventing an accurate reading.
With this, we know it's linear and that 100 degrees is 320, we can then calculate 0 degrees and hence calibrate it.
Boiling water = 320/1023 = 1.56 volts
Therefore Ice = 1023/5 * (1.56 - 1) = 115 ADC value
This means that 320-115 = 205 ADC values to go from 0 to 100.
1 degree change = 205/100 = 2.05 ADC
Next:-
100 degrees celcius to readings = 320 ADC /2.05 ADC = 156 in temperature
0 degrees celcius to readings = 115 ADC /2.05 ADC = 56 in temperature
We can see it is off by 56, therefore the offset is set to 56. During physical testing, we found that the offset is actually 96 through trial and error.
We can now calibrate it in this method:-
valTemp = taken from ADC
tempOffset = 96
oneDegreeChange = 2.05 ADC
tempCel = (valTemp/oneDegreeChange)-tempOffset;
Cheers!
Tuesday, May 29, 2012
Element14 to the rescue!
Temperature sensor was killed in action. The legs broke off. We needed to get a new one. Where to get good stuff at a good price? Element14!
I called them an hour earlier to place an order. I ordered 2 of TMP36GT9Z a Temperature sensor IC. Costed $1.22 each. Also bought for myself a Desoldering Braid to make my soldering life easier when I make a mistake.
I then went down to collect it on the same day an hour later! Painless ordering and fast!
Oh, did I mention they give Students 8% Discount!
Twitter to Python to Serial Com to Arduino (Part 2)
Twitter has many ways to authenticate a user. For this project, since the device doesn't change we are using "Single-user OAuth". Using that method allows use not to not need to implement the full OAuth token acquisition handshakes.
All you need is:-
Once there, go to "My Applications" that is listed under the account name and "Create a new application".
Fill up what is needed then head to "Settings" and modify "Application type" to "Read and Write". Then go to "Details" and create an Access Token.
After all is done, take note of the Consumer key, Consumer secret key, Access token and Access token secret.
With this information, you can then tweet directly from python. Here's the code:-
All you need is:-
- Consumer key
- Consumer secret key
- Access token
- Access token secret
Once there, go to "My Applications" that is listed under the account name and "Create a new application".
Fill up what is needed then head to "Settings" and modify "Application type" to "Read and Write". Then go to "Details" and create an Access Token.
After all is done, take note of the Consumer key, Consumer secret key, Access token and Access token secret.
With this information, you can then tweet directly from python. Here's the code:-
import twitterAnd that's it for now!
api = twitter.Api(consumer_key='key', consumer_secret='key', access_token_key='key', access_token_secret='key')
api.PostUpdate("Hello world from Python!")
Subscribe to:
Posts (Atom)











