ISL229034
Datasheet
Slave Address
| Slave address | ??? | 
|---|
PowerOn
| 項目 | アドレス | Bit7 | Bit6 | Bit5 | Bit4 | Bit3 | Bit2 | Bit1 | Bit0 | 
|---|---|---|---|---|---|---|---|---|---|
| COMMAND-I | 0x00 | OP7 | OP6 | OP5 | RESERVED | RESERVED | RESERVED | RESERVED | RESERVED | 
| OP7 Bit7  | 
OP6 Bit6  | 
OP5 Bit5  | 
概要 | 
|---|---|---|---|
| 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);  
}
Configuration
| 項目 | アドレス | Bit7 | Bit6 | Bit5 | Bit4 | Bit3 | Bit2 | Bit1 | Bit0 | 
|---|---|---|---|---|---|---|---|---|---|
| COMMAND-II | 0x01 | RESERVED | RESERVED | RESERVED | RESERVED | RES1 | RES0 | RANGE1 | RANGE0 | 
| RANGE1
Bit1 | RANGE0
Bit0 |  FULL SCALE LUX RANGE |
|:-:|:-:|:-:|:--|
| 0 | 0 | 1,000 |
| 0 | 1 | 4,000 |
| 1 | 0 | 16,000 |
| 1 | 1 | 64,000 |
| RES1 Bit3  | 
RES2 Bit2  | 
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();         
}
