x かころぐみよ
参考
結果
プログラム(おもに3.3V化と電圧化)
// 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
const int pinTempSensor = 1; // Grove - Temperature Sensor connect to G1
#if defined(ARDUINO_ARCH_AVR)
#define debug Serial
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
#define debug SerialUSB
#else
#define debug Serial
#endif
void setup()
{
Serial.begin(9600);
}
void loop()
{
int a = analogRead(pinTempSensor);
//float R = 1023.0/a-1.0;
//R = R0*R;
float R,v1,a1,o1;
v1 = ((float)a) * 0.001; //電圧を求める
a1 = v1 / 100000.0; //電流を求める
o1 = 5.0 / a1; //全体の抵抗を求める
R = o1 - 100000.0; //全体の抵抗から検出抵抗を引く
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);
}