-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIRSensor_Test Script
More file actions
40 lines (30 loc) · 1.1 KB
/
IRSensor_Test Script
File metadata and controls
40 lines (30 loc) · 1.1 KB
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
#include <Wire.h>
#include <Adafruit_MLX90614.h>
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
void setup() {
Serial.begin(115200); // ESPs usually use 115200 baud
while (!Serial); // Wait for Serial Monitor to open
Serial.println("MLX90614 Test - Non-Contact Motor Sensing");
// Initialize I2C with ESP32 default pins (SDA 21, SCL 22)
// If using ESP8266, Wire.begin() defaults to D2/D1
if (!mlx.begin()) {
Serial.println("Error connecting to MLX sensor. Check wiring.");
while (1);
};
Serial.println("Sensor Found!");
}
void loop() {
// Read Ambient Temperature (The air around the sensor)
// float ambientC = mlx.readAmbientTempC();
// float ambientF = mlx.readAmbientTempF();
// Read Object Temperature (The motor surface)
float objectC = mlx.readObjectTempC();
float objectF = mlx.readObjectTempF();
// Print Results
// Serial.print("Ambient: ");
// Serial.print(ambientF); Serial.print("°F | ");
Serial.print("Motor (Object): ");
Serial.print(objectF); Serial.println("°F");
// Delay for readability - 500ms is good for a test stand
delay(500);
}