Reply
Highlighted
Posts: 1
Registered: ‎06-04-2014

Issue in getting UV Index from SI1145. I have followed the data sheet page #16

Hi,

 

I have just followed documentation from the data sheet page #16.

 

To enable UV reading, set the EN_UV bit in CHLIST, and configure UCOEF [3:0] to the default values of 0x29, 0x89, 0x02, and 0x00.

 

After this, I keep reading the AUX_DATA, but all the time value is 0 for AUX_DATA. Please suggest. Do I need to set it in "Forced Conversion Mode" or "Autonomous Mode"? I guess mode does not matter for UV.

 

I have downloaded the sample code as recommended in the document. I am interested only in the UV values. Please suggest if I need to do anything else apart from the above.

 

Here is my code:

uint8 configureSI1145(){
//  uint8 retValues [10] = {0};

/*  
  retValues[0] = SI1145_readRegister(0x00, 1);
  retValues[1] = SI1145_readRegister(0x01, 1);
  retValues[2] = SI1145_readRegister(0x02, 1);
  retValues[3] = SI1145_readRegister(0x03, 1);
*/
 
//  retValues[4] = SI1145_readRegister(PARAM_WR, 1);
  SI1145_writeRegister(PARAM_WR, 1, 0x80);
  SI1145_writeRegister(COMMAND, 1, PARAM_SET | CHLIST);
  SI1145_writeRegister(COMMAND, 1, PARAM_QUERY | CHLIST);
 
  SI1145_writeRegister(UCOEF0, 1, 0x13); // 0x00
  SI1145_writeRegister(UCOEF1, 1, 0x14); // 0x02
  SI1145_writeRegister(UCOEF2, 1, 0x15); // 0x89
  SI1145_writeRegister(UCOEF3, 1, 0x16); // 0x29
 
//  retValues[5] = SI1145_readRegister(PARAM_RD, 1);
//  retValues[6] = SI1145_readRegister(PARAM_WR, 1);
 
//  _CC2541_UART_PRINT("retValues = %0x, %0x, 0x", retValues[4], retValues[5], retValues[6]);
 
  return 0;
}
   
/*******************************************************************************
 * @fn         configureSI1145
 *
 * @brief      Checks the Device ID (0xCA)
 *             Configures SI1145 to 1Hz continues outputReads UV Index from SI1145
 *
 * @return     uint16 UV Index
 *******************************************************************************
*/
uint16 getUVIndex_SI1145(){
  uint8 retValues [2] = {0};
  uint16 uvIndex = 0;
//  float uvIndexConverted = 0;

  retValues[0] = SI1145_readRegister(AUX_DATA0, 1);
  retValues[1] = SI1145_readRegister(AUX_DATA1, 1);
 
  uvIndex = (retValues[1] << 8) | retValues[0];
//  uvIndexConverted = uvIndex / 100.0;
 
  return uvIndex;
}

uint8 SI1145_readRegister(uint8 register_addr, uint8 numBytes) {
  uint8 ret = 0;
  uint8 pBuff[3] = {0};
  HalI2CInit(SI1145_SLAVE_ADDRESS, i2cClock_267KHZ);  
 
  /* issue Temperature command with no hold */
  pBuff[0] = register_addr;
  ret  = HalI2CWrite(1, pBuff);
  if(ret != 1){
#ifndef RELEASE    
    _CC2541_PRINT("SHT25 I2C Temperature command write failed\n");
#endif    
    return 0xff;
  }

  ret = HalI2CRead(1, pBuff);
  if(ret != 1){
#ifndef RELEASE    
    _CC2541_PRINT("SHT25 I2C Temperature command write failed\n");
#endif    
  }
 
  return pBuff[0];
}

uint8 SI1145_writeRegister(uint8 register_addr, uint8 numBytes, uint8 data) {
  uint8 ret = 0;
  uint8 pBuff[3] = {0};
  HalI2CInit(SI1145_SLAVE_ADDRESS, i2cClock_267KHZ);  
 
  /* issue Temperature command with no hold */
  pBuff[0] = register_addr;
  pBuff[1] = data;
  ret  = HalI2CWrite(2, pBuff);
  if(ret != 2){
#ifndef RELEASE    
    _CC2541_PRINT("SHT25 I2C Temperature command write failed\n");
#endif    
    return 0xff;
  }
 
  return ret;
}

 

 

Thanks

GD

Posts: 332
Registered: ‎09-22-2009

Re: Issue in getting UV Index from SI1145. I have followed the data sheet page #16

For the initialization of the part, I recommend you use the UV Index's example initialization in its entirety. The ALS VIS and ALS IR measurements are components of the UV index AUX measurement. The ALS measurements need to be configured properly for the UV to work.