My problem is that my first values are absurd and I wish to remove them because I also take the max and min altitude. In my opinion it's a buffer problem but I do not know how to fix it. Thank you
Note that it’s NOT a 5V sensor, so depending on your board you need to ensure you don’t abuse the hardware... which sensor do you have?
When you say the first values are absurd - how many of those and for how long? Do things work o after a while?
The MS5611-01BA Has a pretty high resolution and is optimized for altimeters and variometers with an altitude resolution of 10 cm andmhas factory calibrated coefficients for the built in ADC.
The code you have fills in a buffer (super rapidely) in the setup - so very likely with very similar values - and then the loop() is using that buffer to calculate an averaged altitude using a circular buffer technique (overwrite the oldest value in the buffer and calculate the average of what remains there, so at the speed of your loop, the average of the 32 read from the last few milliseconds (takes less than 10ms for a read))
Hello,
Thank you for your reply.
I use an arduino uno for realizing my tests and my VCC is equal to 3.3V. I bought this sensor:
There are approximately 50 absurd values in a second in the opening of the serial port. The sensor returns a roughly correct value of my altitude but this value drifts over time. The amount can range from 2m to a minute.
Thank you for your reply.
First of all, the values given to me at the opening of the serial monitor are below. There is about two seconds before I get a valid altitude at about 157m.
temp: 0.00 degC pres: 0.00 mbar altitude: inf m
temp: 0.00 degC pres: 0.00 mbar altitude: inf m
temp: 0.00 degC pres: 0.00 mbar altitude: inf m
temp: 0.00 degC pres: 31.10 mbar altitude: 39502.00 m
temp: 24.62 degC pres: 62.20 mbar altitude: 32083.99 m
temp: 24.62 degC pres: 93.29 mbar altitude: 26302.11 m
temp: 24.61 degC pres: 124.39 mbar altitude: 22461.05 m
temp: 24.62 degC pres: 155.49 mbar altitude: 19624.43 m
temp: 24.63 degC pres: 186.59 mbar altitude: 17394.47 m
temp: 24.63 degC pres: 217.69 mbar altitude: 15567.98 m
temp: 24.62 degC pres: 248.79 mbar altitude: 14028.02 m
temp: 24.63 degC pres: 279.88 mbar altitude: 12702.63 m
temp: 24.63 degC pres: 310.98 mbar altitude: 11541.52 m
temp: 24.64 degC pres: 342.08 mbar altitude: 10511.38 m
temp: 24.64 degC pres: 373.18 mbar altitude: 9586.79 m
temp: 24.62 degC pres: 404.28 mbar altitude: 8749.04 m
temp: 24.64 degC pres: 435.38 mbar altitude: 7985.83 m
temp: 24.64 degC pres: 466.48 mbar altitude: 7284.35 m
temp: 24.64 degC pres: 497.58 mbar altitude: 6636.46 m
temp: 24.63 degC pres: 528.68 mbar altitude: 6034.87 m
temp: 24.63 degC pres: 559.78 mbar altitude: 5474.18 m
temp: 24.64 degC pres: 590.88 mbar altitude: 4949.56 m
temp: 24.65 degC pres: 621.98 mbar altitude: 4456.79 m
temp: 24.65 degC pres: 653.07 mbar altitude: 3992.37 m
temp: 24.63 degC pres: 684.17 mbar altitude: 3553.30 m
temp: 24.65 degC pres: 715.27 mbar altitude: 3137.84 m
temp: 24.65 degC pres: 746.37 mbar altitude: 2743.11 m
temp: 24.65 degC pres: 777.47 mbar altitude: 2367.49 m
temp: 24.64 degC pres: 808.57 mbar altitude: 2009.29 m
temp: 24.63 degC pres: 839.67 mbar altitude: 1667.13 m
temp: 24.65 degC pres: 870.77 mbar altitude: 1339.88 m
temp: 24.65 degC pres: 901.87 mbar altitude: 1026.15 m
temp: 24.65 degC pres: 932.97 mbar altitude: 725.05 m
temp: 24.64 degC pres: 964.07 mbar altitude: 435.63 m
temp: 24.65 degC pres: 995.17 mbar altitude: 157.15 m
temp: 24.65 degC pres: 995.18 mbar altitude: 157.14 m
temp: 24.65 degC pres: 995.18 mbar altitude: 157.11 m
temp: 24.65 degC pres: 995.18 mbar altitude: 157.09 m
temp: 24.64 degC pres: 995.18 mbar altitude: 157.07 m
temp: 24.65 degC pres: 995.18 mbar altitude: 157.05 m
temp: 24.65 degC pres: 995.19 mbar altitude: 157.04 m
temp: 24.65 degC pres: 995.19 mbar altitude: 157.02 m
temp: 24.64 degC pres: 995.19 mbar altitude: 157.01 m
temp: 24.64 degC pres: 995.19 mbar altitude: 157.00 m
After that I tried to wait two seconds before filling the buffer and then displayed the values in the serial monitor like below :
So seems the first library fails from time to time which means it returns "crap" (0) into your circular buffer and averaging crap with good data gives you crap
Ahah exactly
I tried the code I posted previously (with the good library) at 115200 and I get the values below. It drifts a little in time. I post my first values when i open the serial monitor.
So I did with the circular buffer technical still 115200 and I get these values. Values are more stable and do not drift over time. I tried to let the code run for a few minutes and I get the same pressure so it's great. By cons I have again this problem of the first absurd values that appears and i don't know how remove these and where do it come from...
First of all, I understand better why I obtained a constant result. I took int32_t pressure which gives me a pressure in mbar with no decimal point. I put all int32_t and pressure in Pascal and I get the result below.
I no longer have the problem of bad values at launch :). On the other hand it is said in the datasheet that the sensor has an accuracy of + -10cm and I have the impression that I have slightly larger variations. Does it come from my code or sensor limits? thank you for everything