 Grove Starter Kit For Arduino --- Temperature Sensor © LGPL

Teaches you how to use the temperature sensor in the Arduino Grove Starter Kit.

• 1,812 views
• 5 respects

Apps and online services

Note: I do not talk about the LCD screen in this project, If you haven't yet installed the library for it or need help with it please go here.

Setup:

As far as hardware, all you need to do is connect the temperature sensor to A0:

Code:

First you must find the initial value of the thermistor:

Then, since the resistance is what tells us the temperature, we must convert the reading to the resistance:

resistance = (float)(1023 - a) * 10000 / a;

And finally we convert the resistance to Celsius:

c = 1 / (log(resistance / 10000) / b + 1 / 298.15) - 273.15;

Code

temp.inoArduino
#include <math.h>
#include <Wire.h>
#include "rgb_lcd.h"
int a; //thermistor value
float c;
int b = 3985;      //b value of the thermistor
float resistance;

const int colorR = 0;
const int colorG = 0;
const int colorB = 255;

rgb_lcd lcd;

void setup(){
lcd.begin(16, 2);
lcd.setRGB(colorR, colorG, colorB);
}

void loop(){
a = analogRead(0); //find the original reading of the thermistor
resistance = (float)(1023 - a) * 10000 / a; //get the resistance of the sensor;
c = 1 / (log(resistance / 10000) / b + 1 / 298.15) - 273.15; //convert to Celsius via datasheet&nbsp;;
int f = (c*(9/5)+32);//convert to F (delete if you want C)
lcd.clear();
lcd.setCursor(0,0);
lcd.print("temperature is:");
lcd.setCursor(0,1);
lcd.print(f);//print the F temp on the lcd screen (change to: lcd.print(c); if you want C)
lcd.print("f");//change to lcd.print("c"); if you want C
delay(1000);//wait 1 second
}

Schematics by Grant

• 717 views
• 1 comment
• 2 respects

by Grant

• 1,809 views
• 9 respects

by Grant

• 10,112 views
• 13 respects

by Grant

• 5,454 views
• 7 respects

How To Use DS18B20 Water Proof Temperature Sensor

Project showcase by Team IoTBoys

• 35,433 views