티스토리 뷰

OS/Banana Pi /BPI-Bit

BPI-Bit : 온도 센서 사용하기

파란크리스마스 2019. 2. 6. 01:18
728x90

출처

BPI-Bit : 온도 센서 사용하기

BPI-Bit에는 온도 센서 모둘이 내장 되어 있습니다. 예제를 통해서 온도 값을 입력 받아보겠습니다.

GPIO control of BPI:bit

GPIO control of BPI:bit
Light Sensor(L)GPIO 36Analog Input
Light Sensor(R)GPIO 39Analog Input
Botton AGPIO 35Digital Input
Botton BGPIO 27Digital Input
Temperature SensorGPIO 34Analog Input
BuzzerGPIO 25PWM(Digital Output) / Analog Output
RGB_LEDGPIO 4Digital Output
MPU9250_SCLGPIO 22Digital Output
MPU9250_SDAGPIO 21Digital Output
MPU9250_INTGPIO 16Digital Input
R_LED(SPI_SCK)GPIO 18Digital Output

예제 소스

// GPIO 핀
#define Temp 34 //ADC2_CH7

// temperature config
const float voltagePower = 3.3;
const float Rs = 5.1; //Sampling Resistance is 5.1K ohm
const int B = 3950;
const double T = 273.15 + 25; //Normal Temperature Parameters
const double R1 = 10; //Normal Temperature Resistance (K ohm)
double Temp_Value = 0;

void setup() {
  Serial.begin(115200); //Serial Port Config 115200-8-N-1
  pinMode(TEMPERATURE_SENSOR, INPUT);//TEMPERATURE_SENSOR(IO34) Input Mode
}

void loop() {
  Temp_Value = analogRead(TEMPERATURE_SENSOR);//Read Analog Value       
  double voltageValue = (Temp_Value / 4095) * 3.3;//
  Serial.print("Current voltage value=");
  Serial.println(voltageValue);
  //Thermistor value
  double Rt = ((voltagePower - voltageValue) * Rs) / voltageValue;
  Serial.print("Current registor value=");
  Serial.println(Rt);
  
  //Temperature value
  Serial.print("Current temperature value=");
  Serial.println(((T * B) / (B + T * log(Rt / R1))) - 273.15);
  Serial.println();
  delay(500);
}

실행 결과

댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함