Ingo Lohs
Published © GPL3+

Grove - Introduction in a Temperature Sensor

Beginner-Example

BeginnerProtip1 hour4,779
Grove - Introduction in a Temperature Sensor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Seeed Studio Grove Base Shield
×1
Seeed Studio Grove Light Sensor
×1

Software apps and online services

Arduino Web Editor
Arduino Web Editor

Story

Read more

Code

Temperature Sensor - Example

C/C++
Original code by Seeedstudio
// 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/((float)a)-1.0;
    R = 100000.0*R;

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

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

    delay(100);
}

Credits

Ingo Lohs

Ingo Lohs

182 projects • 194 followers
I am well over 50 years and come from the middle of Germany.

Comments