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.
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) |
To use the Adafruit MLX90393 with a microcontroller like an Arduino UNO, follow these steps:
#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);
}
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.