tempC = (volts
0.5) * 100 ;
// print the celcius temperature over the serial port
Serial.print(" degrees C: ");
Serial.print(tempC);
//print spacer
Serial.print(" **** ");
// Convert from celcius to fahrenheit
tempF = (tempC * 9.0 / 5.0) + 32.0;
//print the fahrenheit temperature over the serial port
Serial.print(" degrees F: ");
Serial.println(tempF);
//wait a bit before taking another reading
delay(1000);
}
Code to Note
Serial.begin(9600);
Before using the serial monitor, you must call
Serial.begin()
to initialize
it. 9600 is the “baud rate,” or communications speed. When two devices are
communicating with each other, both must be set to the same speed.
Serial.print(tempC);
The Serial.print() command is very smart. It can print out almost anything
you can throw at it, including variables of all types, quoted text (AKA
“strings”), etc. See
http://arduino.cc/en/serial/print
for more info.
Serial.println(tempF);
Serial.print()
will print everything on the same line.
Serial.println()
will move to the next line. By using both of these
commands together, you can create easy-to-read printouts of text and data.
What You Should See
You should be able to read the temperature your temperature sensor is
detecting on the serial monitor in the Arduino IDE. If it isn’t working, make
sure you have assembled the circuit correctly and verified and uploaded the
code to your board, or see the Troubleshooting section.
Example of what you should see in the Arduino IDE’s serial monitor:
TempVal = 223
volts: 0.719
degrees C: 21.94 **** degrees F: 71.48
TempVal = 224
volts: 0.723
degrees C: 22.26 **** degrees F: 72.06
TempVal = 224
volts: 0.723
degrees C: 22.26 **** degrees F: 72.06
TempVal = 224
volts: 0.723
degrees C: 22.26 **** degrees F: 72.06
TempVal = 224
volts: 0.723
degrees C: 22.26 **** degrees F: 72.06
TempVal = 224
volts: 0.723
degrees C: 22.26 **** degrees F: 72.06
TempVal = 223
volts: 0.719
degrees C: 21.94 **** degrees F: 71.48
TempVal = 223
volts: 0.719
degrees C: 21.94 **** degrees F: 71.48
Page 42 of 63