# Thermistor Sensor Module with micro:bit

Difficulty
Easy
Steps
11

In this guide, we will learn to use a thermistor. They are useful little components that change their resistance with temperature.

Completing this guide will teach you about thermistors and its relationship between resistance and temperature.

Parts Used in This Guide

## Step 1  The Module

A thermistor is a type of variable resistor whose resistance changes with temperature.

Let's take a closer look at the thermistor module.

• 3.3V  : 'VCC' stands for Voltage Common Collector. We'll connect the VCC pin to 3.3V on the micro:bit
• GND: In electronics, we define a point in a circuit to be a kind of zero volts or 0V reference point, on which to base all other voltage measurements. This point is called ground or GND.
• Note: Voltage is the difference in potential between two points. As it is difficult to talk about voltage without a reference point, we need another point to compare it to.
• DO: Digital Output
• AO: Analog Output

## Step 7  Measuring analog value

• Open up MakeCode editor and start a new project
• Click on the 'Variables' tab.
• Click 'Make a Variable...' and name it 'AO'
• Then drag and drop a 'set ... to ...' block.
• From 'Basic' tab, drag and drop a 'show number' block
• From Variables tab, grab a 'AO' block and attach it to 'show number ... ' block
• From 'Pins' tab, get out a 'analog read pin' block and connect it to 'set ... to'
• Make sure the value in 'analog read pin' block is P1
• Again from 'Basic' tab, get out a 'pause (ms)' block and change its corresponding value to 1000

Let's use the micro:bit to get a temperature reading. What the micro:bit actually measures is the temperature of a silicon die on its CPU, which gives a rough estimate of the ambient temperature.

• Duplicate the 'show number' block: Right click on it and select 'Duplicate'.
• Place this new 'show number' block under the first 'show number' block
• From the Input tab, grab a 'temperature °C' block, and place it in the second 'show number' block.

## Step 9  Set a threshold value

We are going to set a threshold value so that depending on the temperature, it may show a cross icon.

• From the 'Logic' tab, grab a 'if true ... then ...' block.
• Again back to the 'Logic' tab, grab a ' ... < ... ' block
• Change it to ' ... > ... '
•  Replace its values with 'AO' block (get it from Variables tab), and '900'.
• Place this in the "if true ... then ..." block
• From 'Basic' tab, drag and drop a 'show icon ... ' block and place it in the if loop.
• Change the icon to a cross by clicking on the drop down arrow on the 'show icon... ' block

## Step 10  Else statement

We are going to set another condition now, so that depending on the temperature, it may show a tick or a cross icon.

• Click on the white plus icon to add an 'else' statement.
• Right click on 'show icon' block and select 'Duplicate'.
• Change the second 'show icon' block's symbol to a tick and place this under the else statement.

This is a simple way to monitor temperature using a thermistor module. Displaying a tick or cross icon is just one of many ways to go about it. Thermistors can be found in refrigerators and air conditioners as well as many other systems.

Can you think of other ways you could use a thermistor module?

## Step 11  Upload the code

It's time to upload the code to the micro:bit!

• Connect the micro:bit to your computer using a microUSB cable