Air Quality Sensor - SGP40 (Qwiic) Hookup Guide

Pages
Contributors: El Duderino, MAKIN-STUFF
Favorited Favorite 0

SGP40 Python Package

Note: This package and the included examples assume you are using the latest version of Python 3. If this is your first time using Python or I2C hardware on a Raspberry Pi, these tutorial can help you get started:

The SparkFun SGP40 Python package is a simple module to get you started getting VOC data from the sensor. The Sensirion VOC Index algorithm is written for C/C++ so the Qwiic SGP40 Python package uses a similar algorithm for Python from DFRobot.

The package is hosted on PyPi so it can be installed using the command interface with some simple commands. If you prefer to manually install the package you can find it on the Github repository or download the ZIP of it by clicking the button below:

(*Please be aware this package depends on the Qwiic I2C Driver. You can also check out the repository documentation page, hosted on Read the Docs.)

Qwiic SGP40 Py Installation

Now let's go over both ways of installing the Qwiic SGP40 Python package.

Note: Don't forget to double check that the hardware I2C connection is enabled on your Raspberry Pi or other single board computer. The Raspberry Pi tutorials linked in the note above cover how to enable the Pi's I2C bus.

PyPi Installation

Since this repository is hosted on PyPi installation is simple on systems that support PyPi installation via pip3 (use pip for Python 2). Open a command interface and install the package using the following commands:

For all users (The user must have sudo privileges):

language:bash
sudo pip3 install sparkfun-qwiic-sgp40

For the current user:

language:bash
pip3 install sparkfun-qwiic-sgp40

Local Installation

Follow these instructions for a local installation. Make sure to install the setuptools package prior to installing the Qwiic SGP40 package.

Use the following command for direct installation at the command line (use python for Python 2):

language:bash
python3 setup.py install

To build a package for use with pip3:

language:bash
python setup.py sdist

This builds and places a subdirectory called "dist". Install the package using pip3 with this command making sure to fill in the correct version number:

langauge:bash
cd dist
pip3 install sparkfun_qwiic_sgp40-<version>.targ.gz

Qwiic SGP40 Python Package Operation

A complete overview of all the functions included in the Qwiic SGP40 Py is hosted on the ReadtheDocs. You can also take a look at the source code.

Upgrading the SGP40 Python Package

In case the package is updated in the future, you may need to upgrade it. Upgrade the package using the following commands:

For all users (The user must have sudo privileges):

language:bash
sudo pip3 install --upgrade sparkfun-qwiic-sgp40

For the current user:

language:bash
pip3 install --upgrade sparkfun-qwiic-sgp40