Hello!
I currently have set myself the project to build a 3d printed joystick.
and I'm nearly finished with the CAD design.
Today my sensor arrived and I wanted to quickly test it so I followed the instructions
from SparkFuns hompage. (Bottom of the page)
(Qwiic Magnetometer (MLX90393) Hookup Guide - SparkFun Learn)
/*
3.3V = 3.3V
GND = GND
SDA = A4
SCL = A5
*/
#include <Wire.h>
#include <MLX90393.h>
MLX90393 mlx;
MLX90393::txyz data; //Create a structure, called data, of four floats (t, x, y, and z)
void setup()
{
Serial.begin(9600);
Serial.println("MLX90393 Read Example");
Wire.begin();
//Connect to sensor with I2C address jumpers set: A1 = 1, A0 = 0
//Use DRDY pin connected to A3
//Returns byte containing status bytes
byte status = mlx.begin(1, 0, A3);
delay(2000);
//Report status from configuration
Serial.print("Start status: 0x");
if(status < 0x10) Serial.print("0"); //Pretty output
Serial.println(status, BIN);
mlx.setGainSel(1);
mlx.setResolution(0, 0, 0); //x, y, z
mlx.setOverSampling(0);
mlx.setDigitalFiltering(0);
//See MLX90393.h and .cpp for additional functions including:
//set/getOverSample, set/getTemperatureOverSample, set/getDigitalFiltering, set/getResolution
//set/getTemperatureCompensation, setOffsets, setWThresholds
}
void loop()
{
mlx.readData(data); //Read the values from the sensor
Serial.print("magX[");
Serial.print(data.x);
Serial.print("] magY[");
Serial.print(data.y);
Serial.print("] magZ[");
Serial.print(data.z);
Serial.print("] temperature(C)[");
Serial.print(data.t);
//Serial.print("] status[");
//Serial.print(status);
Serial.print("]");
Serial.println();
delay(100);
}
I use an Arduino Leonardo and a breakout module for the MLX90393.
But all I get in the serial monitor is "Start status: 0x11111111" and then nothing else happens
or if I just take out the sensor module of the breadboard I get unrealistic high values (440°C at room temperature).
That tells me that the sensor is doing something but that it is unable to execute the main loop or is getting stuck in the setup.
I would be really happy if anyone could help me here because I don't know what is the error here.
Pictures below for circuit:
Sensor is powered externally by 3.3V