Getting Started with Grove
Experiment: Analog temperature sensor module
In this article, I'll show you how to use a Grove analog temperature sensor module. As you'll see, just like with the button module, wiring will be a breeze and error-free.
If you prefer to watch the video version of this article, go ahead.
Purchase a Grove Temperature module
This module contains a thermistor. Plug it into a Grove analog connector and it's ready to measure temperatures between -40 to 125°C , with an accuracy of 1.5°C.
This is a Seeed product. Click on the red button, to complete your purchase on the Seeed website.
About this experiment
I'll show you how to use this temperature module to measure temperature.
About the Grove temperature module
This module contains a thermistor, model NCP18WF104F03RC, which is a variable resistor.
The value of the resistance depends on the ambient temperature.
The module uses an NTC thermistor. NTC stands for "Negative Temperature Coefficient". This means that when the temperature of the component increases, its resistance decreases, and vice-versa.
Connect the Grove temperature module
Let's connect the temperature module to one of the Grove connectors on the Base Shield. Because this module is an analog device, we'll use one of the available analog Grove ports, instead of the digital ones we used in the button experiment.
Take a Grove cable.
Plug one end in socket A0 on the Grove Base Shield.
Plug the other end in the Grove socket of the temperature module.
Your circuit should look like the example in this photo:
As we did with the button, follow the yellow wire from the module pin "SIG" to the Base Shield to determine the Arduino pin we will need to use in the sketch.
In the photograph, the arrows point to the yellow wire that conveys the temperature module signal, and the two pins it connects: Arduino analog pin 0 (A0) which is in Grove connector A0, and pin "SIG" on the module.
Now that we now which Arduino pin the module is connected to, we can continue with the sketch.
The Arduino sketch
The sketch we'll use to read the state of the temperature sensor and calculate the temperature in degrees Celsius is very simple.
Have a look:
In the sketch, we include the math library because we need to do a couple of calculations, one of which is a logarithm. The function for the logarithm calculation exists in the math C library.
In line 55, we set the B coefficient, which depends on the thermistor module, and can be found in its datasheet.
In line 56, we set the fix voltage divider resistor. The temperature module contains a 100KΩ resistor.
Both these values are needed for the temperature calculation in the loop.
In line 57, we set the signal pin of the temperature module. We have connected the module to Arduino analog pin 0, or "A0".
Inside the loop, we calculate the temperature in degrees Celsius by breaking down the formula in three parts, and working out a couple of intermediate results.
Let's try out this sketch and circuit.
Execute the sketch
Upload the sketch to your Arduino. To increase the temperature on the sensor, I used a heat gun.
Start the serial monitor to see the calculated temperature.
Every 100 milliseconds, a new temperature will be printed.
Again, how easy was that? Wiring literally takes 10 seconds or less, just like with the button experiment. There was zero risk of error, and no need to use a fixed resistor for the voltage divider. The module even contains a signal amplifier which helps to provide a more reliable measurement.
Let's try out one more experiment in this series. In the next article, I'll show you how to control an LED.
"Getting Started with Grove" series
Ready for some serious learning?
Grove For Busy People
In this course, I’m going to show you how to use the Grove system for the Arduino.
It is a course for people who know the basics of the Arduino. If you have never used an Arduino before, consider enrolling to Arduino Step by Step Getting Started first.
Just click on the big red button to learn more.