Arduino Pro Micro and MLX90614 Non-contact Infrared Temperature Sensor
Table of Contents
Arduino Pro Micro and MLX90614:
Arduino Pro Micro and MLX90614 Non-contact Infrared Temperature Sensor– Since I have made my own Arduino Pro Micro, I have been using it with different sensors and breakout boards. And there are two reasons behind it.
- The first reason is that there are very few tutorials available for Arduino Pro Micro, so I want to use it as much as possible to provide some help to those who want to use it.
- The second reason is that I want to check the performance of my designed Arduino Pro Micro when it is used with different analog and digital sensors and breakout boards.
So, it’s going to be a long series where I will be using Arduino Pro Micro with all those sensors, breakout boards, and wireless communication modules which I have been using with Arduino Uno, Arduino Nano, Raspberry Pi Pico, ESP32, ESP8266, and STM32 etc. So, consider subscribing if you don’t want to miss any of my upcoming tutorials.
Anyway, previously I used the Arduino Pro Micro with the PN532 NFC RFID module and it worked tremendously. During the practical demonstration, I also checked it with my designed 5V and 3A Power supply.
If you want to learn how to design a professional PCB in Altium Designer, How to fix design errors in seconds, how to generate Gerber files, How to order cheap yet high-quality PCBs from PCBWay, how to order your SMD components, How to place and solder tiny SMD components, how to burn a bootloader on Arduino Pro Micro. Then you should read my article on the Arduino Pro Micro.
Anyway, today I am going to use the Arduino Pro Micro with the I2C-supported MLX90614 Non-contact Infrared temperature sensor, and the SSD1306 I2C-supported Oled display module.
And I will use my designed 5V and 3A power supply to power up all the electronics. So, without any further delay, let’s get started!!!
Amazon Links:
MLX90614 Non-contact Infrared Temperature Sensor
*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.
Arduino Pro Micro and MLX90614 Circuit:
As I said earlier, the MLX90614 Non-contact infrared temperature sensor and the SSD1306 Oled display module both are I2C supported. So, using only two pins on the Arduino Pro Micro you can connect both the modules. As you can see I have connected the SCL and SDA pins of the MLX90614 and the SSD1306 Oled display to the SCL and SDA pins.
On my Arduino Pro Micro, I have clearly labeled the SCL and SDA pins. And even I have clearly labeled the SS, MOSI, MISO, and SCLK pins. So, this way I don’t have to remember these pins. Anyway, on the readymade Arduino Pro Micro Pin 2 is the SDA and Pin 3 is the SCL.
Connect the voltage and GND pins of both the modules with 3.3V and GND pins of the Arduino Pro Micro.
I am using my 5V and 3A power supply to power up all the electronics. I have connected the 5 volts wire to the RAW pin on the Arduino Pro Micro and the GND wire is connected to the GND pin of the Arduino Pro Micro. I can also use a USB cable. It really doesn’t matter if you don’t have such a power supply. You can even use your Laptop or computer to power up all these components while performing your initial experiments.
And if you think, you need an external power supply to power up your Arduino board and all the other electronics using a 12V adaptor or a 12V battery or a lipo battery pack, or a lithium ion battery pack, or even a solar panel then I highly recommend using a 5V and 3A powers supply. Because with 3A you can power up pretty much all the sensors and the majority of the breakout boards and motors. So, that’s all about the connections. Now, let’s go ahead and take a look at the programming.
Altium Designer + Altium 365 + Octopart:
Altium 365 lets you hold the fastest design reviews ever. Share your designs from anywhere and with anyone with a single click. it’s easy, leave a comment tagging your teammate and they’ll instantly receive an email with a link to the design. Anyone you invite can open the design using a web browser. Using the browser interface, you’re able to comment, markup, cross probe, inspect, and more. Comments are attached directly to the project, making them viewable within Altium designer as well as through the browser interface. Design, share, and manufacture, all in the same space with nothing extra to install or configure. Connect to the platform directly from Altium Designer without changing how you already design electronics. Altium 365 requires no additional licenses and comes included with your subscription plan.
Get real-time component insights as you design with Octopart built into Altium 365. Octopart is the fastest search engine for electronic parts and gives you the most up-to-date part data like specs, datasheets, cad models, and how much the part costs at different amounts etc. Right in the design environment so you can focus on your designs. Start with Altium Designer and Activate Altium 365. Search for electronic parts on Octopart.
Required Libraries:
First of all, we will install the MLX90614 library for this open your Arduino IDE, then go to the Sketch Menu, then to Include Library, and click on Manage Libraries. Wait for a few seconds and when the loading is done; then in the search box type MLX90614 as you can see in the image below.
You will also need the following libraries for the SSD1306 Oled display module.
Arduino Pro Micro and MLX90614 Programming:
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 66 67 68 69 70 71 72 |
#include <DFRobot_MLX90614.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); DFRobot_MLX90614_I2C sensor; // instantiate an object to drive our sensor void setup() { Serial.begin(115200); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); delay(2000); display.clearDisplay(); display.setTextColor(WHITE); // initialize the sensor while( NO_ERR != sensor.begin() ){ Serial.println("Communication with device failed, please check connection"); delay(3000); } Serial.println("Begin ok!"); /** * adjust sensor sleep mode * mode select to enter or exit sleep mode, it's enter sleep mode by default * true is to enter sleep mode * false is to exit sleep mode (automatically exit sleep mode after power down and restart) */ sensor.enterSleepMode(); delay(50); sensor.enterSleepMode(false); delay(200); sensor.setEmissivityCorrectionCoefficient(.98); float ambientTemp = sensor.getAmbientTempCelsius(); float objectTemp = sensor.getObjectTempCelsius(); } void loop() { /** * get ambient temperature, unit is Celsius * return value range: -40 C ~ 85 C */ float ambientTemp = sensor.getAmbientTempCelsius(); /** * get temperature of object 1, unit is Celsius * return value range: -40 C ~ 85 C */ float objectTemp = sensor.getObjectTempCelsius(); // print measured data in Celsius Serial.print("Ambient celsius : "); Serial.print(ambientTemp); Serial.println(" C"); Serial.print("Object celsius : "); Serial.print(objectTemp); Serial.println(" C"); display.clearDisplay(); // display R G B Values display.setTextSize(2); display.setCursor(0,0); display.print("Temp:"); display.setTextSize(3); display.setCursor(0, 28); display.print(objectTemp); display.setTextSize(1); display.setCursor(0, 56); display.print("www.electroniclinic.com"); display.display(); // print measured data in Fahrenheit Serial.print("Ambient fahrenheit : "); Serial.print(ambientTemp*9/5 + 32); Serial.println(" F"); Serial.print("Object fahrenheit : "); Serial.print(objectTemp*9/5 + 32); Serial.println(" F"); delay(1000); } |
This is the same code from my getting started article on the Arduino Nano and MLX90614 temperature sensor. And this code is perfectly compatible with the Arduino Pro Micro. You can clearly see, I am using the same libraries and I didn’t even change a single instruction. I have already uploaded this program and now let’s watch the MLX90614 Non-contact Infrared Temperature sensor and my designed Arduino Pro Micro in action.
Arduino Pro Micro and MLX90614 Testing:
Anyway, before, I am going to start the practical demonstration first, let me tell you about the Emissivity value which is usually ignored by most of the boys and girls and as a result, they would get the wrong temperature values.
As you know very well the MLX90614 is a non-contact infrared temperature sensor and is completely different from those surface-contact based temperature sensors. And you might also know that every object or material has its own emissivity value.
Let’s say you are designing a contactless temperature monitoring system for Covid patients and you ignore the emissivity value of the Human skin then how you are supposed to get an accurate temperature reading?
During my first test, I completely ignored the emissivity value and as a result, I got wrong temperature readings as I was using the standard emissivity value of 1. While in reality, different objects have different emissivity values.
Anyway, I calibrated the MLX90614 Temperature sensor as per the human skin and then I started getting the actual temperature reading. And this way, I built myself the most accurate contactless temperature monitoring system for Covid patients. So, you need to read my getting started article on the MLX90614 and Arduino. So, let’s go ahead and start measuring the temperature.
Practical Demonstration:
I successfully tested it with different objects. I also measured my hand temperature and I also measure the temperature of LED Strip. I recommend you should my video tutorial given below. Don’t forget to like, share, comment, and subscribe; if you have learned something new. So, that’s all for now.
Watch Video Tutorial: