adafruit / Adafruit_CircuitPython_SCD30

Helper library for the SCD30 e-CO2 sensor
MIT License
15 stars 10 forks source link

Refinements for MCP2221 #9

Closed caternuson closed 3 years ago

caternuson commented 3 years ago

For #2

This is a bit hack-ish in the way it forces an MCP2221 reset, but seems to work. Tested with Blinka/MCP2221:

$ python3 scd30_simpletest.py 
Data Available!
CO2: 0.0 PPM
Temperature: 28.976119995117188 degrees C
Humidity: 28.07159423828125 %%rH

Waiting for new data...

Data Available!
CO2: 1135.52685546875 PPM
Temperature: 28.933395385742188 degrees C
Humidity: 28.12957763671875 %%rH

Waiting for new data...

Data Available!
CO2: 1375.5328369140625 PPM
Temperature: 28.946746826171875 degrees C
Humidity: 29.0130615234375 %%rH

And with CP 6.1.0 on QT Py:

Adafruit CircuitPython 6.1.0 on 2021-01-21; Adafruit QT Py M0 with samd21e18
>>> import scd30_simpletest
Data Available!
CO2: 0.0 PPM
Temperature: 28.8212 degrees C
Humidity: 28.0289 %%rH

Waiting for new data...

Data Available!
CO2: 930.281 PPM
Temperature: 28.8052 degrees C
Humidity: 27.6443 %%rH

Waiting for new data...

Data Available!
CO2: 988.408 PPM
Temperature: 28.8212 degrees C
Humidity: 27.5574 %%rH
caternuson commented 3 years ago

As an alternative, could remove the call to reset() in __init__, similar to #3.

caternuson commented 3 years ago

rename file to scd30_mcp2221test.py?

The new example? I was thinking it may end up growing with time. Can add whatever future hacks are needed for whatever board there?

ladyada commented 3 years ago

want me to review?

caternuson commented 3 years ago

Sure. I can rename the example too if you want. I'm really not sure best way to document this "feature". Might make sense to name it something to draw attention to it being something MCP2221 specific?

ladyada commented 3 years ago

yeah rename to scd30_mcp2221test.py