参考
結果
プログラム(サンプルそのまま)
/*
/* Grove - Temperature Sensor demo v1.0
* This sensor detects the environment temperature,
* Connect the signal of this sensor to A0, use the
* Serial monitor to get the result.
* By: https://www.seeedstudio.com
*/
#include <math.h>
int a;
float temperature;
int B=3975; //B value of the thermistor
float resistance;
void setup()
{
Serial.begin(9600);
}
void loop()
{
a=analogRead(0);
resistance=(float)(1023-a)*10000/a; //get the resistance of the sensor;
temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;//convert to temperature via datasheet ;
delay(1000);
Serial.print("Current temperature is ");
Serial.println(temperature);
}