Introduction: Temperature Sensor With LED
Using Arduino and a Vernier Temperature Probe you can measure and compare temperatures between liquids, while also adding a command to illuminate an LED. The Temperature Sensor will determine the temperature level of a liquid, and indicate whether it is hot or cold relative to the indicated setting on your Arduino. Depending on the temperature of the liquid, a light will go on/off indicating when the liquid has reached the desired temperature.
In this project, you will learn how to make a temperature probe function with Arduino, as well as the function to make an LED emit light for a given temperature. You will start by building the circuit, plugging in the code and finally testing it using different temperatures of liquid.
Here is a video of the end product: http://www.youtube.com/watch?v=vHH2bnjvt9U&feature=youtu.be
For the basic build you'll need the following materials:
- Arduino Uno microcontroller
- Solderless breadboard
- One 220Ω resistor
- One 470Ω resistor
- Jumper wires (connecting wires)
- Vernier Temperature Probe
- One LED
- Wire cutters/strippers
- Soldering iron
Now that you have gotten the materials, lets begin!
Step 1: Preparing Your Temperature Probe
Using a pair of wire cutters, take your Viernier Temperature Probe and snip the off the end of the cord. Inside, you will see six colored wires: Take a pair of wire strippers, and strip the green and black wires: these two wires will serve as your thermistor (temperature sensor). Solder one half of a jumper wire to both the green and black wires.
Step 2: Building a Temperature Sensor Circuit
The sensor circuit that you will be building will connect the Vernier Temperature Probe in order to read the temperature values on the serial monitor in Arduino.
Following the schematic, build the circuit on the breadboard as shown in the third photo. One wire of the thermistor of the Vernier Temperature Probe is connected to 5V, while the other is connected to Arduino's analog pin A5. Use the 220Ω resistor for this circuit.
*Thermistor is running to 5V and analog pin 5
*220Ω resistor is attached to ground and running to analog pin 5
*Attach one jumper wire from ground to the negative rail
*Attach one jumper wire from 5V to the positive rail
Note: Image of thermistor in circuit drawing is inaccurate
Step 3: Program the Arduino : Thermistor
Now that we have created the circuit for the thermistor, let's begin programming!
This code turns on the serial monitor and allows the Vernier Temperature Probe to output numerical values based on the temperature of the environment the probe is in. In this case the output are numbers from 0-100 (low numbers corresponding to low units of temperature, high numbers corresponding to higher units of temperature).
1. pinMode: Measures the inputs of analog pin 5
2. analogRead: Reads the inputs from the thermistor
3. map(): Makes values from serial monitor print from 0 to 1023 (current range) into 0 to 100 (target range)
Before we move on to the next step, let's check to make sure the temperature probe works! Fill two glasses with water: one with cold, one with hot. Insert Vernier temperature probe into the cold water: numbers on the serial monitor (between 0-100) should register as a low value. Then insert the probe into the cup of hot water; readings on the serial monitor should increase and be a relatively high value.
Step 4: Connect the LED to Your Circuit
Now it's time to connect your LED to the rest of your circuit. In order to connect the LED to your Temperature sensor circuit, connect the LED to pin13, using the 470Ω resistor.
*LED cathode (short leg) running to ground
*LED anode (long leg) running to to digital pin 13
*470Ω resistor running to pin 13 and anode of LED
*Attach one jumper wire from cathode of LED to the negative rail
*Attach one jumper wire from the resistor to the positive rail
Step 5: Reprograming the Arduino With LED
In order to cue the light to go on and off depending on the temperature reading on the serial monitor, insert the code above.
This code indicates that if the serial monitor outputs a number greater than or equal to 60, then the LED will omit light (turn on). If the serial monitor reads a value that does not fit under this restriction (“else”), then the LED will turn off.
1. if... else: else can proceed another if test, so that multiple, mutually exclusive tests can be run at the same time. Each test will proceed to the next one until a true test is encountered.
2. analogWrite: value id the duty cycle; between 0 (always off) and 255 (always on).
-if(reading) can be changed based on personal preference
-Serial.println() text can be changed based on personal preference
Step 6: Combined Code !
This is what your final set of code and circuit should look like together! Upload the code.
Step 7: Lets Try It Out!
Now that you have assembled and coded your Arduino, you are ready to test it out!
Fill two cups up with water; one with hot water, and the other with cold water. Connect your Arduino to your computer using an adapter cord and open the Serial Monitor on Arduino.
Insert the probe in the cold water first, and watch what happens. Then put it into the hot water, what changes? When the probe is submerged in cold water, the LED should turn off. When the probe is submerged in hot water, the LED should turn on.
Hope this was helpful, have fun!