'temperature'에 해당되는 글 6건

  1. 2018.08.06 Hardware | MAX31865 + PT100 온도센서 조합 2
  2. 2017.07.29 Hardware | DS18B20 온도센서 17
  3. 2017.07.12 Hardware | AM2322 Temperature & Humidity Sensor
  4. 2017.03.09 Hardware | BME280 sensor
  5. 2017.03.06 Hardware | Arduino BMP280 고도/온도/기압 센서
  6. 2017.03.05 Hardware | Arduino 비접촉 온도센서 GY-906 MLX90614

Hardware | MAX31865 + PT100 온도센서 조합

|

1. MAX31865


K-Type 온도 센서를 arduino 와 연결하여 측정하는 MAX31855 은 아래 포스팅에서 가지고 놀아 봤습니다.


* Hardware | MAX31855 + K-type 온도센서 조합

http://chocoball.tistory.com/entry/Hardware-MAX31855-Ktype


그 외의 온도센서에 대해서는 아래 포스트들을 참고해보세요.


* Hardware | AM2322 Temperature & Humidity Sensor

http://chocoball.tistory.com/entry/Hardware-AM2322-Temperature-Humidity-Sensor


* Hardware | Arduino 비접촉 온도센서 GY-906 MLX90614

http://chocoball.tistory.com/entry/HardwareArduinoMLX90614


* Hardware | Arduino BMP280 고도/온도/기압 센서

http://chocoball.tistory.com/entry/HardwareArduinoBMP280


* Hardware | BME280 sensor

http://chocoball.tistory.com/entry/HardwareBME280


* Hardware | DS18B20 온도센서

http://chocoball.tistory.com/entry/Hardware-DS18B20-temperature-sensor


여기서 주의할 점은, MAX31865은 MAX31855와 제일 마지막 앞번의 digit 차이 입니다.

주문시 주의해야 합니다.


* MAX31865 : PT100 / PT1000 용

* MAX31855 : K-type 용





2. MAX31865 구입


AliExpress 에서 검색하면 아래의 링크가 가장 많이 구입한걸로 나옵니다.

바로 주문 넣습니다.


* MAX31865 SPI PT100/PT1000 RTD-to-Digital Converter Board Temperature Thermocouple Sensor Amplifier Module For Arduino 3.3V/5V

https://ko.aliexpress.com/item/MAX31865-PT100-PT1000-RTD-to-Digital-Converter-Board-Temperature-Thermocouple-Sensor-Amplifier-BModule-For-Arduino/32777498066.html







3. 도착


다른 센서들보다는 조금 높은 가격입니다.

그러나 업자는 항상 1 USD 미만으로 보내주십니다. :-)



포장은 일반적인 간단한 포장입니다.



Adafruit 제품과 거의 동일하게 만들었습니다.



Chip 을 확대해 봤습니다.

Taiwan 에서 생산된 M31865 라고 인쇄되어 있습니다.



Pin array 와 terminal 을 납땜해 줍니다.

Rref 의 저항은 431 = 430 ohm 입니다.





4. Thermocouple K-Type 구매하기


MAX31865 를 구입하면서, 거의 동시에 온도 센서도 주문에 넣습니다.


* Thermocouple K-Type Thermocouple Thermometer Probe WRNT-03 200mm*1000mm

https://ko.aliexpress.com/item/Thermocouple-K-Type-Thermocouple-Thermometer-Probe-WRNT-03-200mm-1000mm/32615649856.html



분명히 K-Type 이라고 적혀 있습니다.



Probe 형이라 길이가 깁니다. 포장도 큼지막 합니다.



뽁뽁이로 잘 쌓여서 도착했습니다.



음? CU50?



이미 MAX31855 글에서도 CU50 에 대해서 적었습니다.


MAX31865 / MAX31855 의 개념이 없었고, K-Type / PT100 / PT1000 개념도 없이 처음 질렀던 온도계 센서 입니다.

더욱 헷갈리게 된 것은, K-Type 이라고 주문한게 CU50 이 도착해, 처음 한동안은 뭐가 문제인지 몰랐습니다.


그 뒤에 센서 및 coverter chip 종류가 다르다는걸 알았죠.


* CU50 / WRNT-03 spec.

K1118591875.pdf



뭘 모르면 알때까지 삽질해야 하는 것은 인생의 진리 입니다.





5. PT100 구입하기


MAX31865 는 PT100 / PT1000 용 analog to digital converter 입니다.

PT1000 은 예민하면서 실험실용으로 사용되고 있어서, PT100 을 선택합니다.


* MYLB-0-400C PT100 Type 5mm x 50mm Temperature Controller Thermocouple Probe 2 Meters

