-
Notifications
You must be signed in to change notification settings - Fork 117
/
RAK12003_FIR_MLX90632.ino
64 lines (56 loc) · 1.53 KB
/
RAK12003_FIR_MLX90632.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* @file RAK12003_FIR_MLX90632.ino
* @author rakwireless
* @brief This example shows how to read both the remote object temperature and the local sensor temperature.
* and prints out the temperature data to the Serial console.
* @version 0.1
* @date 2021-01-20
*
* @copyright Copyright (c) 2021
*/
#include <Wire.h>
#include "SparkFun_MLX90632_Arduino_Library.h" // Click here to get the library: http://librarymanager/AllSparkFun_MLX90632_Arduino_Library
#define MLX90632_ADDRESS 0x3A
MLX90632 RAK_TempSensor;
void setup()
{
TwoWire &wirePort = Wire;
MLX90632::status returnError;
time_t timeout = millis();
Serial.begin(115200);
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
Serial.println("MLX90632 Read Example");
Wire.begin(); //I2C init
if (RAK_TempSensor.begin(MLX90632_ADDRESS, wirePort, returnError) == true) //MLX90632 init
{
Serial.println("MLX90632 Init Succeed");
}
else
{
Serial.println("MLX90632 Init Failed");
}
}
void loop()
{
float object_temp = 0;
object_temp = RAK_TempSensor.getObjectTempF(); //Get the temperature of the object we're looking at
Serial.print("Object temperature: ");
Serial.print(object_temp, 2);
Serial.print(" F");
float sensor_temp = 0;
sensor_temp = RAK_TempSensor.getSensorTemp(); //Get the temperature of the sensor
Serial.print(" Sensor temperature: ");
Serial.print(sensor_temp, 2);
Serial.print(" C");
Serial.println();
}