Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use Adafruit MLX90393: Examples, Pinouts, and Specs

Image of Adafruit MLX90393Design with Adafruit MLX90393 in Cirkit Designer

Introduction

The Adafruit MLX90393 is a versatile and compact magnetic sensor capable of measuring magnetic fields in three dimensions (X, Y, and Z axes). It is based on the MLX90393 sensor from Melexis, which can detect magnetic fields with high accuracy and resolution. This sensor is commonly used in applications such as electronic compasses, position detection, and proximity sensing. Its small form factor and I2C interface make it ideal for embedded systems and IoT devices.

Explore Projects Built with Adafruit MLX90393

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Adafruit MPU6050 and VL6180X Sensor Interface with Servo Control: A project utilizing Adafruit MLX90393 in a practical application
Adafruit MPU6050 and VL6180X Sensor Interface with Servo Control

This circuit features an Adafruit QT Py microcontroller interfaced with an Adafruit MPU6050 6-axis accelerometer/gyroscope and an Adafruit VL6180X Time of Flight (ToF) distance sensor, both connected via I2C communication. The QT Py also controls a Servomotor SG90, likely for physical actuation based on sensor inputs. The embedded code initializes the sensors, reads their data, and outputs the readings to a serial monitor, with the potential for motion control based on the sensor feedback.

Open Project in Cirkit Designer

Technical Specifications

Key Features

Pin Configuration and Descriptions

Pin Number Name Description
1 VIN Supply voltage (2.2V to 3.6V)
2 GND Ground connection
3 SDA I2C Data Line
4 SCL I2C Clock Line
5 INT Interrupt output (active low)
6 DRDY Data Ready output (active low)

Usage Instructions

Integration with a Circuit

To use the Adafruit MLX90393 with a microcontroller like an Arduino UNO, follow these steps:

  1. Connect the VIN pin to the 3.3V output on the Arduino.
  2. Connect the GND pin to one of the ground pins on the Arduino.
  3. Connect the SDA pin to the A4 pin (SDA) on the Arduino.
  4. Connect the SCL pin to the A5 pin (SCL) on the Arduino.
  5. (Optional) Connect the INT pin to an available digital pin if interrupt functionality is required.
  6. (Optional) Connect the DRDY pin to another available digital pin if data ready indication is needed.

Best Practices

Example Code for Arduino UNO

#include <Wire.h>
#include <Adafruit_MLX90393.h>

// Create an MLX90393 instance
Adafruit_MLX90393 mlx = Adafruit_MLX90393();

void setup() {
  Serial.begin(9600);
  // Initialize the sensor
  if (!mlx.begin()) {
    Serial.println("Failed to initialize MLX90393!");
    while (1);
  }
  Serial.println("MLX90393 initialized.");
}

void loop() {
  // Read magnetic field data
  float x, y, z;
  mlx.readData(&x, &y, &z);
  // Print the results
  Serial.print("X: "); Serial.print(x); Serial.print(" uT, ");
  Serial.print("Y: "); Serial.print(y); Serial.print(" uT, ");
  Serial.print("Z: "); Serial.print(z); Serial.println(" uT");
  // Small delay before the next reading
  delay(500);
}

Troubleshooting and FAQs

Common Issues

FAQs

Q: Can the MLX90393 be used with a 5V microcontroller? A: Yes, but ensure that the sensor's VIN pin is connected to a 3.3V supply, and use logic level converters for SDA and SCL lines if necessary.

Q: How can I change the I2C address of the sensor? A: The I2C address is fixed for the MLX90393. If you need to use multiple sensors on the same bus, you will need an I2C multiplexer.

Q: What is the maximum range of magnetic field the MLX90393 can measure? A: The MLX90393 can measure magnetic fields up to ±5 mT.

Q: How do I use the interrupt and data ready pins? A: The INT and DRDY pins can be connected to digital pins on your microcontroller and configured to trigger an interrupt when a measurement is ready or when certain thresholds are exceeded.

For further assistance, consult the Adafruit MLX90393 datasheet and the library's documentation.