ESP32 and Infrared Temperature Sensor MLX90614
by Michal Choma in Circuits > Microcontrollers
14617 Views, 2 Favorites, 0 Comments
ESP32 and Infrared Temperature Sensor MLX90614
![MLX90614 temperature sensor](/proxy/?url=https://content.instructables.com/F9F/N3VB/KMGBA96H/F9FN3VBKMGBA96H.jpg&filename=MLX90614 temperature sensor)
During pandemic situation, very useful is infrared thermometer, which detect temperature without touching object - non contact thermometer. Also for electronics is suitable sensor.
BOM
![IMG_20210319_143837.jpg](/proxy/?url=https://content.instructables.com/F3A/FUXU/KMGBA6X6/F3AFUXUKMGBA6X6.jpg&filename=IMG_20210319_143837.jpg)
For testing you will need:
1. ESP32, I use devkit v1.
2. MLX90614 sensor
3. breadboard
4. 4x dupont cables
Wiring
![IMG_20210319_143657.jpg](/proxy/?url=https://content.instructables.com/FIK/GCC3/KMGBA6X4/FIKGCC3KMGBA6X4.jpg&filename=IMG_20210319_143657.jpg)
As sensor use I2C communication, wiring is simple:
MLX90614 - ESP32
VIN - 3.3V (never connect to 5V, because ESP32 use 3.3V logic!)
GND - GND
SCL - GPIO 22 (marked as D22 on board)
SDA - GPIO 21 (marked as D21 on board)
Code
You will need adafruit library, which you can simple find in library manager in Arduino IDE.
Then you can open example (mlxtest). You can get temperature of object and also ambient temperature. Both temperature values can be set in Celsius or Farenheit.
#include <wire.h><Wire.h><br>#include <adafruit_mlx90614.h></adafruit_mlx90614.h></wire.h><Adafruit_MLX90614.h> Adafruit_MLX90614 mlx = Adafruit_MLX90614(); void setup() { Serial.begin(9600); Serial.println("Adafruit MLX90614 test"); mlx.begin(); } void loop() { Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC()); Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C"); Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF()); Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F"); Serial.println(); delay(500); }
Testing
Sensor is good for measure electronics as resistors or chips. Testing temperature of human body is questionable, as temperature depend on distance sensor from object.