https://ko.aliexpress.com/item/MYLB-0-400C-PT100-Type-5mm-x-50mm-Temperature-Controller-Thermocouple-Probe-2-Meters/32746546570.html




점점 진실에 접근하는 느낌이 듭니다.



도착.




포장 문제 없슴.

선은 3 wire 센서 이군요.



흠흠.



색이 다른 터미널끼리는 거의 100 ohm 의 차이를 보입니다.

이는 PT100 의 일반적인 현상이며, 더운 여름에 측정하다 보니 저항값이 조금 높습니다.


이 저항값의 변화를 가지고 온도를 측정하는 것입니다.



동일 선끼리는 거의 0 ohm 입니다.





6. Pinout / Layout


Pinout 에 대해서는 아래 Adafruit 의 링크를 참조해 보세요.


* Adafruit MAX31865 RTD PT100 or PT1000 Amplifier

https://learn.adafruit.com/adafruit-max31865-rtd-pt100-amplifier/pinouts


 MAX31865  | Arduino Micro
---------------------------
    Vin    |      3.3V
    GND    |      GND
    CLK    |      D13
    SDO    |      D12
    SDI    |      D11
    CS     |      D10
---------------------------


Layout 입니다.






7. sketch


레퍼런스 소스를 이용해서 기본적인 동작 확인에 들어갑니다.

우선 Library Manager 에서 max31865 를 검색해서 install 해줍니다.



인스톨이 완료되면, "File > Examples > Adafruit MAX31865 library > max31865" 을 선택하여 소스를 로딩합니다.



아래는 sketch 입니다.


/*************************************************** 
  This is a library for the Adafruit PT100/P1000 RTD Sensor w/MAX31865

  Designed specifically to work with the Adafruit RTD Sensor
  ----> https://www.adafruit.com/products/3328

  This sensor uses SPI to communicate, 4 pins are required to  
  interface
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include 

// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31865 max = Adafruit_MAX31865(10, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31865 max = Adafruit_MAX31865(10);

// The value of the Rref resistor. Use 430.0 for PT100 and 4300.0 for PT1000
#define RREF      430.0
// The 'nominal' 0-degrees-C resistance of the sensor
// 100.0 for PT100, 1000.0 for PT1000
#define RNOMINAL  100.0

void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit MAX31865 PT100 Sensor Test!");

  max.begin(MAX31865_3WIRE);  // set to 2WIRE or 4WIRE as necessary
}


void loop() {
  uint16_t rtd = max.readRTD();

  Serial.print("RTD value: "); Serial.println(rtd);
  float ratio = rtd;
  ratio /= 32768;
  Serial.print("Ratio = "); Serial.println(ratio,8);
  Serial.print("Resistance = "); Serial.println(RREF*ratio,8);
  Serial.print("Temperature = "); Serial.println(max.temperature(RNOMINAL, RREF));

  // Check and print any faults
  uint8_t fault = max.readFault();
  if (fault) {
    Serial.print("Fault 0x"); Serial.println(fault, HEX);
    if (fault & MAX31865_FAULT_HIGHTHRESH) {
      Serial.println("RTD High Threshold"); 
    }
    if (fault & MAX31865_FAULT_LOWTHRESH) {
      Serial.println("RTD Low Threshold"); 
    }
    if (fault & MAX31865_FAULT_REFINLOW) {
      Serial.println("REFIN- > 0.85 x Bias"); 
    }
    if (fault & MAX31865_FAULT_REFINHIGH) {
      Serial.println("REFIN- < 0.85 x Bias - FORCE- open"); 
    }
    if (fault & MAX31865_FAULT_RTDINLOW) {
      Serial.println("RTDIN- < 0.85 x Bias - FORCE- open"); 
    }
    if (fault & MAX31865_FAULT_OVUV) {
      Serial.println("Under/Over voltage"); 
    }
    max.clearFault();
  }
  Serial.println();
  delay(1000);
}


결과는 아래와 같습니다.



뭔가 많이 이상하군요... 뭐가 문제일까...





8. Jumper !!!


그렇습니다.

Adafruit 의 점퍼 설정을 대충 읽은 결과 입니다.



위의 글에 나와 있듯이, 미세하게 연결된 24 부분의 선을 잘라줘야 합니다.

시키는 대로 했으나 제대로 되지 않았습니다.


처음에는 CU50 으로 삽질하면서 2 wire 설정으로 납땜 했다가, 납 지워줬다가, 3 wire 설정으로 다시 납땜 했다가,

기판이 지저분해진 상태이고, 자주 인두로 지져서 기판 상태가 엉망으로 되면서 고장난게 분명하다는 결론에 도달했습니다.

(모두 합하면 10시간동안 삽질함)





9. 재구매


breakout 보드값이 비싸지만, 모든걸 다 해본 뒤라 새로운 converter 를 구입하기로 합니다.

이번에는 색이 다른것으로 구입합니다.


배송료 합하면 거의 6천원이군요... ㅠ.ㅠ


* 31865 MAX31865 RTD platinum resistance temperature detector module PT100 to PT1000

https://www.aliexpress.com/item/31865-MAX31865-RTD-platinum-resistance-temperature-detector-module-PT100-to-PT1000/32814557294.html



잘 도착했습니다. 얼른 시험해보고 싶습니다.



점퍼 사시의 간극이 커서 잘 납땜해야 합니다.



Rref 저항은 430 ohm 으로 동일하며, 2 4 사이에 미세하게 연결되어 있는것도 확인했습니다.

커터로 잘 그어서 절단해 줍니다.



두둥!

잘 연결하고 확인해 봅니다.



Aㅏ.....

그렇습니다. 여러 삽질을 하는 동안, 기존 breakout 기판이 고장난 것이었습니다.

그간 삽질하면서 학습한 내용을 토대로 잘 jumper 도 납땜하고, 자를껀 자르고 연결하니 한방에 성공합니다.



애증의 MAX31865 와 PT100 센서 입니다.



찬물 / 상온 물 / 뜨거운 물을 가지고 확인한 동영상 입니다.

calibration 이 필요해 보이지만, 그딴거는 나중에 기회되면 하겠습니다.

여기까지 오는것만 해도 힘들었습니다.



그래프화 시킨 그림입니다.

동작에 무리 없어 보입니다.





FIN


제가 가지고 있는 온도센서 및 converter breakout 보드는 다 확인해 봤네요.

CU50 만 빼고... 이놈은 어떻게 해야 할까요.


And

Hardware | DS18B20 온도센서

|

1. 온도 센서

지금까지 온도센서를 4개 구동시켜 봤습니다.


* Hardware | AM2322 Temperature & Humidity Sensor

http://chocoball.tistory.com/entry/Hardware-AM2322-Temperature-Humidity-Sensor


* Hardware | Arduino 비접촉 온도센서 GY-906 MLX90614

http://chocoball.tistory.com/entry/HardwareArduinoMLX90614


* Hardware | Arduino BMP280 고도/온도/기압 센서

- http://chocoball.tistory.com/entry/HardwareArduinoBMP280


* Hardware | BME280 sensor

- http://chocoball.tistory.com/entry/HardwareBME280


온도라는 것은 생물이 살아가는 지구 환경의 특성을 나타내주는 중요한 바로메터 이기 때문에

시장에는 사용 용도에 따라서 여러 센서가 존재하는 듯 합니다.


이제 5번째 센서를 구동시켜보기로 합니다.




2. 수온 측정용 온도센서

물의 온도를 측정하기 위해서는 방수가 되어야 합니다.

알루미늄 방수캡으로 커버된 온도센서가 "DS18B20" 입니다.


원래는 아래 그림처럼 Dallas사에서 만든 세발달린 칩으로 되어 있습니다.



그것을 알루미늄 캡과 고무로 실링을 한 제품입니다.



데이터쉬트는 다음과 같습니다.


DS18B20.pdf


사양을 보면, 중간에 저항을 넣어줘야 하는 군요.

센서가 타버리지 않게 꼭 저항을 챙기도록 합니다.





3. 주문

오늘도 AliExpress 에서 구매합니다.


https://ko.aliexpress.com/item/1pcs-DS18B20-Stainless-steel-package-1-meters-waterproof-DS18b20-temperature-probe-temperature-sensor/32467815969.html





4. Layout

데이터쉬트에 표기되어 있듯이 "저항"을 꼭 챙기도록 합니다.



Datasheet 를 보면 3~5V 에서 구동한다고 되어 있으므로, Arduino Nano 에서는 3.3V 단자에 연결했습니다.


  DS18B20 | Arduino Nano
------------------------------
   Black  |     GND
    Red   |     3.3V (4.7k Ohms)
   White  |     D2 (4.7k Ohms)
------------------------------


빵판 모습은 다음과 같습니다.



Pullup 저항도 달아 줍니다. 이 pullup 저항이 왜 중요한지는 이 글의 마지막에 적어 놨습니다.

AliExpress 에서 구매한것 치고 4.7k Ohms 는 꽤나 정확하네요.



미지근한 물, 냉장고의 물, 급탕기로 뎁힌 뜨거운 물을 준비합니다.

자, 이제 준비 완료 입니다.







5. IDE Sketch

유명한 센서라서 여러 사이트에서 소개되고 있습니다.


가장 간단한 스케치는 다음과 같습니다.

https://create.arduino.cc/projecthub/TheGadgetBoy/ds18b20-digital-temperature-sensor-and-arduino-9cc806


- OneWire Library : https://github.com/PaulStoffregen/OneWire

- DallasTemperature Library : https://github.com/milesburton/Arduino-Temperature-Control-Library


/********************************************************************/
// First we include the libraries
#include <OneWire.h>
#include <DallasTemperature.h>
/********************************************************************/
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices 
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/********************************************************************/
void setup(void)
{
 // start serial port
 Serial.begin(9600);
 Serial.println("Dallas Temperature IC Control Library Demo");
 // Start up the library
 sensors.begin();
}
void loop(void)
{
 // call sensors.requestTemperatures() to issue a global temperature
 // request to all devices on the bus
/********************************************************************/
 Serial.print(" Requesting temperatures...");
 sensors.requestTemperatures(); // Send the command to get temperature readings
 Serial.println("DONE");
/********************************************************************/
 Serial.print("Temperature is: ");
 Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"? 
   // You can have more than one DS18B20 on the same bus. 
   // 0 refers to the first IC on the wire
   delay(1000);
}



cactus.io 에서 제품 자체의 시리얼 넘버까지 친절하게 보여주는 소스는 다음과 같습니다.

http://cactus.io/hookups/sensors/temperature-humidity/ds18b20/hookup-arduino-to-ds18b20-temperature-sensor


"cactus_io_DS18B20.h" 라이브러리는 다음 링크에서 다운받으면 됩니다.

cactus_io_DS18B20.zip


/* Example sketch for Maxim Integrated DS18B20 temperature sensor Written by cactus.io, and requires the cactus_io_DS18B20 library. This sketch was tested using the Adafruit Prewired DS18B20 Sensor. For hookup details using this sensor then visit http://cactus.io/hookups/sensors/temperature-humidity/ds18b20/hookup-arduino-to-ds18b20-temperature-sensor */ #include <cactus_io_DS18B20.h> int DS18B20_Pin = 2; //DS18S20 Signal pin on digital 2 // Create DS18B20 object DS18B20 ds(DS18B20_Pin); void setup() { ds.readSensor(); Serial.begin(9600); Serial.println("Maxim Integrated DS18B20 Temperature Sensor | cactus.io"); Serial.println("DS18B20 Serial Number: "); // we pass the serial number byte array into the printSerialNumber function printSerialNumber(ds.getSerialNumber()); Serial.println(""); Serial.println(""); Serial.println("Temp (C)\tTemp (F)"); } void loop() { ds.readSensor(); Serial.print(ds.getTemperature_C()); Serial.print(" *C\t"); Serial.print(ds.getTemperature_F()); Serial.println(" *F"); // Add a 2 second delay. delay(2000); } // We call this function to display the DS18B20 serial number. // It takes an array of bytes for printing void printSerialNumber(byte *addr) { byte i; for( i = 0; i < 8; i++) { Serial.print("0x"); if (addr[i] < 16) { Serial.print('0'); } Serial.print(addr[i], HEX); if (i < 7) { Serial.print(", "); } } }




6. 결과

실제로 "실내 공기 > 미지근한 물 > 냉장고의 차가운 물 > 급탕기로 뎁힌 물" 을 차례로 측정한 온도 변화 입니다.



동영상으로도 찍어 봤습니다.



전체 과정은 아래 동영상 입니다.



잘 되네요!




7. 주의

처음에 GND 와 VCC를 서로 바꿔 연결했더니만, 온도센서쪽이 불덩이가 되었습니다.

잠깐 만지기만 해도 손이 데일 정도였으니, 100도이상 순식간에 올라갔던 것 같습니다.


다행이 식힌 다음 제대로 연결했더니 센서 동작에는 문제가 없었습니다.

다른 센서들은 핀 연결을 잘못해도 문제가 생길 여지가 없는데, 이 센서는 왜 pullup 저항을 달아 놓는지 조금 이해가 갈 것 같습니다.




FIN

5개째 온돈세서 구동기였습니다.

더이상 다른 온도 센서는 없겠지?


And

Hardware | AM2322 Temperature & Humidity Sensor

|

1. 온도 센서

온도를 측정할 수 있는 센서는 매우 다양하게 있습니다.

아래 링크들은 지금까지 실험해본 센서들 입니다.


* Hardware | Arduino BMP280 고도/온도/기압 센서

http://chocoball.tistory.com/entry/HardwareArduinoBMP280


* Hardware | BME280 sensor

http://chocoball.tistory.com/entry/HardwareBME280


* Hardware | Arduino 비접촉 온도센서 GY-906 MLX90614

http://chocoball.tistory.com/entry/HardwareArduinoMLX90614



생각보다 온도 센서들이 다양하게 있습니다.

그러던 중 SHT 계얄과 AM 계열이 또 있다는 것을 알게 되었죠.


그럼 어떤게 더 좋을까 찾아 봤습니다.

정확면에서는 AM 계열이 좋다는 글을 어디선가 보았습니다.


각 온도 센서들을 비교한 사이트도 있습니다만, AM 계열은 다루기가 까다롭다는 것을 알 수 있었습니다.

(측정을 위해 연속 측정하지 않고, reset 해야 하는 등)


http://3. - https://www.kandrsmith.org/RJS/Misc/Hygrometers/calib_many.html


그렇다면, 일단 AM2321 을 구입하기로 하고 AliExpress 를 뒤져 봅니다.


옷!!!

새로운 버전인 AM2322가 나와 있네요.


https://ko.aliexpress.com/item/1pcs-AM2321-digital-temperature-and-humidity-sensors-can-replace-SHT21-SHT10-SHT11/32324748233.html



센서 계열에서 3 USD 이상이면 고가에 속합니다.

하지만 구입합니다. 당연히 배송은 무료 입니다.




2. 도착

약 한달 반 정도 걸린것 같습니다.

오래 기다렸네요.


받고 바로 드는 생각은, "작다" 였습니다.




보통 빵판의 핀 사이의 거리가 "2.54 mm" 인데, 이 센서의 다리 간격이 "1.27 mm" 입니다.

연결을 어떻게 해야할지 고민됩니다.


결국 adapter 를 살까 하다가, 주문하고 기다리는 것을 참을 수가 없어 다리를 구부리기로 합니다.

까딱 잘못하다가는 다리가 날라갈 수가 있습니다.


참고로 1.27 to 2.54 어뎁터는 아래 사이트에서 판매합니다. (거의 안파는 듯)


http://www.proto-advantage.com/store/product_info.php?products_id=2700037



향후를 위해서는 꼭 구하고 십지만, 7 USD 입니다. 배보다 배꼽이 더 큰 현실.




3. Spec.

스펙은 아래 datasheet 를 참고하세요.


AM2322_datasheet.pdf


이번 계기로, 중국어 공부에 대해서 심각하게 고민하게 되었습니다.


다행히 AM2320 에 대한 자료나 소스는 많아서, 비슷하다고 생각하고 진행해 봅니다.




4. Layout

Pin 배열은 다음과 같습니다.

판매자 사이트에 설명이 나와 있습니다.


  AM2322 | Arduino Nano
-------------------------
   Pin 1 |     3.3V
   Pin 2 |      A4
   Pin 3 |     GND
   Pin 4 |      A5
-------------------------



보드 구성은 다음과 같아요.



리드선의 피치가 작아서 아래처럼 할수 없이 다리들을 엇갈리게 구부렸습니다.




다리를 서로 간섭이 안생기도록 벌리고, 클립으로 리드선과 연결해 주었습니다.



최종 연결한 모습 입니다.

불안하게 연결되어 있어서 센서와의 통신도 자주 끊겨버리네요.


일단 동작 확인이 우선이므로, 정식으로 프로젝트 한다면 어뎁터가 꼭 있어야겠습니다.







5. Source

소스 코드는 아래 사이트를 참고하였습니다.


http://www.instructables.com/id/Connecting-AM2320-With-Arduino/


#include 
#include 
AM2320 th;

void setup() {
  Serial.begin(9600);
}

void loop() {
  switch(th.Read()) {
    case 2:
      Serial.println("CRC failed");
      break;
    case 1:
      Serial.println("Sensor offline");
      break;
    case 0:
      Serial.print("humidity: ");
      Serial.print(th.h);
      Serial.print("%, temperature: ");
      Serial.print(th.t);
      Serial.println("*C");
      break;
  }

  delay(200);
}


위의 사이트 말고도 여러 사이트를 참고하실 수 있습니다.


https://github.com/hibikiledo/AM2320

https://github.com/Ten04031977/AM2320-master




6. 결과

IDE 의 Sensor Monitor 를 통해 본 결과 입니다.



결과가 잘 나옵니다.

습도가 점점 올라가는 것은, 예상 하셨듯 입김을 불어 넣어준 결과 입니다. 잘 반응하네요.






FIN

어? 또다른 온도 센서가 하나 더 있네 ?!!!



And

Hardware | BME280 sensor

|

1. 시작하기

BMP280 을 구동시키면서 googling 해보면, "Humidity = 습도" 값을 표시해주는 글들이 심심치 않게 보였습니다.

그래서 열씸히 Humidity 를 표현하려고 이리저리 시도해 봤습니다.


또, Aliexpress 에서 구입한 BMP280 제품을 보면 GY-BME/P280 이라고 표시되어 있습니다.

할거 다 해봤습니다.


아니 그런뒈.... 그런뒈! (컬투 버전) 



2. 알아버렸다

그렇습니다. Humidity 를 하려면, 정확하게 BME280 이 있어야 합니다. BMP280 로는 안되는 것이였습니다.

아놔.




나를 깨우쳐준 글.



정말 되냐 안되냐를 확인할 수 있는 글.



3. 넌 누구냐

직접 확인해 봅니다.

SparkFun 이 제공하는 'I2C_ReadAllData.ino' sketch 를 통해서 0x58 이냐, 0x60 이냐를 확인해 봅니다.


SparkFun Library 를 아래 링크를 통해 다운받고 설치합니다.


 - https://github.com/sparkfun/SparkFun_BME280_Arduino_Library


마지막으로 I2C address 를 0x77 > 0x76 으로 바꾸고 실행해 봅니다.



아놔... 넌 BMP280 이구나...



4. BME280 구입

정말 정말 Humidity 수치를 알고 싶습니다.


한꺼번에 구입하지 못 한것을 탓하면서, 다시 주문을 넣습니다.

3주만에 오네요.



2개를 주문해서 앞뒤로 한 샷에 넣어 봅니다.



위의 부분이 센서군요. 보통 Bosch 에서 만든다고 하는데, Bosch 각인은 아닌것 같습니다.




이놈이 진짜 BME280 인지, 바로! 확인해 봅니닷!



오옷! 맞네요.
(정보를 알려준 외국인 친구 감사~!)



5. 구동해 보기

Library 를 다운받아 설치합니다.


 - https://github.com/adafruit/Adafruit_BME280_Library


I2C address 를 0x77 > 0x76 으로 꼭 변경해야 합니다.



이거 수정하지 않고 한참 해멨습니다.



이제 example sketch 를 로딩합니다.



소스는 다음과 같습니다.


/***************************************************************************
  This is a library for the BME280 humidity, temperature & pressure sensor

  Designed specifically to work with the Adafruit BME280 Breakout
  ----> http://www.adafruit.com/products/2650

  These sensors use I2C or SPI to communicate, 2 or 4 pins are required
  to interface. The device's I2C address is either 0x76 or 0x77.

  Adafruit invests time and resources providing this open source code,
  please support Adafruit andopen-source hardware by purchasing products
  from Adafruit!

  Written by Limor Fried & Kevin Townsend for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ***************************************************************************/

#include 
#include 
#include 
#include 

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

unsigned long delayTime;

void setup() {
    Serial.begin(9600);
    Serial.println(F("BME280 test"));

    bool status;
    
    // default settings
    status = bme.begin();
    if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring!");
        while (1);
    }
    
    Serial.println("-- Default Test --");
    delayTime = 1000;

    Serial.println();
}


void loop() { 
    printValues();
    delay(delayTime);
}


void printValues() {
    Serial.print("Temperature = ");
    Serial.print(bme.readTemperature());
    Serial.println(" *C");

    Serial.print("Pressure = ");

    Serial.print(bme.readPressure() / 100.0F);
    Serial.println(" hPa");

    Serial.print("Approx. Altitude = ");
    Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
    Serial.println(" m");

    Serial.print("Humidity = ");
    Serial.print(bme.readHumidity());
    Serial.println(" %");

    Serial.println();
}

layout 은 다음과 같고, pin 구성은 BMP280 과 같이 I2C 연결과 같습니다.


- VIN : 3.3V

- GND : GND

- SCL : A5

- SDA : A4



빵판에 연결합니다.




6. 결과

얏호~!!!

이제 Humidity 를 볼 수 있어요.



더 사용폭이 많은 BME280 만 만들지, 왜 BMP280 을 만드냐고 살짝 울분을 토해봅니다..



FIN

이제 뭘하지?

And

Hardware | Arduino BMP280 고도/온도/기압 센서

|

1. 시작하기

온도, 기압, 고도센서가 하나의 기판에 달려있는, 참 고마원 BMP280 을 가지고 놀아봅니다.

원래는 Adafruit 에서 나온 정식 발매품이 있는 듯 하나, Aliexpress 를 사랑하는 저로서는 clone 품을 가지고 놀아봅니다.





2. Library

2가지 library 를 설치해야 합니다.

- Adafruit Sensor

- Adafruit BMP280


먼저, Adafruit Sensor library 를 설치합니다.

- https://github.com/adafruit/Adafruit_Sensor




그리고, BMP280 용 library 를 다운로드 받아 설치합니다.

     - https://learn.adafruit.com/adafruit-bmp280-barometric-pressure-plus-temperature-sensor-breakout/wiring-and-test




맨 마지막으로, clone 부품을 구동시키기 위해,

"Adafruit_BMP280.h" 파일을, 아래처럼 I2C 어드레스에 대해 0x77 > 0x76 으로 수정해 줘야 합니다.





3. 소스코드

위의 library 를 추가하였으면, "File > Examples > Adafruit BMP280 Library > bmp280test" 를 선택할 수 있습니다.




/***************************************************************************
  This is a library for the BMP280 humidity, temperature & pressure sensor

  Designed specifically to work with the Adafruit BMEP280 Breakout 
  ----> http://www.adafruit.com/products/2651

  These sensors use I2C or SPI to communicate, 2 or 4 pins are required 
  to interface.

  Adafruit invests time and resources providing this open source code,
  please support Adafruit andopen-source hardware by purchasing products
  from Adafruit!

  Written by Limor Fried & Kevin Townsend for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ***************************************************************************/

#include 
#include 
#include 
#include 

#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11 
#define BMP_CS 10

Adafruit_BMP280 bme; // I2C
//Adafruit_BMP280 bme(BMP_CS); // hardware SPI
//Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);

void setup() {
  Serial.begin(9600);
  Serial.println(F("BMP280 test"));
  
  if (!bme.begin()) {  
    Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
    while (1);
  }
}

void loop() {
    Serial.print(F("Temperature = "));
    Serial.print(bme.readTemperature());
    Serial.println(" *C");
    
    Serial.print(F("Pressure = "));
    Serial.print(bme.readPressure());
    Serial.println(" Pa");

    Serial.print(F("Approx altitude = "));
    Serial.print(bme.readAltitude(1013.25)); // this should be adjusted to your local forcase
    Serial.println(" m");
    
    Serial.println();
    delay(2000);
}



4. Layout

PIN 배열은 다음과 같습니다.

- VCC : 3.3v

- GND : GND

- SCL : A5

- SDA : A4







5. 결과

잘 나오네요.

실재로 사용시에는 기준값을 조금 수정해야 할 것 같습니다만, 일단 성공입니다.




6. 확장

아래 링크에서는 OLED 를 사용한 방법을 소개하고 있습니다.


- http://www.instructables.com/id/Standalone-Arduino-Altimeter/


바로 따라해 봅니다.

우선 아래 용도로 사용될 BMP280 library 를 다운로드 받고, libraries 폴더에 위치시킵니다.


BMP280.zip





[BMP280]

----------------------

- VCC : +3.3V

- GND : GND

- SCL : A5

- SDA : A4

- CSB : +3.3V

- SDO : GND


[0.96" I2C IIC Series 128X64 OLED]

----------------------

- SCL : A5

- SDA : A4

- VCC : +3.3V

- GND : GND


#include "U8glib.h"
#include "BMP280.h"
#include "Wire.h"
#define P0 1021.97  //1013.25 
BMP280 bmp;

// OLED Type
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);

char sT[20];
char sP[9];
char sA[9];
char sA_MIN[9];
char sA_MAX[9];
double A_MIN = 0;
double A_MAX = 0;

void draw(double T, double P, double A) {
  u8g.setFont(u8g_font_unifont);

  dtostrf(T, 4, 2, sT);
  dtostrf(P, 4, 2, sP);
  dtostrf(A, 4, 2, sA);

  u8g.drawStr( 5, 10, "Temp: ");
  u8g.drawStr( 5, 30, "Bar : ");
  u8g.drawStr( 5, 50, "Alt : ");
  u8g.drawStr( 50, 10, sT);
  u8g.drawStr( 50, 30, sP);
  u8g.drawStr( 50, 50, sA);
}

void draw2(double A_MIN, double A_MAX) {
  u8g.setFont(u8g_font_unifont);

  dtostrf(A_MIN, 4, 2, sA_MIN);
  dtostrf(A_MAX, 4, 2, sA_MAX);
  u8g.drawStr( 5, 20, "A Min: ");
  u8g.drawStr( 60, 20, sA_MIN);
  u8g.drawStr( 5, 45, "A Max: ");
  u8g.drawStr( 60, 45, sA_MAX);
}

