forked from arduino-libraries/Arduino_LSM6DS3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleTempSensor.ino
46 lines (34 loc) · 943 Bytes
/
SimpleTempSensor.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
Arduino LSM6DS3 - Simple Gyroscope
This example reads the temperature values from the LSM6DS3
sensor and continuously prints them to the Serial Monitor
or Serial Plotter.
The circuit:
- Arduino Uno WiFi Rev 2 or Arduino Nano 33 IoT
created 15 Mar 2020
by Alex Hoppe
This example code is in the public domain.
*/
#include <Arduino_LSM6DS3.h>
void setup() {
Serial.begin(9600);
while (!Serial);
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}
Serial.print("Temperature sensor sample rate = ");
Serial.print(IMU.temperatureSampleRate());
Serial.println(" Hz");
Serial.println();
Serial.println("Temperature reading in degrees C");
Serial.println("T");
}
void loop() {
float t;
if (IMU.temperatureAvailable()) {
// after IMU.readTemperature() returns, t will contain the temperature reading
IMU.readTemperature(t);
Serial.println(t);
}
}