element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Photography
  • Challenges & Projects
  • Project14
  • Photography
  • More
  • Cancel
Photography
Blog MLX90640 IR Thermal Camera
  • Blog
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Photography to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fmilburn
  • Date Created: 14 Jul 2021 4:20 AM Date Created
  • Views 10976 views
  • Likes 16 likes
  • Comments 19 comments
  • melexis
  • photographych
  • infrared
  • edge badge
  • thermal
  • camera
  • ir
  • project14
  • thermal camera
  • mlx90640
  • circuit python
  • 3d print
Related
Recommended

MLX90640 IR Thermal Camera

fmilburn
fmilburn
14 Jul 2021
image

Photography                                               Submit an EntrySubmit an Entry

 

Monthly Themes   | Monthly Poll   |  Back to homepage image

 

I've been intrigued by thermal cameras for some time and decided to experiment with the MLX90640 IR Camera from Melexis.  Anxious to get started I soldered some 4-wire flat telephone cable between it and an Adafruit development board with a display handed out at a conference I attended.  In the image below I'm measuring my cup of tea under the watchful eye of Bender to ensure it is at the proper temperature.  Unfortunately, it took so long to set up the photo that the tea has cooled off to an unacceptable level.

image

And that teabag was left steeping in the cup too long.  Enough about the tea, let's do some research on the sensor and turn it into a real project.

 

Background

 

My original intention was to use a Raspberry Pi Zero W as the brains.  In addition to the MLX90640, there would also have a Pi camera which would allow the thermal image to be overlaid on top of a camera image.  For the camera body, I considered Lego as well as 3D prints.  But I procrastinated on ordering and only received the MLX90640 a few days ago.  Knowing I wouldn't have time to write much software or do the mechanical design I settled on using an Adafruit "Edge Badge" handed out at a conference I attended.   There is a nice write-up by Adafruit on using this sensor with a similar board.  By luck, I also found a 3D model that met most of my needs for the camera body.

 

MLX90640 Features and Usage

 

The MLX90640 allows relatively high precision non-contact temperature measurement with a 32x24 pixel sensor.  Uses include presence/movement detection, thermal comfort, temperature control, insulation efficiency, and determining if your hot beverage is at the right temperature.

 

Among the features are:

  • 32x24 pixels IR array
  • Easy to solder four lead TO39 package
  • I 2 C compatible digital interface
  • Programmable refresh rate 0.5Hz…64Hz
  • 3.3V supply voltage
  • Current consumption less than 23mA
  • Two field of view options – 55°x35° and 110°x75°
  • Target temperature from -40°C to 300°C

 

The datasheet reports an initial factory set accuracy for temperatures in the range of 0°C to 100°C to be ± 1.5°C in the center portion of the sensor.  The sensor has the lowest noise at refresh rates of 1Hz and becomes noisier with higher refresh rates.

 

Melexis provides a well-written datasheet and C++ code for using the sensor.  They also have several videos describing the product and its use.

 

The MLX90640 sells in small quantities for around $50.  The circuit is simple and as noted above the sensor comes in a TO-39 package that would be easy to hand solder.

image

Credit:  Melexis MLX90640 32x24 IR Array Datasheet

 

Newark doesn't stock the individual components but they do sell an Adafruit MLX9640MLX9640 breakout board for the reasonable price of $60 and that is what I am using.  I got mine using winnings from a Project14 basket. The Adafruit board adds an LDO, power LED, and STEMMA headers to the circuit above.

 

Project Wiring

 

As seen in the schematic from Melexis, there isn't much to the wiring.  In addition to the circuitry on the Adafruit breakout, the Edge Badge has circuitry for charging and controlling a LiPo battery.  Since I didn't have a STEMMA cable I wired up a daughterboard on the back of the Edge Board for the power, ground, SDA, and SCL connections.  It would be much easier to use a pre-built cable.  Links to the Adafruit wiring diagram are given at the bottom of this post.

 

Code

 

The Circuit Python code used has only minimal changes from the Adafruit examples.  Do note that the Adafruit code won't run as written however because it attempts to get the map_range function from the simpleio library.  Apparently, this function was moved from simpleio to simplemath at some point.  Adafruit hasn't yet updated its code or the documentation for simpleio.  Links to the Adafruit code are given at the bottom of this post.

 

3D Model

 

The 3D model also originated from Adafruit and can be downloaded in various formats. 

image

This is a very nice model and I picked up a couple of ideas from it for the future.  I removed the stand-offs in the original design and mounted the sensor board to the camera directly.  The posts on the camera mount were then extended which gave sufficient room for the daughterboard as well as proper placement of the sensor.  Given more time there are several additional changes I'd consider:

  • Faux lens body for the sensor with lens cap like the version linked at the bottom
  • Larger posts with threaded screw inserts
  • Separate side plates for aesthetic reasons
  • Screw on top and bottom for easier removal

 

In a fit of whimsy, I elected to print it in non-traditional colors :-).  Links to Adafruit design files are given at the bottom of this post.

 

Assembly

 

Assembly was straightforward.  I cut off the flat telephone cable due to a lack of room and wired the daughterboard directly to the sensor breakout.  The back plate didn't quite fit my Edge Badge so I took a file to it.  I had some trouble printing the top plate and had to restart the print.  The problem arose due to the need for a small support that could be removed with a small design change.  As seen below the parts count is low.

