Initialize the IMU.
IMU.begin()
None.
1 on success, 0 on failure.
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}
- end()
- readAcceleration()
- readGyroscope()
- accelerationAvailable()
- gyroscopeAvailable()
- accelerationSampleRate()
- gyroscopeSampleRate()
De-initialize the IMU.
IMU.end()
None.
None.
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}
// Read IMU data...
// Done with the IMU readings
IMU.end();
- begin()
- readAcceleration()
- readGyroscope()
- accelerationAvailable()
- gyroscopeAvailable()
- accelerationSampleRate()
- gyroscopeSampleRate()
Query the IMU's accelerometer and return the acceleration in g's. The accelerometer is configured with a scale of [-4, +4] g.
IMU.readAcceleration(x,y,z)
- x: float variable where the acceleration value in the IMU's x-axis will be stored.
- y: float variable where the acceleration value in the IMU's y-axis will be stored.
- z: float variable where the acceleration value in the IMU's z-axis will be stored.
1 on success, 0 on failure.
float x, y, z;
if (IMU.accelerationAvailable()) {
IMU.readAcceleration(x, y, z);
Serial.print(x);
Serial.print('\t');
Serial.print(y);
Serial.print('\t');
Serial.println(z);
}
- begin()
- end()
- readGyroscope()
- accelerationAvailable()
- gyroscopeAvailable()
- accelerationSampleRate()
- gyroscopeSampleRate()
Query the IMU's gyroscope and return the angular speed in dps (degrees per second). The gyroscope is configured with a scale of [-2000, +2000] dps.
IMU.readGyroscope(x,y,z)
- x: float variable where the gyroscope value in the IMU's x-axis will be stored.
- y: float variable where the gyroscope value in the IMU's y-axis will be stored.
- z: float variable where the gyroscope value in the IMU's z-axis will be stored.
1 on success, 0 on failure.
float x, y, z;
if (IMU.gyroscopeAvailable()) {
IMU.readGyroscope(x, y, z);
Serial.print(x);
Serial.print('\t');
Serial.print(y);
Serial.print('\t');
Serial.println(z);
}
- begin()
- end()
- readAcceleration()
- accelerationAvailable()
- gyroscopeAvailable()
- accelerationSampleRate()
- gyroscopeSampleRate()
Query if new acceleration data from the IMU is available.
IMU.accelerationAvailable()
None.
0 if no new acceleration data is available, 1 if new acceleration data is available.
float x, y, z;
if (IMU.accelerationAvailable()) {
IMU.readAcceleration(x, y, z);
Serial.print(x);
Serial.print('\t');
Serial.print(y);
Serial.print('\t');
Serial.println(z);
}
- begin()
- end()
- readAcceleration()
- readGyroscope()
- gyroscopeAvailable()
- accelerationSampleRate()
- gyroscopeSampleRate()
Query if new gyroscope data from the IMU is available.
IMU.gyroscopeAvailable()
None.
0 if no new gyroscope data is available, 1 if new gyroscope data is available.
float x, y, z;
if (IMU.gyroscopeAvailable()) {
IMU.readGyroscope(x, y, z);
Serial.print(x);
Serial.print('\t');
Serial.print(y);
Serial.print('\t');
Serial.println(z);
}
- begin()
- end()
- readAcceleration()
- readGyroscope()
- accelerationAvailable()
- accelerationSampleRate()
- gyroscopeSampleRate()
Return the IMU's accelerometer sample rate.
IMU.accelerationSampleRate()
None.
The IMU's accelerometer sample rate in Hz.
Serial.print("Accelerometer sample rate = ");
Serial.print(IMU.accelerationSampleRate());
Serial.println(" Hz");
Serial.println();
Serial.println("Acceleration in g's");
Serial.println("X\tY\tZ");
- begin()
- end()
- readAcceleration()
- readGyroscope()
- accelerationAvailable()
- gyroscopeAvailable()
- gyroscopeSampleRate()
Return the IMU's gyroscope sample rate.
IMU.gyroscopeSampleRate()
None.
The IMU's gyroscope sample rate in Hz.
Serial.print("Gyroscope sample rate = ");
Serial.print(IMU.gyroscopeSampleRate());
Serial.println(" Hz");
Serial.println();
Serial.println("Angular speed in degrees/second");
Serial.println("X\tY\tZ");
- begin()
- end()
- readAcceleration()
- readGyroscope()
- accelerationAvailable()
- gyroscopeAvailable()
- accelerationSampleRate()
Reads the temperature from the sensor (Celsius).
IMU.readTemperature(temperature_deg)
- temperature_deg: int variable where the temperature value will be stored.
None.
if (IMU.temperatureAvailable())
{
int temperature_deg = 0;
IMU.readTemperature(temperature_deg);
Serial.print("LSM6DSOX Temperature = ");
Serial.print(temperature_deg);
Serial.println(" °C");
}
Reads the temperature from the sensor (Celsius).
IMU.readTemperatureFloat(temperature_deg)
- temperature_deg: float variable where the temperature value will be stored.
None.
if (IMU.temperatureAvailable())
{
float temperature_deg = 0.0f;
IMU.readTemperatureFloat(temperature_deg);
Serial.print("LSM6DSOX Temperature = ");
Serial.print(temperature_deg);
Serial.println(" °C");
}
Checks if temperature data is available.
IMU.temperatureAvailable()
None.
1 on success, 0 on failure.
if (IMU.temperatureAvailable())
{
int temperature_deg = 0;
IMU.readTemperature(temperature_deg);
Serial.print("LSM6DSOX Temperature = ");
Serial.print(temperature_deg);
Serial.println(" °C");
}