Skip to content

Commit c5e398f

Browse files
committed
Example to demonstrate how to do a temperature readout.
1 parent 2e7bbe5 commit c5e398f

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
Arduino LSM6DSOX - Simple Temperature
3+
4+
This example reads the temperature values from the LSM6DSOX
5+
sensor and continuously prints them to the Serial Monitor
6+
or Serial Plotter.
7+
8+
The circuit:
9+
- Arduino Nano RP2040 Connect
10+
11+
created 30 August 2021
12+
by Alexander Entinger
13+
14+
This example code is in the public domain.
15+
*/
16+
17+
#include <Arduino_LSM6DSOX.h>
18+
19+
void setup()
20+
{
21+
Serial.begin(9600);
22+
while (!Serial);
23+
24+
if (!IMU.begin())
25+
{
26+
Serial.println("Failed to initialize IMU!");
27+
while (1);
28+
}
29+
}
30+
31+
void loop()
32+
{
33+
if (IMU.temperatureAvailable())
34+
{
35+
int temperature_deg = 0;
36+
IMU.readTemperature(temperature_deg);
37+
38+
Serial.print("LSM6DSOX Temperature = ");
39+
Serial.print(temperature_deg);
40+
Serial.println(" °C");
41+
}
42+
}

0 commit comments

Comments
 (0)