edit

Grove - Temperature Sensor V1.2

The Grove - Temperature Sensor uses a Thermistor to detect the ambient temperature. The resistance of a thermistor will increase when the ambient temperature decreases. It's this characteristic that we use to calculate the ambient temperature. The detectable range of this sensor is -40 - 125ºC, and the accuracy is ±1.5ºC

Note: This wiki works with Grove - Temperature sensor V1.1 as well, for V1.0 please refer to Grove - Temperature Sensor

Specifications


  • Voltage: 3.3 ~ 5V
  • Zero power resistance: 100 KΩ
  • Resistance Tolerance: ±1%
  • Operating temperature range: -40 ~ +125 ℃
  • Nominal B-Constant: 4250 ~ 4299K

Tip

More details about Grove modules please refer to Grove System

Platforms Supported


Arduino Raspberry Pi BeagleBone Wio LinkIt ONE

Caution

The platforms mentioned above as supported is/are an indication of the module's software or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.

Getting Started


After this section, you can make Grove - Temperature Sensor V1.1/1.2 run with only few steps.

Note

If this is the first time you work with Arduino, we firmly recommend you to see Getting Started with Arduino before the start.

Play With Arduino

Hardware

  • Step 1. Prepare the below stuffs:
Seeeduino V4.2 Base Shield Grove - Temperature Sensor
enter image description here enter image description here enter image description here
Get One Now Get One Now Get One Now
  • Step 2. Connect Grove - Temperature Sensor to port A0 of Grove-Base Shield.

  • Step 3. Plug Grove - Base Shield into Seeeduino.

  • Step 4. Connect Seeeduino to PC via a USB cable.

Note

If we don't have Grove Base Shield, We also can directly connect Grove_Ultrasonic_Ranger to Seeeduino as below.

Seeeduino Grove - Temperature Sensor
5V Red
GND Black
Not Conencted White
A0 Yellow

Software

  • Step 1. Launch Arduino IDE and click File>New to open a new page. Copy the following code into the new page and upload. If you do not know how to upload the code, please check How to upload code.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Demo code for Grove - Temperature Sensor V1.1/1.2
// Loovee @ 2015-8-26

#include <math.h>

const int B = 4275;               // B value of the thermistor
const int R0 = 100000;            // R0 = 100k
const int pinTempSensor = A0;     // Grove - Temperature Sensor connect to A0

void setup()
{
    Serial.begin(9600);
}

void loop()
{
    int a = analogRead(pinTempSensor);

    float R = 1023.0/a-1.0;
    R = R0*R;

    float temperature = 1.0/(log(R/R0)/B+1/298.15)-273.15; // convert to temperature via datasheet

    Serial.print("temperature = ");
    Serial.println(temperature);

    delay(100);
}

Step 2. Open the Serial Monitor of Arduino IDE by click Tool-> Serial Monitor. Or tap the Ctrl+Shift+M key at the same time. if every thing goes well, you will get the temperature.

The result should be like:

Play With Raspberry Pi (With Grove Base Hat for Raspberry Pi)

Hardware

  • Step 1. Things used in this project:
Raspberry pi Grove Base Hat for RasPi Grove - Temperature Sensor
enter image description here enter image description here enter image description here
Get ONE Now Get ONE Now Get ONE Now
  • Step 2. Plug the Grove Base Hat into Raspberry.
  • Step 3. Connect the temperature sensor to port A0 of the Base Hat.
  • Step 4. Connect the Raspberry Pi to PC through USB cable.

Note

For step 3 you are able to connect the temperature sensor to any analog Port but make sure you change the command with the corresponding port number.

Software

  • Step 1. Follow Setting Software to configure the development environment.
  • Step 2. Download the source file by cloning the grove.py library.
1
2
cd ~
git clone https://github.com/Seeed-Studio/grove.py
  • Step 3. Excute below commands to run the code.
1
2
cd grove.py/grove
python grove_temperature_sensor.py 0

Following is the grove_temperature_sensor.py code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import sys
import time
from grove.factory import Factory


