Having the ability to feel temperature is exciting… However, being able to detect the temperature of an object without any physical contact is truly amazing. The MLX90614 is a sensor with the capability of achieving that. This person can detect temperatures ranging from -95 to 720ºF (-70 to 382.2°C) with a resolution of 17 bits by interpreting the infrared light emitted by an object. This is 128 times more accurate than the Arduino’s ADC, allowing it to distinguish between 25ºC and 25.02ºC without physical contact. Even if we divide 17 bits between -70 and 382, we should still achieve a resolution of 0.0034ºC.
I have been keeping an eye on this guy since I first saw it at Sparkfun, but never had a justification to purchase it. After scanning the area, it appeared that the MLX90614 was causing difficulties for certain individuals attempting to link it to their Arduino. So… at bildr, we did what we do well, we purchased one, and spent time simplifying things to help you get it up and running. This I2C device, the MLX90614, differs from other sensors we’ve discussed. Unlike most I2C sensors, it doesn’t work with the wire library for communication. Instead, we will use a different library. Additionally, it’s not on a breakout board like we are used to, so it needs pull-up resistors on the data and clock lines, which are usually included but unnoticed.
Since the regular wire library didn’t work, we’ll opt for the i2cmaster library. Furthermore, the i2cmaster does not work with the Arduino right away; some files must be modified and renamed, and an additional text file is required for it to operate. However, since it is open-source, I am able to implement those modifications and share it again. I am going to provide you with the working version to save you time and stress. You must place the library in your Arduino library folder for it to function properly, but we will reach that point.
Regarding connecting this, for your Arduino (excluding the mega), the SDA can be found on analog input pin 4, while SCL is on analog pin 5. SDA is digital 20, and SCL is digital 21 on an Arduino mega. Refer to the image for the correct connection instructions, including the need to connect a 4.7KΩ resistor from SDA to 3.3V and another resistor from SCL to 3.3V. I have a .1uf capacitor placed between power and ground as recommended in the data sheet, although some people don’t include it, I have tried removing it and the circuit still functioned.
Code
Therefore, here is the code. I am utilizing bildr’s fancy bildrCode wrapper due to its numerous files. This enables us to have control over multiple files in a project, similar to how a wiki operates. This code simply prints out the temperature in Celsius and Fahrenheit using serial communication. Make sure to launch your serial monitor!
Before you load or open the Arduino program, you must place the “I2Cmaster” in your Arduino Library for the code to function properly. If you are unsure of the default location, turn your gaze towards the right.
After placing the I2CMaster folder, proceed to open MLX90614.pde in your Arduino software to upload it.
Conclusion
This sensor is really amazing, and we hope it saved you some time. Inform us if you interact with this individual so we can potentially showcase it on our blog.
We want you to blog with us
bildr is seeking individuals who are interested in writing a blog post for them. If you are interested in contributing to bildr by writing or have a post idea, please reach out to us at blog@bildr.org or share in the forum.
Read More: MLX90614 IR Thermometer