Snippet Tag: AMS0100D

measure temp and pressure with 0100d

void AMS5915::Measure_PressureAndTemperature(float pMin, float pMax) { uint8_t Pres_Hi, Pres_Low, Temp_Hi, Temp_Low; // pressure and temperature digital output in counts uint16_t pressureCounts, temperatureCounts; uint16_t DigoutPmin = 1638.0; // digital output at minimum specified pressure in counts uint16_t DigoutPmax = 14745.0; // digital output at maximum specified pressure in counts Wire.beginTransmission(ams_i2cAddress); Wire.endTransmission(); Wire.requestFrom(ams_i2cAddress, (uint8_t)4); Pres_Hi = i2cread(); Pres_Low = i2cread(); Temp_Hi = i2cread(); Temp_Low = i2cread(); // Convert the pressure data to 14-bits and then in physical units (mbar) pressureCounts = ((Pres_Hi & 0x3F) << 8) | Pres_Low; pressure = (((float)pressureCounts – DigoutPmin)/((DigoutPmax – DigoutPmin)/(pMax – pMin)) + pMin); // Convert the

Read More »