1 of 20
Core Arduino Workshop
Chris Koehler and Brian SandersColorado Space Grant Consortium
2 of 20
Part 3 – Arduino Road Trip
A. Temperature Sensor
2
vArduino Uno
Temperature Sensor:
PC/MacMonitor LEDs
Pot/Other
Infrared
Temp
3
4
- The potentiometer is an analog sensor
- Almost all analog sensors work and are connected in the same way
- Let’s use hook up one more
- To do so will require another breadboard, with nicer features
Temperature Sensor:
5
Temperature sensor is theTMP36 - Temperature Sensor
Temperature Sensor:
6
- This breadboard has power and ground rails- Individual points on rails (rows) are connected- One rail, and its points, are independent of other rails
Temperature Sensor:
7
- Also has numbers and letters to coordinate builds
Temperature Sensor:
8
- Place in new breadboard exactly as shown
Temperature Sensor:
9
- 5V (pin 1) = E3- Data (pin 2) = E2- GND (pin 3) = E1
Note orientation of sensor package
Temperature Sensor:
5 V
Data GND
10
- Connect 5V from Arduino to “+” power rail
- Connect GND from Arduino to “-” rail
Temperature Sensor:
11
- Connect 5V from Arduino to “+” power rail
- Connect GND from Arduino to “-” rail
Temperature Sensor:
12
- Now all pins on “+” rail are connected to 5 Volts
- All “-” are connected to GND
Temperature Sensor:
13
- Connect 5V and GND from rails to sensor
5V to A3
GND to A1
Temperature Sensor:
14
- Connect A0 from Arduino to A2 on Bread-board
Temperature Sensor:
15
- What do we need to change in the Sketch?
Temperature Sensor:
16
- Nothing! But the Temp Sensor Voltage commands all LEDs off
- Build and Upload the code and look at serial monitor
- Should see ~0.73 Volts, which is well below our first LED turn on value of 1.25 Volts in the current IR sensor Sketch
Temperature Sensor:
17
- To understand and set the proper range, let’s consult the data sheet for the sensor
- 10 mV/C (0.010V/C)
Temperature Sensor:
18
- Data sheet also says there is an offset
- For TMP36,Offset = 0.5 Volts
Temperature Sensor:
19
- So to understand the data, we need to do some math to convert voltage to C and set our ranges
Using what we are seeing from our serial monitor, 0.73 Volts, we would get…
Temperature Sensor:
20
- Change the Sketch to do the math and change LED turn on ranges to temperatures of 21, 22, 23, and 24 C.
- Will need a new variable (float)
Temperature Sensor:
21
- New variable, tempC (float)
- Add your math
- Modify your print statements
Temperature Sensor:
22
- Adjust your range settings for the LEDs
- Build and Upload
- Test by touching your temp sensor
- Challenge while you wait… Convert to Fahrenheit
Temperature Sensor:
PLEASE SAVE YOUR
SKETCH FILE
Top Related