Giter Site home page Giter Site logo

scd30's People

Contributors

ndevenish avatar requestforcoffee avatar streakycobra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

scd30's Issues

Missing files

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?

One question..

Can I compensate co2 measurements with data from external pressure sensor like BMP280?
How?
Thanks

Sample code doesn’t work

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!

Memory Leak calling #get_data_ready

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=

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.