/** * Read the MPU interrupt status registers. * @return status Mask of interrupt bits. * @throws RuntimeIOException if an I/O error occurs */ public short mpu_get_int_status() throws RuntimeIOException { if (sensors == 0) { return -1; } // dmp_int_status == 0x39 == MPU9150_RA_DMP_INT_STATUS return i2cDevice.readShort(MPU9150_RA_DMP_INT_STATUS); }
@Override public float getTemperature() throws RuntimeIOException { return device.readShort(TEMPERATURE_REG) / RANGE; }
public int readUShort(int address, int subAddressSize, ByteOrder order) throws RuntimeIOException { return readShort(address, subAddressSize, order) & 0xffff; }
public short readShort(int address) throws RuntimeIOException { return readShort(address, I2CConstants.SUB_ADDRESS_SIZE_1_BYTE, order); }
public short readShort(int address, int subAddressSize) throws RuntimeIOException { return readShort(address, subAddressSize, order); }
/** * Read temperature data directly from the registers. * The scale factor and offset for the temperature sensor are found in the Electrical * Specifications table in the MPU-9150 Product Specification document. * The temperature in degrees C for a given register value may be computed as: * Temperature in degrees C = (TEMP_OUT Register Value as a signed quantity)/340 + 35 * Please note that the math in the above equation is in decimal. * @return Temperature * @throws RuntimeIOException if an I/O error occurs */ public float mpu_get_temperature() throws RuntimeIOException { if (sensors == 0) { return -1; } // temp == 0x41 == MPU9150_RA_TEMP_OUT_H short raw = i2cDevice.readShort(MPU9150_RA_TEMP_OUT_H); //raw = (tmp[0] << 8) | (tmp[1] & 0xff); float val = ((raw - MPU6050_TEMP_OFFSET) / (float)MPU6050_TEMP_SENS) + 35; return val; }
@Override public float getRelativeHumidity() { byte status = device.readByte(STATUS_REG); if ((status & SR_H_DA) == 0) { Logger.warn("Humidity data not available"); return -1; } // Read raw humidity short humidity_raw = device.readShort(HUMIDITY_OUT | READ); return (h1Rh - h0Rh) * (humidity_raw - h0T0Out) / (h1T0Out - h0T0Out) + h0Rh; }
@Override public float getTemperature() { byte status = device.readByte(STATUS_REG); if ((status & SR_T_DA) == 0) { Logger.warn("Temperature data not available"); return -1; } short raw_temp = device.readShort(TEMP_OUT_L | READ); return (float) (raw_temp / 480.0 + 42.5); }
/** * Get temperature (degrees C). * @return Temperature in degrees C. */ @Override public float getTemperature() { byte status = device.readByte(STATUS_REG); if ((status & SR_T_DA) == 0) { Logger.warn("Temperature data not available"); return -1; } // Read raw temperature int temp_raw = device.readShort(TEMP_OUT | READ); return (t1DegC - t0DegC) * (temp_raw - t0Out) / (t1Out - t0Out) + t0DegC; }