Closed rpavlik closed 3 years ago
ping @caternuson
@tannewt yep. on it. just got one yesterday :)
@rpavlik What about doing this in user code instead?
scd.ambient_pressure = int(clue.pressure)
This would help reinforce the fact that the setting really is only integer resolution:
It would also make things more symetric in terms of getting the same value back when you read scd.ambient_pressure
.
Actually, I'm going to be like a politician and flip-flip on this. I'm cool with it. I think the trade off of allowing simpler user code vs. the potential issues of the automagic behavior is minimal.
@rpavlik Want to do something similar for altitude
while you're at it?
Ah, I hadn't thought of altitude since my thought process was literally "hey, I can have it compensate for pressure, this clue has a bmp280, I shall take the value from bmp280 and apply to scd30". Sure, I can get to that tonight probably.
There you go!
BTW, we probably want to bump major version soon on this because of the eCO2 -> CO2 rename?
Looks good. Tested real quick on a MatrixPortal. The parameter is still eCO2
since this PR is based on branch forked without that merged in.
Adafruit CircuitPython 6.1.0 on 2021-01-21; Adafruit Matrix Portal M4 with samd51j19
>>> import board
>>> import adafruit_scd30
>>> scd30 = adafruit_scd30.SCD30(board.I2C())
>>> scd30.eCO2
755.951
>>> scd30.ambient_pressure
0
>>> scd30.ambient_pressure = 1010.5
>>> scd30.ambient_pressure
1010
>>> scd30.altitude
0
>>> scd30.altitude = 300.5
>>> scd30.altitude
300
>>> scd30.eCO2
779.802
>>>
BTW, we probably want to bump major version soon on this because of the eCO2 -> CO2 rename?
Yep. Looks like that was done a couple of days ago with the 2.0.0 release: https://github.com/adafruit/Adafruit_CircuitPython_SCD30/releases/tag/2.0.0
awesome thanks!
I noticed that there was this feature to set the pressure for better results, and since I was using a CLUE, I figured I'd set it on startup. Of course, the BMP280 returns a float, not an int, so I got an error about trying to shift a float. This fixes the error, by turning whatever we're given in the setter of
ambient_pressure
into an int, so you can just: