What We’re DoingWhat’s the next phenomena we will measure with our Arduino? Temperature. To do this we’ll use a rather complicated IC (integrated circuit) hidden in a package identical to our P2N2222AG transistors. It has three pins ground, signal and +5 volts, and is easy to use. It outputs 10 millivolts per degree centigrade on the signal pin (to allow measuring temperatures below freezing there is a 500 mV offset eg. 25° C = 750 mV, 0° C = 500mV). To convert this from the digital value to degrees we will use some of the Arduino’s maths abilities. Then to display it we’ll use one of the IDE’s rather powerful features, the debug window. We’ll output the value over a serial connection to display on the screen. Let’s get to it.

One extra note, this circuit uses the Arduino IDE’s serial monitor. To open this, first upload the program then click the button which looks like a square with an antennae.

/*
* 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)
}

Nothing Seems to HappenThis program has no outward indication it is working. To see the results you must open the Arduino IDE’s serial monitor (instructions above)

Gibberish is DisplayedThis happens because the serial monitor is receiving data at a different speed than expected. To fix this, click the pull-down box that reads “*** baud” and change it to “9600 baud”

Temperature Value is Unchanging.Try pinching the sensor with your fingers to heat it up or pressing a bag of ice against it to cool it down.

Making it Better?

Outputting voltage:
This is a simple matter of changing one line. Our sensor outputs 10mv per degree centigrade so to get voltage we simply display the result of getVoltage().

More informative output:
Lets add a message to the serial output to make what is appearing in the Serial Monitor more informative. To do this first revert to the original code then change:Serial.println(temperature); —-> Serial.print(temperature);
Serial.println(” degrees centigrade”);
The change to the first line means when we next output it will appear on the same line, then we add the informative text and a new line.

Changing the serial speed:
If you ever wish to output a lot of data over the serial line time is of the essence. We are currently transmitting at 9600 baud but much faster speeds are possible. To change this change the line:Serial.begin(9600); —-> Serial.begin(115200);
Upload the sketch turn on the serial monitor, then change the speed from 9600 baud to 115200 baud in the pull down menu. You are now transmitting data 12 times faster.

Hi! I am using this circuit and programming as part of a sensor suite I want to eventually mount inside a little greenhouse to remotely monitor the conditions and have it twitter them and post to pachube.com. I have a prototype setup now and it works great, except that sometimes the readings go up and down so much.

I wonder if you maybe know what may cause such strange readings? For some time it will stay around 20 degrees (which it is), then a spike to, say, 100. I cannot explain these, and hope you can give a tip.