This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TivaC TM4C123G with BoosterPack

Other Parts Discussed in Thread: ENERGIA

Hi All,

I'm using Energia 11 Wire library to read data from BMP180 pressure sensor. 

Following is extracted code to show how I read data:

=========================================

void BMP180Module::I2CMRead(const uint8_t& addr, const uint8_t& bytes)
{
#if defined(ENERGIA)
Wire.beginTransmission(parameters.ui8Addr);
Wire.write(addr);
Wire.endTransmission(false);
Wire.requestFrom(parameters.ui8Addr, bytes);
while (Wire.available() == 0)
;
parameters.pui8Data[0] = Wire.read();
parameters.pui8Data[1] = Wire.read();
if (bytes == 3)
parameters.pui8Data[2] = Wire.read();
#endif
}

void BMP180Module::cmdI2CMRead(const uint8_t& cmd, const uint8_t& addr, const uint8_t& bytes)
{
#if defined(ENERGIA)
Wire.beginTransmission(parameters.ui8Addr);
Wire.write(BMP180_O_CTRL_MEAS);
Wire.write(cmd);
Wire.endTransmission();
I2CMRead(addr, bytes);
#endif
}

==================================

I read the data using the following commands; and process them

// Temperature
cmdI2CMRead((BMP180_CTRL_MEAS_SCO | BMP180_CTRL_MEAS_TEMPERATURE), BMP180_O_OUT_MSB, 2);

// temperature processing

// This is with no sampling: pressure
cmdI2CMRead((BMP180_CTRL_MEAS_SCO | BMP180_CTRL_MEAS_PRESSURE),
BMP180_O_OUT_MSB, 3);

// pressure processing

I read 2 bytes for temperature and 3 bytes for pressure. 

My question is: when I read temperature and pressure data as above, and approximately compared the raw values to the value we could get from running the pressure_bmp180.bin from TivaC example, the pressure sensor values are quite wrong. If I change the order, then the temperature sensor values are wrong. 

Am I doing something wrong reading the values from Wire? Any help is appreciated.

Thank you! Sam