How would I read from a BMP280 sensor at the fastest possible rate ?



  • I am using a BMP280 module. I am very confident my system setup and software are working fine. Readings of temperature and pressure I receive seem valid.

    I wish to implement a design, based around an 8051 microcontroller, where the pressure reading is continually read from the device and sent out a serial port onto my PC where it is date stamped and saved to a log file.

    I want to run this as fast as possible. I do not wish to use the IIR filer, as I actually want to see any spikes that might appear.

    I'd be just reading the 3 or 6 bytes (either just pressure or pressure and temperature) and transmitting the raw values to my PC (converting later on). I've had my circuit reading 11 bytes from a different I2C sensor, and transmitting those values, at 800 hz without problems. So I know I can handle the fastest ODR the device claims to achieve.

    I understand I can either run in "forced mode" or "normal mode".

    It is not exactly clear to me which to use.

    Also, regardless of the mode I use, how would I know when to read from the device ?

    If I run in forced mode, can I simply write my code to run a tight loop of just reading from the device, transmitting the data to my PC, over and over ??? It would seem I would be trying to read at a rate that is much faster then the device can actually handle. Is there a problem with that ... as in ... would I risk reading invalid data ?

    If I run in normal mode, there is some sort of standby time. Would I need to determine that time, and write my code to wait AT LEAST that amount of time before seeking another reading ?

    Your help would be greatly appreciated.


  • Hardware Contributor

    Hello.

    I have not looked deeply at the datasheet, but I advice to read it 😉 It seems that if you want to be precise and fast, forced mode is less good than normal mode.
    About, your sampling rate, it will depends on lot of things like coding, sure. I think you can read/poll a register of the sensor to see if a sample is available. If I were you, I would use "if" instead loop for the polling. look at blink without led arduino example for this.

    I hope this helps 🙂



  • I've now tried various algorithms.

    In all of these I set the oversampling of both temperature and pressure to 1 (no oversampling).

    1. Forced mode, with fixed 5mS delay between reads,

    2. Forced mode, with fixed 4mS delay between reads,

    3. Forced mode, with fixed 3mS delay between reads,

    4. Forced mode, with fixed 1mS delay between reads,

    5. Normal mode, set t_sb = 0.5 mS, waiting until status bit 3 = 0, read data, repeat

    6. Normal mode, set t_sb = 0.5 mS, waiting until status bit 3 = 0, read data, wait until status bit 3 = 1, repeat

    With each algorithm, I'd do 2000 reads.

    As I went through the above scenarios, the minimum and maximum readings (for both values) got farther and farter apart - ie: the range of values got larger.

    That was until #5, where it was slightly better then #1. The range with #6 was the least of all - in other words, algorithm 6 gave the most consistent readings (I should say the sensor is laying still throughout these tests).

    In #5, it took 6 seconds to make 2000 readings - or an ODR of about 333 hz. In #6, it took 12 seconds to make 2000 readings - or an ODR of 166 hz. Just what the datasheet said would be the maximum ODR.

    I have to assume with #5, about half the readings were done before the registers were updated. In other words, it was a waste of cpu time to make the reading.


Log in to reply
 

Suggested Topics

21
Online

11.2k
Users

11.1k
Topics

112.5k
Posts