Because much of what we do we have to know how to use computers, or program them to do what we need them to do such as in this case; recourd our results. Because of how everything is becoming more computer involved, we need to be fluent in knowing basic knowledge on computer programming.
Step Two:
Start with a simple program and work your way up to getting the program made that does what you need it to do. This way you save time by not struggling with a difficult problem to start with. We also do a lot of background research so we dont have to learn everything from scratch and re-invent the wheel.
Step Three:
The Arduino Code
/* ---------------------------------------------------------
* | Arduino Experimentation Kit Example Code |
* | CIRC-10 .: Temperature :. (TMP36 Temperature Sensor) |
* ---------------------------------------------------------
*
* A simple program to output the current temperature to the IDE's debug window
*
* For more details on this circuit: http://tinyurl.com/c89tvd
*/
//TMP36 Pin Variables
int temperaturePin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade
//(500 mV offset) to make negative temperatures an option
/*
* setup() - this function runs once when you turn your Arduino on
* We initialize the serial connection with the computer
*/
void setup()
{
Serial.begin(9600); //Start the serial connection with the copmuter
//to view the result open the serial monitor
//last button beneath the file bar (looks like a box with an antenae)
}
void loop() // run over and over again
{
float temperature = getVoltage(temperaturePin); //getting the voltage reading from the tem
//perature sensor
temperature = (temperature - .5) * 100; //converting from 10 mv per degree wit 500
// mV offset
//to degrees ((volatge - 500mV) times 100)
Serial.println(temperature); //printing the result
delay(1000); //waiting a second
}
/*
* getVoltage() - returns the voltage on the analog input defined by
* pin
*/
float getVoltage(int pin){
return (analogRead(pin) * .004882814); //converting from a 0 to 1023 digital range
// to 0 to 5 volts (each 1 reading equals ~ 5 milliv
//olts
}
Here is a code that I found that seemed to work better and was simple to work with. You can find it below or on this site: http://myelectronicsdiary.wordpress.com/2012/03/01/a-simple-arduino-based-temperature-logger-system/
float tempC; |
int Sensor = 0; |
|
void setup() |
| { |
| Serial.begin(9600); //opens serial port, sets data rate to 9600 bps |
| } |
|
| void loop() |
| { |
| float val = analogRead(Sensor); //read the value from the sensor |
| tempC = (5.0 * val * 100.0)/1024.0; //convert the analog data to temperature |
| Serial.print("Temperature = "); |
| Serial.print((byte)tempC); //send the data to the computer |
| Serial.println("C"); |
| delay(1000); //wait one second before sending new data |
| } |
The Teperatures I found are as follows:
Temperature = 25C
Temperature = 24C
Temperature = 26C
Temperature = 25C
Temperature = 27C
Temperature = 27C
Temperature = 29C
Temperature = 30C
Temperature = 30C
Temperature = 33C
Temperature = 34C
Temperature = 35C
Temperature = 38C
Temperature = 38C
Temperature = 39C
Temperature = 40C
Temperature = 43C
Temperature = 44C
Temperature = 44C
Temperature = 48C
Temperature = 50C
Step Four:
I feel that the best part of this temperature recording code is that it converts the temperature results to celsius which is a universal reading that many of us know. Such as my readings at the begining are around room temperature which in measurements most of us would understand: 25C = 77 fahrenheit. Then the temps began to raise as I heated the piece of aluminum. I stopped when I reached 50C which is close to 122 fahrenheit.
Step Five:
I feel that my strengths in the project was researching more about recording temperature using the arduino because I was able to find a code that I understood better than the one provided which also worked just fine. My future improvements would be to set up the code to give the results in Fahrenheit as well since many people here can relate to those results more so that the ones in Celsius. I feel that this code can come in handy for a lot of things and it is a valuable skill to learn how to set this up.
No comments:
Post a Comment