Stufin
Home Quick Cart Profile

M5 StickC Thermal Camera Hat (MLX90640)

Buy Now on Stufin

Thermal Imaging

Capture thermal images for predictive maintenance, quality control, and surveillance.

Temperature Measurement

Measure temperatures ranging from -40C to 300C with an accuracy of 1.5C.

I2C CommunicationCommunicate with the M5 StickC microcontroller via the I2C protocol, allowing for seamless integration and data transfer.

Key Features

--------------

High-Precision Thermal SensorThe MLX90640 thermal sensor provides accurate temperature measurements and thermal images.

Compact Design

The hat's compact size (18mm x 18mm) makes it suitable for integration into small-scale projects and applications.

Low Power Consumption

The module operates at a low voltage (3.3V) and consumes minimal power, making it ideal for battery-powered devices.

Easy Integration

The hat is specifically designed for use with the M5 StickC microcontroller, simplifying the integration process and reducing development time.

RoHS-CompliantThe module complies with the Restriction of Hazardous Substances (RoHS) directive, ensuring environmental sustainability.

Technical Specifications

---------------------------

Sensor Type

MLX90640 thermal sensor

Resolution

32x24 pixels

Temperature Range

-40C to 300C

Accuracy

1.5C

Communication Protocol

I2C

Voltage

3.3V

Current

10mA (typical)

Operating Frequency

100kHz (I2C clock frequency)

Dimensions

18mm x 18mm

Weight

2g (approx.)

Applications

--------------

The M5 StickC Thermal Camera Hat (MLX90640) is suitable for a variety of applications, including

Temperature Monitoring

Monitor temperatures in industrial, automotive, and healthcare applications.

IoT Projects

Integrate with IoT devices for remote temperature monitoring and thermal imaging.

Robotics

Use in robotics applications for thermal imaging and temperature sensing.

By combining the M5 StickC Thermal Camera Hat (MLX90640) with the M5 StickC microcontroller, developers can create innovative, IoT-based thermal imaging solutions with ease.

Pin Configuration

  • M5 StickC Thermal Camera Hat (MLX90640) Pinout Explanation
  • The M5 StickC Thermal Camera Hat (MLX90640) is a compact thermal imaging module designed for IoT applications. It features a 32x24 thermal sensor array and communicates with the host board via I2C protocol. Here's a detailed explanation of each pin on the module:
  • Pinout Structure:
  • The M5 StickC Thermal Camera Hat has a total of 8 pins, arranged in two rows of 4 pins each. The pinout structure is as follows:
  • Row 1:
  • 1. VCC (Power Supply): 3.3V power supply input. Connect to a 3.3V power source on your host board.
  • 2. GND (Ground): Ground connection. Connect to the ground pin on your host board.
  • 3. SCL (I2C Clock): I2C clock signal. Connect to the I2C clock pin on your host board.
  • 4. SDA (I2C Data): I2C data signal. Connect to the I2C data pin on your host board.
  • Row 2:
  • 1. VIN (Power Input): Optional power input pin. Can be used to power the module from a battery or an external power source.
  • 2. INT (Interrupt): Interrupt pin. Can be used to notify the host board when new thermal data is available.
  • 3. RST (Reset): Reset pin. Can be used to reset the module.
  • 4. NC (Not Connected): Not connected. Do not connect anything to this pin.
  • Connection Guidelines:
  • When connecting the M5 StickC Thermal Camera Hat to your host board, ensure the following:
  • VCC (Pin 1) connects to a 3.3V power supply pin on your host board.
  • GND (Pin 2) connects to a ground pin on your host board.
  • SCL (Pin 3) connects to the I2C clock pin on your host board.
  • SDA (Pin 4) connects to the I2C data pin on your host board.
  • VIN (Pin 5) can be connected to a power source (optional) or left unconnected if using the on-board power regulator.
  • INT (Pin 6) can be connected to an interrupt pin on your host board (optional).
  • RST (Pin 7) can be connected to a reset pin on your host board (optional).
  • NC (Pin 8) should not be connected.
  • Important Notes:
  • Ensure the power supply voltage is 3.3V, as the module is not 5V tolerant.
  • Use a level shifter or voltage divider if your host board's I2C bus operates at a different voltage level.
  • Consult the datasheet and documentation for your host board to determine the correct I2C pin connections.
  • The MLX90640 thermal sensor array requires careful handling to avoid damage. Avoid touching the sensor array or exposing it to direct sunlight.

Code Examples

