Hello everyone,
I am trying to measure pressure using a couple Honeywell sensors. I have 3 i2c pressure sensors, which all have the same address. There is a mux allowing communication with all 3 sensors. Every time I print pressure data I get a random hex value. Converting the value, the returned value isn't the expected value. The returned hex value is 0x8523 = 34083 in decimal.
This is the function that reads the raw data from the pressure sensors and returns a raw pressure value
uint32_t i2cReadHWPressureTemp(uint8_t channel) { uint8_t c_cmd_data[1] = {channel}; *((uint32_t*)pressure_data) = 0xFFFFFFFFU; I2C_Master_WriteReg(0xF0, 0x01, c_cmd_data, 1); I2C_Master_ReadData(0x28, pressure_data, 4); return *((uint32_t*)pressure_data);
This is the part of the code that is reading from the function. It is turning the raw data into pressure and temperature data.
static uint8_t Press[PRESSURE_NUM_BYTES] = {0xFFU, 0xFFU, 0xFFU, 0xFFU}; uint32_t bridge_data; uint32_t pressure; uint32_t temp_data; uint32_t temperature; case sensors: *((uint32_t*)Press) = i2cReadHWPressureTemp(4); bridge_data = (((uint32_t)Press[0] & ~STATUS_MASK) << 8) | (uint32_t)Press[1]; pressure = ((bridge_data - OUTPUT_MIN)*(PRESSURE_MAX_001BA - PRESSURE_MIN_001BA))/ (OUTPUT_MAX - OUTPUT_MIN) + PRESSURE_MIN_001BA; temp_data = ((uint32_t)(Press[2]) << 8) | ((uint32_t)(Press[3] >> 5)); temperature = ((temp_data*0.0977) - 50); SendSignedHexNumStr(pressure, 4, false); break;
My issue is that bridge_data always comes out to be 0, which means the the list Press[PRESURE_NUM_BYTES] is an empty list even when it is filled by the function i2cReadHWPressureTemp. I need help figuring out how to fill the list.
I hope this is clear.
Thank you