Ambient Light 센서 ISL29034를 Arduino에서 제어 (I2C)

ISL229034





데이터 시트



데이터 시트

슬레이브 주소




슬레이브 주소
???



PowerOn




품목
주소
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0


COMMAND-I
0x00
OP7
OP6
OP5
RESERVED
RESERVED
RESERVED
RESERVED
RESERVED



OP7Bit7
OP6Bit6
OP5Bit5
개요


0
0
0
Power-down the device (Default)

0
0
1
The device measures ALS only once every integration cycle. This is the lowest operating mode. (Note 11)

0
1
0
IR once

0
1
1
Reserved (DO NOT USE)

1
0
0
Reserved (DO NOT USE)

1
0
1
Measures ALS continuously

1
1
0
Measures IR continuous

1
1
1
Reserved (DO NOT USE)



arduino
#define ISL29034_POWER_DOWN 0b000
#define ISL29034_ALS_ONLY 0b001
#define ISL29034_ALS_CONTINUOSULY 0b101
#define ISL29034_IR_CONTINUOSULY 0b110

#define ISL29034_COMMAIN_I_REG 0x00

void PowerOn()
{
  writeI2c(ISL29034_COMMAIN_I_REG, ISL29034_ALS_CONTINUOSULY);  
}

구성




품목
주소
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0


COMMAND-II
0x01
RESERVED
RESERVED
RESERVED
RESERVED
RES1
RES0
RANGE1
RANGE0



RANGE1Bit1
RANGE0Bit0
FULL SCALE LUX RANGE


0
0
1,000

0
1
4,000

1
0
16,000

1
1
64,000



RES1Bit3
RES2Bit2
NUMBER OF CLOCK CYCLES
n-BIT ADC


0
0
65,536
16

0
1
4,096
12

1
0
256
8

1
1
16
4



arduino
#define ISL29034_LUX_RANGE_1000 0b00
#define ISL29034_LUX_RANGE_4000 0b01
#define ISL29034_LUX_RANGE_16000 0b10
#define ISL29034_LUX_RANGE_64000 0b11

#define ISL29034_CLOCK_65536 0b0000
#define ISL29034_CLOCk_4096 0b0100
#define ISL29034_CLOCK_256 0b1000
#define ISL29034_CLOCK_16 0b1100

#define ISL29034_COMMAIN_II_REG 0x01

void Configuration()
{
  writeI2c(ISL29034_COMMAIN_II_REG, ISL29034_LUX_RANGE_64000|ISL29034_CLOCK_65536);  
}

Ambient 읽기



arduino
#define ISL29034_DATA 0x02

uint16_t ReadData()
{
  uint16_t ambient;
  uint8_t buffer[2];

  readI2c(ISL29034_DATA, 2, buffer);
  ambient = (((uint16_t)buffer[1])<<8) | (uint16_t)buffer[0];

  return ambient;
}

Lower Interrupt Threshold Registers



ToDo

Upper Interrupt Threshold Registers



ToDo

I2C 액세스 코드



Arduino
#define ISL29034_SLAVE_ADDRESS 0x??

// I2Cへの書き込み
void writeI2c(byte register_addr, byte value) {
  Wire.beginTransmission(ISL29034_SLAVE_ADDRESS);  
  Wire.write(register_addr);         
  Wire.write(value);                 
  Wire.endTransmission();        
}

// I2Cへの読み込み
void readI2c(byte register_addr, int num, byte *buf) {
  Wire.beginTransmission(ISL29034_SLAVE_ADDRESS); 
  Wire.write(register_addr);           
  Wire.endTransmission(false);         

  //Wire.beginTransmission(DEVICE_ADDR); 
  Wire.requestFrom(HTS221_SLAVE_ADDRESS, num);  

  int i = 0;
  while (Wire.available())
  {
    buf[i] = Wire.read(); 
    i++;   
  }
  //Wire.endTransmission();         
}

좋은 웹페이지 즐겨찾기