M5 StickC Thermal Camera Hat (MLX90640) Documentation
Overview
The M5 StickC Thermal Camera Hat is a thermographic camera module based on the MLX90640 sensor, designed for thermal imaging applications. It is a compact, low-power consumption device that can be easily integrated with the M5 StickC microcontroller board. This module provides high-resolution thermal images, making it suitable for various IoT applications, such as temperature monitoring, predictive maintenance, and thermal anomaly detection.
Technical Specifications
MLX90640 thermal sensor with 32x24 pixels resolution
 Temperature range: -40C to 300C
 Accuracy: 1.5C (typical)
 Resolution: 12-bit
 Frame rate: up to 64 Hz
 Interface: I2C
 Power consumption: 1.8V, <100 mA
Software Libraries and Examples
The M5 StickC Thermal Camera Hat can be used with the M5 StickC microcontroller board, which is based on the ESP32 chip. The following examples demonstrate how to use this component in various contexts:
Example 1: Basic Thermal Imaging
This example uses the `M5StickC_MLX90640` library to read thermal data from the MLX90640 sensor and display it on the M5 StickC's built-in LCD screen.
```c
#include <M5StickC.h>
#include <M5StickC_MLX90640.h>
M5StickC_MLX90640 thermalCamera;
void setup() {
  M5.begin();
  thermalCamera.begin();
}
void loop() {
  thermalCamera.readSensor();
  uint16_t thermalData = thermalCamera.getThermalData();
  
  M5.Lcd.clear(BLACK);
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.print("Thermal Image:");
  
  for (int i = 0; i < 768; i++) {
    uint16_t temperature = thermalData[i];
    M5.Lcd.setCursor(i % 32, i / 32);
    M5.Lcd.print(temperature, DEC);
  }
  
  delay(1000);
}
```
Example 2: Temperature Monitoring with Wi-Fi Connectivity
This example uses the `WiFi` and `M5StickC_MLX90640` libraries to connect to a Wi-Fi network and send thermal data to a remote server using HTTP requests.
```c
#include <WiFi.h>
#include <M5StickC.h>
#include <M5StickC_MLX90640.h>
const char ssid = "your_ssid";
const char password = "your_password";
const char serverUrl = "http://your_server_url.com/thermal_data";
M5StickC_MLX90640 thermalCamera;
WiFiClient client;
void setup() {
  M5.begin();
  thermalCamera.begin();
  
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");
  Serial.println("Initializing HTTP connection...");
}
void loop() {
  thermalCamera.readSensor();
  uint16_t thermalData = thermalCamera.getThermalData();
  
  String thermalDataString = "";
  for (int i = 0; i < 768; i++) {
    thermalDataString += String(thermalData[i], DEC) + ",";
  }
  
  client.setServer(serverUrl, 80);
  client.println("POST /thermal_data HTTP/1.1");
  client.println("Host: " + String(serverUrl));
  client.println("Connection: close");
  client.println("Content-Type: application/x-www-form-urlencoded");
  client.println("Content-Length: " + String(thermalDataString.length()));
  client.println();
  client.print(thermalDataString);
  
  delay(10000);
}
```
Example 3: Integration with a Machine Learning Model
This example uses the `TensorFlow Lite` library to integrate the M5 StickC Thermal Camera Hat with a machine learning model for thermal anomaly detection.
```c
#include <TensorFlowLite.h>
#include <M5StickC.h>
#include <M5StickC_MLX90640.h>
M5StickC_MLX90640 thermalCamera;
tflite::MicroInterpreter interpreter;
void setup() {
  M5.begin();
  thermalCamera.begin();
  
  // Load the TensorFlow Lite model
  tflite::Model model = tflite::LoadModelFromFile("thermal_anomaly_detection.tflite");
  interpreter = new tflite::MicroInterpreter(model, 1);
}
void loop() {
  thermalCamera.readSensor();
  uint16_t thermalData = thermalCamera.getThermalData();
  
  // Preprocess thermal data for input to the machine learning model
  float inputData = new float[768];
  for (int i = 0; i < 768; i++) {
    inputData[i] = thermalData[i] / 100.0;
  }
  
  // Run the machine learning model
  TfLiteTensor inputTensor = interpreter->input(0);
  inputTensor->data.f = inputData;
  interpreter->Invoke();
  
  TfLiteTensor outputTensor = interpreter->output(0);
  float outputData = outputTensor->data.f;
  
  // Check for thermal anomalies
  bool isAnomaly = false;
  for (int i = 0; i < 1; i++) {
    if (outputData[i] > 0.5) {
      isAnomaly = true;
      break;
    }
  }
  
  if (isAnomaly) {
    Serial.println("Thermal anomaly detected!");
  } else {
    Serial.println("No thermal anomaly detected.");
  }
  
  delay(10000);
}
```
These examples demonstrate the capabilities of the M5 StickC Thermal Camera Hat and its potential applications in various IoT contexts.