Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MLX90640

Mongoose OS driver for the MLX90640 IR Array device.

Introduction

The MLX90640 is a 32x24 infra red array device for measuring temperature without contact. The interface to the device is via an I2C interface.

API

This driver provides a simple interface to the IR device via the I2C interface. After initialisation of the device the getMLX90640FramePtr() function can be called. This returns a pointer to 768 (32x24) float values. Each value contains the temperature in degrees Celsius.

Details

The I2C bus (SCL and SDA) must be connected to the device along with 3V3 and GND. The default I2C address for the MLX90640 device is 0x33. The initialisation of the device is performed automagically as the mongoose framework ensures that the mgos_mlx90640_init() function is called. The parameters passed for initialisation are held in the mos.yml file.

Example Application

mos.yml

The driver uses the Mongoose native I2C bus driver. The SDA and SCL pins must be configured as detailed in the schema below. The I2C bus speed should be set to 400 kbps as shown below as the ESP32 does not currently support fast mode (1 Mbps) although the mlx90640 device does.

config_schema:
 - ["i2c.enable",   "b", true, {title: "Enable I2C"}]
 - ["i2c.sda_gpio", "i", 22, {title: "GPIO to use for SDA"}]
 - ["i2c.scl_gpio", "i", 21, {title: "GPIO to use for SCL"}]
 - ["i2c.freq",     "i", 400000, {title: "I2C bus speed (Hz)"}]
 - ["i2c.unit_no",  "i", 0, {title: "Which hardware unit to use, 0 or 1"}]
 - ["mlx90640.fps", "i", 1,  {title: "The MLX90640 device frames per second configuration."}]

Application

#include "mgos.h"
#include "mgos_mlx90640.h"

static void mlx90640Read_cb(void *arg) {
    int frameBufIndex=0;

    //Read frame from thermal camera
    float *framePtr = getMLX90640FramePtr();

    //Display temperature values (C) on serial debug port
    for( frameBufIndex=0 ; frameBufIndex<MLX90640_FRAME_BUFFER_SIZE ; frameBufIndex++ ) {
      LOG(LL_INFO, ("frameBufIndex[%d]=%.1fC", frameBufIndex, framePtr[frameBufIndex] ));
    }

}

enum mgos_app_init_result mgos_app_init(void) {

  //Every 5 seconds read the MLX90640
  mgos_set_timer(5000, MGOS_TIMER_REPEAT, mlx90640Read_cb, NULL);

  return MGOS_APP_INIT_SUCCESS;
}

About

A driver for the MLX90640 IR Array device.

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages