본문 바로가기

Sensors

BH1750 조도센서

반응형

BH1750 조도센서

 

스펙

동작 전압 : 3v ~ 5v

통신 방식 : I2C

측정 범위 : 1 ~ 65535 lx (룩스)

측정 오차 : +/- 20%

 

 

조도센서 기본 원리

광원의 강도에 따라 저항값이 달라지는 특정으로 밝기를 측정

 

하드웨어 연결

일반적으로 위와 같이 하단면에 각 핀에 대한 설명이 보여집니다 (그렇지 않은 경우는 제조사 정보를 참조하여 주세요)

VCC는 MCU의 5v에  GND는 MCU의 GND에

SCL과 SDA는 각각 MCU의 아날로그 핀에 연결합니다

ADDR의 경우는 I2C통신 방식에 따라 기본적으로 BH1750센서가 갖는 주소가 ADDR에 아무것도 연결되어 있지 않으면 0x23 만약 ADDR을 VCC와 연결하면 0x5c 로 주소값을 갖게됩니다 이 기능은 I2C 버스에 주소값이 같은 센서가 있는경우 회피하기 위해서 사용됩니다

(클릭하면 확대)

 

 

제어

기본적으로 I2C 통신방식을 취하고 있기 때문에 센서 주소로 I2C통신을 진행하며 

 

 

위 DataSheet에 첨부된 그림과 같이 

초기 해상도 설정(00010000 = 0x10 H-resolution mode)에 대한 값을 센서 주소(0100011 = 0x23)로 전달하고 

해당하는 해상도 모드의 측정시간 만큼 기다린뒤에

이후 2바이트의 High Byte와 Low Byte값을 센서 주소에서 읽어오게 됩니다

읽어온 값은 십진수로 바꾼뒤 1.2나누면 Lux값이 도출됩니다

 

오실로스코프로 I2C Read 데이터를 확인하여 보면 아래와 같이 표시됩니다

 

 

아두이노 지원 (ATmega328P)

// 사용자 지원 라이브러리 사용
// https://github.com/PeterEmbedded/BH1750FVI
 
#include <BH1750FVI.h>
 
// 조도센서 설정
uint8_t ADDRESSPIN = 6;
 
// 기본으로 I2C주소는 ADDR LOW로 설정 HIGH : 0x5C / LOW : 0x23
BH1750FVI::eDeviceAddress_t DEVICEADDRESS = BH1750FVI::k_DevAddress_L;
 
// 디바이스 모드로 DataSheet에 언급된 High Resolution Mode에 대한 셋업 부분
// 아래 첨부 참조 
BH1750FVI::eDeviceMode_t DEVICEMODE = BH1750FVI::k_DevModeContHighRes;
 
// 조도센서 인스턴스 생성
BH1750FVI LightSensor(ADDRESSPIN, DEVICEADDRESS, DEVICEMODE);
 
void setup()
{
  // 시리얼 초기화
  Serial.begin(9600);
 
  // 조도센서 초기화
  LightSensor.begin();  
  Serial.println("BH1750 Running...");
}
 
void loop()
{
  // 조도센서 데이터 가져오기
  uint16_t lux = LightSensor.GetLightIntensity();
 
  // 시리얼 출력 
  Serial.print("Light: ");
  Serial.print(lux);
  Serial.println(" lx");
}
BH1750FVI 라이브러리  DataSheet 명시  설명
 k_DevModeContHighRes  Continuously H-Resolution Mode  Start measurement at 1lx resolution.
Measurement Time is typically 120ms.
 k_DevModeContHighRes2  Continuously H-Resolution Mode2  Start measurement at 0.5lx resolution.
Measurement Time is typically 120ms.
 k_DevModeContLowRes  Continuously L-Resolution Mode  Start measurement at 4lx resolution.
Measurement Time is typically 16ms.
 k_DevModeOneTimeHighRes  One Time H-Resolution Mode  Start measurement at 1lx resolution.
Measurement Time is typically 120ms.
It is automatically set to Power Down mode after measurement.
 k_DevModeOneTimeHighRes2  One Time H-Resolution Mode2  Start measurement at 0.5lx resolution.
Measurement Time is typically 120ms.
It is automatically set to Power Down mode after measurement.
 k_DevModeOneTimeLowRes  One Time L-Resolution Mode   Start measurement at 4lx resolution.
Measurement Time is typically 16ms.
It is automatically set to Power Down mode after measurement.

 

H-Resolution Mode (고해상도 모드) : 1 lux 정밀도 / 120ms 측정시간  (측정 범위 : 0.0 ~ 54612.5 Lux)

H-Resolution Mode2 (고해상도 모드 2) : 0.5 lux 정밀도 / 120ms 측정시간 (측정 범위 : 0.0 ~ 54612.5 Lux)

L-Resolution Mode (저해상도 모드) : 4 Lux 정밀도 / 16ms 측정시간 (측정 범위 : 0.0 ~ 최대 27306.25 Lux)

 

One Time 이 붙는 모드는 위와 동일한 측정 정밀도와 시간을 갖으며 측정이 완료되면 절전 모드로 들어가는 특징이 있습니다

절전모드 해제시 기본모드로 진입하며 필요시는 다시 One Time 셋업을 해야 합니다 (절전 모드시에는 0.01uA만 소비합니다)

 

 

데이터시트

bh1750fvi-e-186247.pdf
다운로드

 

 

 

반응형