Using a temperature sensor with an Arduino
Arduino Uno tutorials
🕑 This lesson will take about 20 minutes
In this lesson, you will learn how to take readings from a temperature sensor using the Freetronics temperature sensor and an Arduino Uno.
Note that there are two different module types: the temperature sensor module and the humidity & temperature sensor module. Note: If you are using the humidity & temperature sensor module you will need to download a library for the Arduino IDE and use different wiring and code – follow the instructions for that module here.
Required parts
Here is what you will need:
1 x Arduino Uno board
1 x Freetronics temperature sensor module
1 x breadboard
3 x male-to-male jumper wires
Wiring schematic
Attach the temperature sensor module to your breadboard.
Connect the GND pin on the temperature sensor to a GND slot on the Arduino Uno board via the breadboard using a male-to-male jumper wire.
Connect the VCC (or VIN) pin on the temperature sensor to the 5V slot on the Arduino via the breadboard using a male-to-male jumper wire.
Connect the DATA pin on the temperature sensor to digital pin 2 on the Arduino board via the breadboard using a male-to-male jumper wire.
The schematic below shows how to wire it all up.
The code
Create a new sketch file using the Arduino IDE software. Copy the code below and replace any existing code in your file with the copied code. You can also view the source code and full instructions for the sensor on the Freetronics website. Save the file and upload the code to your Arduino board.
Testing the sensor
Upload the code to your Arduino and keep it plugged into your computer with the USB cable. Click on Tools > Serial Monitor in the Arduino IDE software. In the Serial Monitor window, make sure the baud rate is set to 9600 baud in the drop-down selection box. The temperature sensor should have a constant blue LED and the Serial Monitor should display the temperature readings every second.
Access the Serial Monitor from the Tools menu in the Arduino IDE software.
The Serial Monitor can display regular readings from the temperature sensor