1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

(3.3V)M5Nano C6で温度センサー、Grove-Temperature_Sensorで遊ぶ(V1.0)

Last updated at Posted at 2024-11-03

x かころぐみよ

参考

結果

o_coq374.jpg

o_coq375.jpg

o_coq597.jpg

o_coq598.jpg


/*
/* 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);
    //a=analogRead(15);
    a=analogRead(1);
    //resistance=(float)(1023-a)*10000/a; //get the resistance of the sensor;

    float v1,a1,o1; 
    v1 = ((float)a) * 0.001;      //電圧を求める
    a1 = v1 / 10000.0;            //電流を求める
    o1 = 5.0 / a1;                //全体の抵抗を求める
    resistance = o1 - 10000.0;    //全体の抵抗から検出抵抗を引く
    //Serial.println(v1); //debug
        
    temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;//convert to temperature via datasheet&nbsp;;
    delay(1000);
    Serial.print("Current temperature is ");
    Serial.println(temperature);
}


1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?