requestforcoffee / scd30 Goto Github PK
View Code? Open in Web Editor NEWPython I2C driver for the SCD30 CO2, temperature and humidity sensor.
License: MIT License
Python I2C driver for the SCD30 CO2, temperature and humidity sensor.
License: MIT License
I'm might be missing something in the setup but when running the sample I get the following error:
FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'
.
Any idea what it could be?
Can I compensate co2 measurements with data from external pressure sensor like BMP280?
How?
Thanks
The temperature compensation fails to write to the register and always stays the same
smbus2
and other dependencies should be added to requirements.txt and installed together with the package.
Hi,
I’m quite new to the scene and I can’t manage to make the sample code work on my raspi 4B.
I’ve followed the instructions, installed the scd30_i2c package, did the wiring and copied the sample code to Thonny IDE on my raspi that I access trough VNC. When runing the code I get the following error msgs:
"
Traceback (most recent call last):
File "/home/pita/Documents/Malina SCD30 test.py", line 5, in
scd30 = SCD30()
File "/home/pita/.local/lib/python3.7/site-packages/scd30_i2c/init.py", line 17, in init
self._i2c = smbus2.SMBus(1)
File "/home/pita/.local/lib/python3.7/site-packages/smbus2/smbus2.py", line 279, in init
self.open(bus)
File "/home/pita/.local/lib/python3.7/site-packages/smbus2/smbus2.py", line 308, in open
self.fd = os.open(filepath, os.O_RDWR)
PermissionError: [Errno 13] Permission denied: '/dev/i2c-1'
"
I think this is because I did not do something in the "Software configuration and I²C clock stretching" part of the tutorial. This is because this part is clarifying why i2c clock stretching is required but it doesn’t give precise instructions on how to achieve the software configuration and I2C clock stretching.
Please advise what do I need to do in this part of the tutorial.
Thank you, cheers!
Hi, the sample code on pypi is missing the "import time".
Calling sensor.get_data_ready()
in a loop causes a slow memory leak. It gets worse if periodic measurement is enabled.
import time
import tracemalloc
from scd30_i2c import SCD30
def print_trace_diff(a, b):
stats = [s for s in b.compare_to(a, 'lineno') if not s.traceback[0].filename.endswith('tracemalloc.py')]
stats = [s for s in stats if s.size_diff != 0]
if stats:
for stat in stats[:10]:
print(stat)
def main():
tracemalloc.start(10)
snap = tracemalloc.take_snapshot()
scd30 = SCD30()
#scd30.set_measurement_interval(5)
#scd30.start_periodic_measurement()
try:
while True:
print("ready: ", scd30.get_data_ready())
time.sleep(5)
print_trace_diff(snap, tracemalloc.take_snapshot())
print()
except KeyboardInterrupt:
# scd30.stop_periodic_measurement()
scd30.soft_reset()
if __name__ == '__main__':
main()
The first print looks something like:
ready: 0
/usr/lib/python3.7/ctypes/__init__.py:60: size=1332 B (+1332 B), count=20 (+20), average=67 B
/usr/lib/python3.7/ctypes/__init__.py:55: size=1288 B (+1288 B), count=19 (+19), average=68 B
/home/dave/project/lib/python3.7/site-packages/smbus2/smbus2.py:252: size=1242 B (+1242 B), count=17 (+17), average=73 B
/usr/lib/python3.7/enum.py:892: size=936 B (+936 B), count=26 (+26), average=36 B
/home/dave/project/lib/python3.7/site-packages/scd30_i2c/__init__.py:174: size=780 B (+780 B), count=2 (+2), average=390 B
/home/dave/project/lib/python3.7/site-packages/scd30_i2c/__init__.py:136: size=720 B (+720 B), count=3 (+3), average=240 B
/usr/lib/python3.7/logging/__init__.py:2003: size=404 B (+404 B), count=1 (+1), average=404 B
/home/dave/project/lib/python3.7/site-packages/scd30_i2c/__init__.py:153: size=372 B (+372 B), count=1 (+1), average=372 B
/home/dave/project/lib/python3.7/site-packages/scd30_i2c/__init__.py:131: size=364 B (+364 B), count=1 (+1), average=364 B
/home/dave/project/lib/python3.7/site-packages/scd30_i2c/__init__.py:121: size=364 B (+364 B), count=1 (+1), average=364 B
By the time its run a few times, you can see a steady increase in the number of objects allocated by the library:
/usr/lib/python3.7/ctypes/__init__.py:60: size=1484 B (+1484 B), count=23 (+23), average=65 B
/usr/lib/python3.7/ctypes/__init__.py:55: size=1440 B (+1440 B), count=22 (+22), average=65 B
/home/dave/project/lib/python3.7/site-packages/smbus2/smbus2.py:252: size=1394 B (+1394 B), count=20 (+20), average=70 B
/usr/lib/python3.7/enum.py:892: size=936 B (+936 B), count=26 (+26), average=36 B
############## Steady, monotonic increase on line 136 below
/home/dave/project/lib/python3.7/site-packages/scd30_i2c/__init__.py:136: size=864 B (+864 B), count=7 (+7), average=123 B
/home/dave/project/lib/python3.7/site-packages/scd30_i2c/__init__.py:174: size=780 B (+780 B), count=2 (+2), average=390 B
/usr/lib/python3.7/logging/__init__.py:2003: size=404 B (+404 B), count=1 (+1), average=404 B
/home/dave/project/lib/python3.7/site-packages/scd30_i2c/__init__.py:153: size=372 B (+372 B), count=1 (+1), average=372 B=
Hi,
could you provide a list of RPi's that are known to work with the library?
If there are special tweaks necessary for other than RPi4, that would also be helpful.
Yours
S
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.