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

Using the program #1

Open
hockenator opened this issue Apr 13, 2020 · 2 comments
Open

Using the program #1

hockenator opened this issue Apr 13, 2020 · 2 comments

Comments

@hockenator
Copy link

Paul, thanks for your great work. I'm currently like to connect an SVM to a RasPi for an indoor tVOC sampling and logging campaign. I followed your recommended steps in compiling the bcm2835 driver. Everything was fine, but: What I have to do now? My goal is to use a SVM30 library in a python code...
I'm a little bit confused, because "a new kid on the block".
Can you give a hint please?

@paulvha
Copy link
Owner

paulvha commented Apr 13, 2020

Hi, thanks for the feedback.
Make sure to read the SVM30.odt on how to compile and create an object and use it from the command line.

For another project (scd30) I got some good advice how to integrate that with Python. I took the following from that project that you can tailor to your need :

Stay Safe,
Paul


Received the following code from Aeolus1364 (credits to him) .
import subprocess, shlex
def run_command(command):
process = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE)
while True:
output = process.stdout.readline()
if output == '' and process.poll() is not None:
break
if output:
print(output.strip())
rc = process.poll()
return rc

run_command("./scd30")
It was part of an issue to integrate the scd30 program in Python and capture the output. To enable this the p_printf() changes were applied (version 3.0.2). p_printf() performs a ‘fflush(stdout)’ after each write which seems to be necessary for the integration to work well. Normally a line is detected after newline (which is performed as well in do_output()).
His full code is posted on : https://github.com/Aeolus1364/SCD30_Python_Library

@hockenator
Copy link
Author

hockenator commented Apr 13, 2020 via email

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

2 participants