Closed SarwarN88 closed 11 months ago
Please post complete code being used to read the data. The rate limit in date reading may be due to something else in code.
`#include "Adafruit_MLX90393.h"
Adafruit_MLX90393 sensor = Adafruit_MLX90393();
void setup(void) { Serial.begin(115200);
/ Wait for serial on USB platforms. / while (!Serial) { delay(10); }
Serial.println("Starting Adafruit MLX90393 Demo");
//if (! sensor.begin_I2C()) { // hardware I2C mode, can pass in address & alt Wire if (! sensor.begin_SPI(MLX90393_CS)) { // hardware SPI mode Serial.println("No sensor found ... check your wiring?"); while (1) { delay(5); } } Serial.println("Found a MLX90393 sensor");
sensor.setGain(MLX90393_GAIN_2_5X); // You can check the gain too Serial.print("Gain set to: "); switch (sensor.getGain()) { case MLX90393_GAIN_1X: Serial.println("1 x"); break; case MLX90393_GAIN_1_33X: Serial.println("1.33 x"); break; case MLX90393_GAIN_1_67X: Serial.println("1.67 x"); break; case MLX90393_GAIN_2X: Serial.println("2 x"); break; case MLX90393_GAIN_2_5X: Serial.println("2.5 x"); break; case MLX90393_GAIN_3X: Serial.println("3 x"); break; case MLX90393_GAIN_4X: Serial.println("4 x"); break; case MLX90393_GAIN_5X: Serial.println("5 x"); break; }
// Set resolution, per axis sensor.setResolution(MLX90393_X, MLX90393_RES_19); sensor.setResolution(MLX90393_Y, MLX90393_RES_19); sensor.setResolution(MLX90393_Z, MLX90393_RES_16);
// Set oversampling sensor.setOversampling(MLX90393_OSR_2);
// Set digital filtering sensor.setFilter(MLX90393_FILTER_6); }
void loop(void) { float x, y, z;
// get X Y and Z data at once if (sensor.readData(&x, &y, &z)) { Serial.print("X: "); Serial.print(x, 4); Serial.println(" uT"); Serial.print("Y: "); Serial.print(y, 4); Serial.println(" uT"); Serial.print("Z: "); Serial.print(z, 4); Serial.println(" uT"); } else { Serial.println("Unable to read XYZ data from the sensor."); }
delay(2);
}`
The code currently read all 3 axis.
How are you determining the read rate? Having serial output in the read loop will slow things down.
I just count number of samples return per second in the Serial print. It should increase regardless. True, serial output will slow the sampling rate but I want to check if measuring one axis or increasing frequency will return more samples. Theoretically it should.
The 2ms delay will also limit the reading to roughly 500Hz. Well below any O(MHz) rate being attempted.
The MLX90393 output data rate (ODR) is not set directly. Instead, there is OSR (oversampling) and DIG_FILT (filtering). The resulting maximum ODR is a fallout of those settings. See Tables 18 and 19 in the datasheet.
Getting a rate in the MHz range is not even possible.
Closing. Seems like sensor rate confusion and not an issue with library code.
I am trying to increase the sampling rate by changing the frequency in the .cpp file from 1Mhz to 8Mhz. For each axis, I get 15 samples per second at 1Mhz. However, when I increase the frequency to 8Mhz the sample rate remain the same? Also when I force the library to return only one axis (x) using hex
0x08
in#define MLX90393_AXIS_ALL (0x0E)
, the sampling rate does not increase. In the MLX90393 data sheet it say sampling rate will increase if a axis is ignored in the measurement. In the loop I set delay to 2ms.