Has anyone had any success using the SI Labs Temperature and Humidity Sensors?
I am unable to read the sensor reliably. There is a CRC check function that is validating the 1st, 3rd and 5th reads when I have a CyDelay(1), but nothing else. Without the delay (as shown below) the first read is valid, but no others. I have tried changing the delays up to 1000 with no difference.
//Request a humidity reading
I2C_1_I2CMasterWriteByte(MEASURE_RH_NOHOLD); // Register to write at.
//Hang out while measurement is taken.
uint8 msb, lsb, checksum;
msb = I2C_1_I2CMasterReadByte(I2C_1_I2C_ACK_DATA);
lsb = I2C_1_I2CMasterReadByte(I2C_1_I2C_ACK_DATA);
checksum = I2C_1_I2CMasterReadByte(I2C_1_I2C_ACK_DATA);
uint16 rawHumidity = ((unsigned int) msb << 8) | (unsigned int) lsb;
if(SI7013_check_crc(rawHumidity, checksum) != 0) return(999); //Error out
//sensorStatus = rawHumidity & 0x0003; //Grab only the right two bits
rawHumidity &= 0xFFFC; //Zero out the status bits but keep them in place
//Given the raw humidity data, calculate the actual relative humidity
float tempRH = rawHumidity / (float)65536; //2^16 = 65536
float rh = -6 + (125 * tempRH); //From page 14
I am hoping that I am just doing something stupid here.
Parts are on a custom PCB. I2C traces are VERY close to matched. I am using the original library on an arduino connected to the sensor via a cable and it works fine. So it isn't the sensor.
I have attached the Project. I am using Creator 4.1 Update 1.