Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Humidity value always 0.0 #2

Closed
christoph-7 opened this issue May 23, 2017 · 6 comments
Closed

Humidity value always 0.0 #2

christoph-7 opened this issue May 23, 2017 · 6 comments

Comments

@christoph-7
Copy link

christoph-7 commented May 23, 2017

Hi,
when running the sample.py, the humidity value is always 0.0.
Temperature and pressure seem fine. The sensor is also working with the Adafruit library on an Arduino.

EDIT1:
I'm using Python 2.7
Looking into the init.py, the error seems to occur in the calculating of the variable res, which is in my case calculated to ~ -3798. Therefore line 92 is evaluated to 0.0

@rm-hull
Copy link
Owner

rm-hull commented May 23, 2017

Interesting.... line 92 clamps the value between 0% and 100% (obviously, any value outside this range doesn't/shouldn't make sense)

  • Do the temperature and pressure values correspond with what the adafruit library results?
  • Are you using an unbranded BME280 or the adafruit breakout board?
  • Can you print out the bme280.compensation_params and paste into this issue

@christoph-7
Copy link
Author

christoph-7 commented May 23, 2017

The value of temperature is ~3 °C higher with the Adafruit library and pressure is the same.
I'm using an unbranded BME280 breakout board.

bme280.compensation_params delivers
{'dig_P9': 4285, 'dig_P8': -10230, 'dig_T1': 28814, 'dig_T3': 50, 'dig_T2': 26441, 'dig_P1': 35567, 'dig_P3': 3024, 'dig_P2': -10609, 'dig_P5': -40, 'dig_P4': 7295, 'dig_P7': 9900, 'dig_P6': -7, 'dig_H1': 75, 'dig_H3': 0, 'dig_H2': 358, 'dig_H5': 131075, 'dig_H4': 329, 'dig_H6': 30, 'x8': 4, 'x2': 2, 'x1': 1, 'x4': 3, 'x16': 5}

EDIT1:
I looked up the compensation value for the humidity with the Adafruit library. The only difference is dig_H5, which is only 50

EDIT2:
I think that you did made a mistake in the register shifting in line 156
I changed
compensation_params.dig_H5 = (e5 & 0xF0) << 12 | e6
to
compensation_params.dig_H5 = ((e5 >> 4) & 0xF0) | (e6 << 4)
and now I'm getting reasonable results. I will later try to verify the measurements to clarify if this is just another incorrect value.

@rm-hull
Copy link
Owner

rm-hull commented May 23, 2017

Yes, I think you're right, it is definitely an issue with H5 - looking at the datasheet, I think I made a transcription error when I coded it up:
screen shot 2017-05-23 at 21 10 27

I believe your calc is correct, so I will push out a new version

@rm-hull
Copy link
Owner

rm-hull commented May 23, 2017

I've published 0.1.3 on pypi with the fix in it, and have improved the debug logging of uncompensated readings:

$ python examples/sample.py 
compensation_params = {'dig_P9': 4285, 'dig_P8': -10230, 'dig_T1': 28441, 'dig_T3': 50, 'dig_T2': 26357, 'dig_P1': 36127, 'dig_P3': 3024, 'dig_P2': -10788, 'dig_P5': 45, 'dig_P4': 6191, 'dig_P7': 9900, 'dig_P6': -7, 'dig_H1': 75, 'dig_H3': 0, 'dig_H2': 364, 'dig_H5': 0, 'dig_H4': 313, 'dig_H6': 30, 'x8': 4, 'x2': 2, 'x1': 1, 'x4': 3, 'x16': 5}
uncompensated_reading(temp=0x00081930, pressure=0x00058A70, humidity=0x00006C49, block=58:A7:00:81:93:00:6C:49)
compensated_reading(id=e5b9d160-b697-4799-bcd6-dce26ae9ebfd, timestamp=2017-05-23 20:40:07.209791, temp=23.782 °C, pressure=1011.74 hPa, humidity=43.29 % rH)

@cmur2
Copy link

cmur2 commented Jun 12, 2020

Sorry for necromancy, I got a similar issue reported in cmur2/python-bme280#35 and thus came to this thread.

@rm-hull one question:
Shouldn't compensation_params.dig_H5 = ((e5 >> 4) & 0xF0) | (e6 << 4) be compensation_params.dig_H5 = ((e5 >> 4) & 0x0F) | (e6 << 4) (0x0F instead if 0xF0) to avoid ignoring e5 completely?

Edit: It looks like a missed a later modification to the code, my apologies.

@rm-hull
Copy link
Owner

rm-hull commented Jun 12, 2020

@cmur2 if you look at the code https://github.com/rm-hull/bme280/blob/master/bme280/__init__.py#L179, is that not what it does?

I think that #11 made this observation, and it was fixed in commit ad21381.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants