-
Notifications
You must be signed in to change notification settings - Fork 0
/
BastWAN_GY-906_Get_Temperature.ino
65 lines (56 loc) · 2.33 KB
/
BastWAN_GY-906_Get_Temperature.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
65
/******************************************************************************
MLX90614_Serial_Demo.ino
Serial output example for the MLX90614 Infrared Thermometer
This example reads from the MLX90614 and prints out ambient and object
temperatures every half-second or so. Open the serial monitor and set the
baud rate to 9600.
Hardware Hookup (if you're not using the eval board):
MLX90614 ------------- Arduino
VDD ------------------ 3.3V
VSS ------------------ GND
SDA ------------------ SDA (A4 on older boards)
SCL ------------------ SCL (A5 on older boards)
An LED can be attached to pin 8 to monitor for any read errors.
Jim Lindblom @ SparkFun Electronics
October 23, 2015
https://github.com/sparkfun/SparkFun_MLX90614_Arduino_Library
Development environment specifics:
Arduino 1.6.5
SparkFun IR Thermometer Evaluation Board - MLX90614
******************************************************************************/
#include <Wire.h> // I2C library, required for MLX90614
#include <SparkFunMLX90614.h> //Click here to get the library: http://librarymanager/All#Qwiic_IR_Thermometer by SparkFun
IRTherm therm; // Create an IRTherm object to interact with throughout
void setup() {
Serial.begin(115200);
Serial.flush();
delay(3000);
Serial.println("\n\nMLX90614 test...");
Wire.begin();
if (therm.begin() == false) {
// Initialize thermal IR sensor
Serial.println("Qwiic IR thermometer did not acknowledge! Freezing!");
while (1);
}
Serial.println("Qwiic IR Thermometer acknowledged. Good to go!");
therm.setUnit(TEMP_C); // Set the library's units to Farenheit
// Alternatively, TEMP_F for Fahrenheit or TEMP_K for Kelvin.
pinMode(LED_BUILTIN, OUTPUT); // LED pin as output
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
// Call therm.read() to read object and ambient temperatures from the sensor.
if (therm.read()) {
// On success, read() will return 1, on fail 0.
// Use the object() and ambient() functions to grab the object and ambient
// temperatures.
// They'll be floats, calculated out to the unit you set with setUnit().
Serial.print("Object: " + String(therm.object(), 2));
Serial.println(" C");
Serial.print("Ambient: " + String(therm.ambient(), 2));
Serial.println(" C");
Serial.println();
}
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}