image

 

The slides below show the microcontroller and sensor, view with the top removed, and the front and back of the camera.

 

{gallery} My Gallery Title

image

Board and MLX90640 IR Thermal Sensor

REPLACE THIS TEXT WITH YOUR IMAGEimage

Assembled Camera with Top Off

image

Competed Camera from Back

image

Completed Camera from Front

 

Testing the Camera

 

OK, here is the first test.  I can see my hand!

image

The camera reports that the warmest part of my hand is 36°C.

 

The two-minute video below demonstrates the camera detecting a person, measuring the temperature of ice water, boiling water, and a lightly loaded Raspberry Pi 3.  As a bonus, it makes a determination on whether or not Bender is cold-hearted.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Realize that some of the tests weren't that well-conceived.  For example, the camera could have been picking up the pan in the boiling water test which showed higher temperatures near the end of the clip.

 

Summary

 

The small 32x24 pixel matrix gives better results than I thought it would.  The sensor generally gives useable results but was off by as much as 4°C or so in some cases.  Realize that my test procedure was not very scientific but it is indicative.

 

I liked the overall case design but as noted above there are several aesthetic changes and some mechanical changes I would make if redoing the project.  Thanks for reading and as always comments and suggestions are welcome.

 

Links

CircuitPython Code

Wiring Diagram

3D Files - These files differ from what I made but fit a development board that is easier to obtain

  • Sign in to reply

Top Comments

  • fmilburn
    fmilburn over 4 years ago in reply to dubbie +7
    The mini-panther approaches the upside-down thermal camera as I try to get everything in the shot with my iPhone in the other hand. Thermal closeup of a moving cat I leave the hard work of creating environmentally…
  • fmilburn
    fmilburn over 4 years ago in reply to dubbie +7
    I had to look it up but the core temperature of a house cat is a bit over 38C. The max temperature showing on the scale of the camera is 32C which appears to correspond as you point out to the eyes. The…
  • beacon_dave
    beacon_dave over 4 years ago in reply to dubbie +7
    "...It seems unlikely that a cat will cover itself in anything! especially not mud..." You've obviously not met my neighbour's cats then...
Parents
  • dubbie
    dubbie over 4 years ago

    Frank,

     

    Premature tea cooling is a serious problem - well it is to me anyway. Speaking of which, I think it's time for a coffee: just as a special treat!

     

    Dubbie

     

    PS I really liked this concept. Could be something for Cat Detector Mark V

    • Cancel
    • Vote Up +5 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fmilburn
    fmilburn over 4 years ago in reply to dubbie

    The mini-panther approaches the upside-down thermal camera as I try to get everything in the shot with my iPhone in the other hand.


    Thermal closeup of a moving catimageimage

    I leave the hard work of creating environmentally protected electronics and capturing an image of a cat in the wild to you :-)

    • Cancel
    • Vote Up +7 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dubbie
    dubbie over 4 years ago in reply to fmilburn

    Frank,

     

    From the picture it looks like the cats eyes are warmer than the rest of the body. Do you know by how much? Is it just that the fur insulates the body? It does look relatively invisible thermally.

     

    Dubbie

    • Cancel
    • Vote Up +5 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fmilburn
    fmilburn over 4 years ago in reply to dubbie

    I had to look it up but the core temperature of a house cat is a bit over 38C. The max temperature showing on the scale of the camera is 32C which appears to correspond as you point out to the eyes. The cat is moving which blurs things and there is surface cooling so this seems fairly reasonable.  The fur does insulate but the shape was quite visible when I was taking the pictures. According to the camera the house temperature is around 24C.  The body of the cat is somewhere between 24C and 32C.

     

    I speculate that if the difference between the surface of the cat and ambient temperature are close then it would be more difficult to make a detection.  If I remember correctly, Arnold Schwarzenegger used this trick in Predator and covered himself in mud to hide from the alien :-)

    • Cancel
    • Vote Up +7 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • fmilburn
    fmilburn over 4 years ago in reply to dubbie

    I had to look it up but the core temperature of a house cat is a bit over 38C. The max temperature showing on the scale of the camera is 32C which appears to correspond as you point out to the eyes. The cat is moving which blurs things and there is surface cooling so this seems fairly reasonable.  The fur does insulate but the shape was quite visible when I was taking the pictures. According to the camera the house temperature is around 24C.  The body of the cat is somewhere between 24C and 32C.

     

    I speculate that if the difference between the surface of the cat and ambient temperature are close then it would be more difficult to make a detection.  If I remember correctly, Arnold Schwarzenegger used this trick in Predator and covered himself in mud to hide from the alien :-)

    • Cancel
    • Vote Up +7 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • dubbie
    dubbie over 4 years ago in reply to fmilburn

    Frank,

     

    It seems unlikely that a cat will cover itself in anything! especially not mud. It might be worth a try outside at night when the temperature differential should be larger. All I need is a thermal camera kit.

     

    Dubbie

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave over 4 years ago in reply to dubbie

    "...It seems unlikely that a cat will cover itself in anything! especially not mud..."

     

    You've obviously not met my neighbour's cats then...

    image

    • Cancel
    • Vote Up +7 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube