5 years, 2 months ago.

MPL3115a2: How do I get th 6ms sampling rate?

I'm using the WIGO_MPL3115A2 Hello world program https://developer.mbed.org/users/clemente/code/WIGO_MPL3115A2/

#include "mbed.h"
#include "MPL3115A2.h"

#define MPL3115A2_I2C_ADDRESS (0x60<<1)
MPL3115A2 wigo_sensor1(PB_9, PB_8, MPL3115A2_I2C_ADDRESS);
Serial pc(USBTX, USBRX);
 // pos [0] = altitude or pressure value 
 // pos [1] = temperature value 
float sensor_data[2];

int main(void) {

   pc.baud( 9600);
   pc.printf("MPL3115A2 Altimeter mode. [%d]\r\n", wigo_sensor1.getDeviceID()); 

   wigo_sensor1.Oversample_Ratio( OVERSAMPLE_RATIO_1);
   wigo_sensor1.Altimeter_Mode();
    
   while(1)
   {
        //
       //if ( wigo_sensor1.isDataAvailable())
       //{
            wigo_sensor1.getAllData( &sensor_data[0]);
           pc.printf("\tAltitude: %f\tTemperature: %f\r\n", sensor_data[0], sensor_data[1]);
       //}
       //
       wait( 0.001);
   }

}

I'm getting a new measurement about every 20 ms. How do I get the 6ms sample rate stated in the data sheet?

Question relating to:

Be the first to answer this question.