BMP280 / BME280 uPython

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Rissy
Posts: 116
Joined: Sun Aug 14, 2022 8:15 am

Re: BMP280 / BME280 uPython

Post by Rissy » Thu Sep 08, 2022 6:20 pm

Evening roberthh!

I thought I 'd used the _float version previously, so this time, I grabbed the _float version again, and of course, I then had the lines of code you've highlighted above as correction factors. I guess i've mis-remembered and had actually taken the _int version.

Anyhow, I've removed those correction factor lines and the temperature/humidity readings now look much better. However, I found that to get the pressure values to read correctly, I still had to put in a correction factor to the received value from your driver file. I now have the following lines:

Code: Select all

    at0 = t0
    ap0 = p0/100.0
    ah0 = h0
    at1 = t1
    ap1 = p1/100.0
    ah1 = h1
Is this expected, or is there still something need adjusting in your driver file?

I don't know right now if there is a linear offset or a non linear offset from your driver file, meaning that dividing the pressure by 100 may still not be correct.

I just want to add that i'm very pleased you were willing to look at all this for me, as there is no way on earth I would have been able to come up with all the corrections you've made so far! I'm just not that good, and I'll be honest, I probably never will be. I'm much more of an end-user rather than someone who's going to be able to have the capability to write and edit driver files! So again, your continued support is most appreciated. :)

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: BMP280 / BME280 uPython

Post by Roberthh » Thu Sep 08, 2022 6:37 pm

The scaling factor of 100 have be related to different physical units. The driver returns the basic values, °C for temperature, % for humidity and Pa for pressure. The usual numbers in weather reports are hPa or hectoPascal, which is by a factor of 100 (hecto) lower than the Pa number. 1 hPA = 100 Pa.
You may also have a look at the README file in my repository. It explains the structure and scaling of the returned values.

Rissy
Posts: 116
Joined: Sun Aug 14, 2022 8:15 am

Re: BMP280 / BME280 uPython

Post by Rissy » Thu Sep 08, 2022 7:19 pm

Ah! That would explain it then! Perfect. I never even thought of that! DOH! (I'm always in such a rush right now, that my hurried approach is stopping me thinking clearly obviously)

In that case, I'll try monitoring this codes results for a while (a few days over the weekend) and get back to you with my feelings on its hopefully new and improved accuracy with these new oversampling rates applied.

Again, a great big thank you! :D

Rissy
Posts: 116
Joined: Sun Aug 14, 2022 8:15 am

Re: BMP280 / BME280 uPython

Post by Rissy » Mon Sep 12, 2022 5:33 pm

Hi Roberthh,

I've been testing out this code for stability all weekend, and it's not bad. Although, the temperature and humidity still suffer some drift away from my reference. The only other thing i can think of at this time is what mode the bme280 is being requested to work at by this code. I can't see a reference to how I can manage this aspect. In my main raspberry pi code, I had to set the mode to "normal" instead of "forced", but i don't see how i can do this.. I have "mode=mode", but can't seem to have the privilege to set this to anything else i.e "normal", "forced", "sleep". I can see some mention of these option in your code, but don't know how to change them from the front end.
I have the same issue with the IIR filter. Can I adjust that somehow too?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: BMP280 / BME280 uPython

Post by Roberthh » Mon Sep 12, 2022 7:16 pm

The BME280 should go into sleep when not requested. So as long as you do not poll too often, at least the temperature reading should be stable. About humidity I have my doubts. I did a series of humidity tests a while ago, exposing a range of sensors to controlled humidity by placing them in a closed box of a saturated solution of various chemicals and a small vent for circulating the air. The BME280 I tested did not perform overly well. The best was a DHT22, which on the data sheet is worse. See the attached table. Rebaking is a procedure to "reset" the humidity sensor and follows the procedure from the data sheet.
Which reference do you use?
test results.jpg
test results.jpg (127.5 KiB) Viewed 61553 times

Rissy
Posts: 116
Joined: Sun Aug 14, 2022 8:15 am

Re: BMP280 / BME280 uPython

Post by Rissy » Mon Sep 12, 2022 9:40 pm

Roberthh wrote:
Mon Sep 12, 2022 7:16 pm
Which reference do you use?
I'm almost embarrassed to say. Clearly nothing as sophisticated as all your results. I've not been as scientific as clearly you have been, but with purchased items where a measurement of humidity is one of the functions, and with multiple copies which all correspond with each other. Perhaps there is the chance that they themselves are not as accurate as perhaps i've been giving them credit.

If they BME280 is not as accurate as perhaps I was hoping, or under the impression; then perhaps the best I can do is accept them as a simple rule of thumb guide rather than an absolute then.

Post Reply