void setup() {
  Serial.begin(9600);
  if (!bmp.begin()) {
    Serial.println("BMP init failed!");
    while (1);
  }
  else Serial.println("BMP init success!");

  bmp.setOversampling(4);

  u8g.setColorIndex(1);
  u8g.setFont(u8g_font_unifont);
}

void loop(void) {
  double T, P;
  char result = bmp.startMeasurment();

  if (result != 0) {
    delay(result);
    result = bmp.getTemperatureAndPressure(T, P);

    if (result != 0) {
      double A = bmp.altitude(P, P0);

      if ( A > A_MAX) {
        A_MAX = A;
      }

      if ( A < A_MIN || A_MIN == 0) {
        A_MIN = A;
      }

      //      Serial.print("T = \t"); Serial.print(T, 2); Serial.print(" degC\t");
      //      Serial.print("P = \t"); Serial.print(P, 2); Serial.print(" mBar\t");
      //      Serial.print("A = \t"); Serial.print(A, 2); Serial.println(" m");

      u8g.firstPage();
      do {
        draw(T, P, A);
      } while ( u8g.nextPage() );
      u8g.firstPage();
      delay(1000);

      do {
        draw2(A_MIN, A_MAX);
      } while ( u8g.nextPage() );
      u8g.firstPage();
      delay(1000);
      
    }
    else {
      Serial.println("Error.");
    }
  }
  else {
    Serial.println("Error.");
  }

  delay(100);

}





값이 잘 바뀌고 있습니다.




FIN

이제 뭘하지?

And

Hardware | Arduino 비접촉 온도센서 GY-906 MLX90614

|

1. 시작하기

오늘은 비접촉 온도센서인 MLX90614 를 가지고 놀아봅니다.


미키마우스같이 생겼네요.


뒷부분에 여러 보조 부품이 같이 실장되어 있어, Arduino 연결 시, 따로 콤포넌트를 추가하지 않아도 됩니다.





2. Library 추가하기

구동하기 위해서는 관련 library 를 추가해야 합니다.


- https://learn.adafruit.com/using-melexis-mlx90614-non-contact-sensors/wiring-and-test




3. 레이아웃

핀 연결은 다음과 같습니다.


- VIN : +3.3V

- GND : GND

- SCL : A5

- SDA : A4






4. 소스

Library 를 설치했으면, File > Example > Adafruit MXL90614 Library > mlxtest 를 가지고 이용할 수 있습니다.



/*************************************************** 
  This is a library example for the MLX90614 Temp Sensor

  Designed specifically to work with the MLX90614 sensors in the
  adafruit shop
  ----> https://www.adafruit.com/products/1748
  ----> https://www.adafruit.com/products/1749

  These sensors use I2C to communicate, 2 pins are required to  
  interface
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include 
#include 

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup() {
  Serial.begin(9600);

  Serial.println("Adafruit MLX90614 test");  

  mlx.begin();  
}

void loop() {
  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC()); 
  Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF()); 
  Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");

  Serial.println();
  delay(500);
}


5. 결과

성공입니다.



다만, 다른 component 와 비교하여 단순히 온도만 내 주는건 좀 아쉽습니다.

특히 BMP280은 온도 외에, 기압, 고도도 나타내 주거든요.



6. 확장

아래 사이트를 보니, OLED 를 이용해서 표시해주는 코드를 발견했습니다.

이제 좀 있어 보이네요.


- http://www.arduinoprojects.net/lcd-projects/mlx90614-and-oled-display-example.php#codesyntax_1


바로 따라해 봅니다.



#include 
#include 
#include 
#include 
#include 
#include 
 
#define OLED_RESET 4
 
Adafruit_SSD1306 display(OLED_RESET);
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
 
//if (SSD1306_LCDHEIGHT != 32)
//error("Height incorrect, please fix Adafruit_SSD1306.h!");
//endif
 
void setup()   
{                
  Serial.begin(57600);
  Serial.println("Adafruit MLX90614 test");  
  mlx.begin();  
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
}
 
 
void loop() 
{
    // Clear the buffer.
  display.clearDisplay();
 
  // text display tests
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.print("Ambient: ");
  display.print(mlx.readAmbientTempC()); 
  display.print(" c");
  display.setCursor(0,10);
  display.print("Object: ");
  display.print(mlx.readObjectTempC()); 
  display.print(" c");
  display.display();
  delay(2000);
  
}

잘 나오네요.

부품 2개를 연결하여 작동시킨 처음 케이스 입니다.



온도 센서 근처에 손가락을 가져가면 온도변화를 화면에 표시해 줍니다.




FIN

이제 뭘하지?

And
prev | 1 | next