def main():
    from grove.helper import SlotHelper
    sh = SlotHelper(SlotHelper.ADC)
    pin = sh.argv2pin()

    sensor = Factory.getTemper("NTC-ADC", pin)

    print('Detecting temperature...')
    while True:
        print('{} Celsius'.format(sensor.temperature))
        time.sleep(1)


if __name__ == '__main__':
    main()

Success

If everything goes well, you will be able to see the following result

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
pi@raspberrypi:~/grove.py/grove $ python grove_temperature_sensor.py 0
Hat Name = 'Grove Base Hat RPi'
Detecting temperature...
24.7473402633 Celsius
24.7473402633 Celsius
24.7473402633 Celsius
24.7112751977 Celsius
24.7112751977 Celsius
^CTraceback (most recent call last):
  File "grove_temperature_sensor.py", line 53, in <module>
    main()
  File "grove_temperature_sensor.py", line 49, in main
    time.sleep(1)
KeyboardInterrupt

You can quit this program by simply press Ctrl+C.

Notice

You may have noticed that for the analog port, the silkscreen pin number is something like A1, A0, however in the command we use parameter 0 and 1, just the same as digital port. So please make sure you plug the module into the correct port, otherwise there may be pin conflicts.

Play With Raspberry Pi (with GrovePi_Plus)

Hardware

  • Step 1. Prepare the below stuffs:
Raspberry pi GrovePi_Plus Grove - Temperature Sensor
enter image description here enter image description here enter image description here
Get One Now Get One Now Get One Now
  • Step 2. Plug the GrovePi_Plus into Raspberry.

  • Step 3. Connect Grove - Temperature Sensor ranger to A0 port of GrovePi_Plus.

  • Step 4. Connect the Raspberry to PC via USB cable.

Software

Tip

In this wiki we use the path ~/GrovePi/ instead of /home/pi/Desktop/GrovePi, you need to make sure Step 2 and Step 3 use the same path.

Note

We firmly suggest you to update the firmware, or for some sensors you may get errors.

  • Step 3. Git clone the Github repository.
1
2
cd ~
git clone https://github.com/DexterInd/GrovePi.git
  • Step 4. Excute below commands to use the Grove - Temperature Sensor to meansure the temperature.
1
2
cd ~/GrovePi/Software/Python
sudo python grove_temperature_sensor.py

Here is the grove_temperature_sensor.py code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# NOTE:
#   The sensor uses a thermistor to detect ambient temperature.
#   The resistance of a thermistor will increase when the ambient temperature decreases.
#
#   There are 3 revisions 1.0, 1.1 and 1.2, each using a different model thermistor.
#   Each thermistor datasheet specifies a unique Nominal B-Constant which is used in the calculation forumla.
#
#   The second argument in the grovepi.temp() method defines which board version you have connected.
#   Defaults to '1.0'. eg.
#       temp = grovepi.temp(sensor)        # B value = 3975
#       temp = grovepi.temp(sensor,'1.1')  # B value = 4250
#       temp = grovepi.temp(sensor,'1.2')  # B value = 4250

import time
import grovepi

# Connect the Grove Temperature Sensor to analog port A0
# SIG,NC,VCC,GND
sensor = 0

while True:
    try:
        temp = grovepi.temp(sensor,'1.2')
        print("temp =", temp)
        time.sleep(.5)

    except KeyboardInterrupt:
        break
    except IOError:
        print ("Error")

The result should be like:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
pi@raspberrypi:~/GrovePi/Software/Python $ sudo python grove_temperature_sensor.py

('temp =', 25.28652137917777)
('temp =', 25.28652137917777)
('temp =', 25.28652137917777)
('temp =', 25.28652137917777)
('temp =', 25.368489566400115)
('temp =', 25.61468397498203)
('temp =', 27.43501590142614)
('temp =', 27.85285590636829)
('temp =', 27.18509952680688)
('temp =', 26.852756540240193)

Reference


If you want to know how the algorithm of temperature coming, please refer to the below image:

Resources


Projects

Temperature sensor Grove module:

Tech Support

Please submit any technical issue into our forum.