{"id":19738412,"url":"https://github.com/sensirion/raspberry-pi-i2c-stc3x","last_synced_at":"2026-05-14T00:40:02.317Z","repository":{"id":149346071,"uuid":"339735009","full_name":"Sensirion/raspberry-pi-i2c-stc3x","owner":"Sensirion","description":"RaspberryPi driver for Sensirion STC3x sensors","archived":false,"fork":false,"pushed_at":"2024-06-21T13:51:28.000Z","size":766,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-28T05:57:56.407Z","etag":null,"topics":["driver","i2c","raspberry-pi","stc","stc31","stc3x","stc3x-sensor"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sensirion.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-17T13:37:36.000Z","updated_at":"2024-12-23T23:38:13.000Z","dependencies_parsed_at":"2024-05-10T09:43:45.869Z","dependency_job_id":"c7e229e5-0c8e-4d60-8dd4-f7af1a64fe88","html_url":"https://github.com/Sensirion/raspberry-pi-i2c-stc3x","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Sensirion/raspberry-pi-i2c-stc3x","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sensirion%2Fraspberry-pi-i2c-stc3x","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sensirion%2Fraspberry-pi-i2c-stc3x/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sensirion%2Fraspberry-pi-i2c-stc3x/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sensirion%2Fraspberry-pi-i2c-stc3x/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sensirion","download_url":"https://codeload.github.com/Sensirion/raspberry-pi-i2c-stc3x/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sensirion%2Fraspberry-pi-i2c-stc3x/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285879574,"owners_count":27247109,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-22T02:00:05.934Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["driver","i2c","raspberry-pi","stc","stc31","stc3x","stc3x-sensor"],"created_at":"2024-11-12T01:14:08.011Z","updated_at":"2025-11-23T00:02:53.482Z","avatar_url":"https://github.com/Sensirion.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sensirion Raspberry Pi I²C STC3X Driver\n\nThe repository provides a driver for setting up a sensor of the STC3X family to run on a Raspberry Pi over I²C.\n\n\u003cimg src=\"images/stc3x.png\" width=\"300px\"\u003e\n\nClick [here](https://sensirion.com/products/catalog/SEK-STC31) to learn more about the Sensirion STC3X sensor family.\n\n\nThe measured gas mixture depends on the STC3x product and configured binary gas.\nPlease refer to the datasheet and API documentation to get a list of supported\nbinary gases.\n\n\n\n## Supported sensor types\n\n| Sensor name   | I²C Addresses  |\n| ------------- | -------------- |\n|[STC31-C](https://sensirion.com/products/catalog/STC31)| **0x29**|\n|[STC31](https://sensirion.com/products/catalog/STC31)| **0x29**|\n\nThe following instructions and examples use a *STC31-C*.\n\n\n\n## Connect the sensor\n\nYour sensor has 4 different connectors: VDD, SCL, GND, SDA.\nUse the following pins to connect your STC3X:\n\n| *STC3X* | *Cable Color*  |   *Raspberry Pi*   |\n| :----------------: | -------------- | ------------------ |\n| VDD | red | Pin 1\n| SCL | yellow | Pin 5\n| GND | black | Pin 6\n| SDA | green | Pin 3\n\n\n\u003cimg src=\"images/raspi-i2c-pinout-3.3V.png\" width=\"400px\"\u003e\n\n\n### Detailed sensor pinout\n\n\u003cimg src=\"images/stc3x-pinout.png\" width=\"300px\"\u003e\n\n| *Pin* | *Cable Color* | *Name* | *Description*  | *Comments* |\n|-------|---------------|:------:|----------------|------------|\n| 1 | red | VDD | Supply Voltage | 2.7V to 5.5V\n| 2 | yellow | SCL | I2C: Serial clock input |\n| 3 | black | GND | Ground |\n| 4 | green | SDA | I2C: Serial data input / output |\n\n\n\n## Quick start example\n\n- [Install the Raspberry Pi OS on to your Raspberry Pi](https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up)\n- [Enable the I²C interface in the raspi-config](https://www.raspberrypi.org/documentation/configuration/raspi-config.md)\n- Download the STC3X driver from [Github](https://github.com/Sensirion/raspberry-pi-i2c-stc3x) and extract the `.zip` on your Raspberry Pi\n- Connect the STC3X sensor as explained in the [section above](#connect-the-sensor)\n- The provided example is working with a STC31-C, I²C address 0x29.\n  In order to use the code with another product or I²C address you need to change it in the call stc3x_init(ADDRESS) in\n  `stc3x_i2c_example_usage.c`. The list of supported I²C-addresses is found in the header\n  `stc3x_i2c.h`.\n\n- Compile the driver\n    1. Open a [terminal](https://projects.raspberrypi.org/en/projects/raspberry-pi-using/8)\n    2. Navigate to the driver directory. E.g. `cd ~/raspberry-pi-i2c-stc3x`\n    3. Navigate to the subdirectory example-usage.\n    4. Run the `make` command to compile the driver\n\n       Output:\n       ```\n       rm -f stc3x_i2c_example_usage\n       cc -Os -Wall -fstrict-aliasing -Wstrict-aliasing=1 -Wsign-conversion -fPIC -I. -o stc3x_i2c_example_usage  stc3x_i2c.h stc3x_i2c.c sensirion_i2c_hal.h sensirion_i2c.h sensirion_i2c.c \\\n           sensirion_i2c_hal.c sensirion_config.h sensirion_common.h sensirion_common.c stc3x_i2c_example_usage.c\n       ```\n- Test your connected sensor\n    - Run `./stc3x_i2c_example_usage` in the same directory you used to\n      compile the driver. You should see the measurement values in the console.\n\n## Troubleshooting\n\n### Building driver failed\n\nIf the execution of `make` in the compilation step 3 fails with something like\n\n```bash\n make: command not found\n```\n\nyour RaspberryPi likely does not have the build tools installed. Proceed as follows:\n\n```\n$ sudo apt-get update\n$ sudo apt-get upgrade\n$ sudo apt-get install build-essential\n```\n\n\n### Initialization failed\n\nIf you run `./stc3x_i2c_example_usage` but do not get sensor readings\nthen go through the below troubleshooting steps.\n\n\n-   Ensure that you connected the sensor correctly: All cables are fully\n    plugged in and connected to the correct pin.\n-   Ensure that I²C is enabled on the Raspberry Pi. For this redo the steps on\n    \"Enable the I²C interface in the raspi-config\" in the guide above.\n-   Ensure that your user account has read and write access to the I²C device.\n    If it only works with user root (`sudo ./stc3x_i2c_example_usage`), it's\n    typically due to wrong permission settings. See the next chapter how to solve this.\n\n### Missing I²C permissions\n\nIf your user is missing access to the I²C interface you should first verfiy\nthe user belongs to the `i2c` group.\n\n```\n$ groups\nusers input some other groups etc\n```\nIf `i2c` is missing in the list add the user and restart the Raspberry Pi.\n\n```\n$ sudo adduser your-user i2c\nAdding user `your-user' to group `i2c' ...\nAdding user your-user to group i2c\nDone.\n$ sudo reboot\n```\n\nIf that did not help you can make globally accessible hardware interfaces\nwith a udev rule. Only do this if everything else failed and you are\nreasoably confident you are the only one having access to your Pi.\n\nGo into the `/etc/udev/rules.d` folder and add a new file named\n`local.rules`.\n```\n$ cd /etc/udev/rules.d/\n$ sudo touch local.rules\n```\nThen add a single line `ACTION==\"add\", KERNEL==\"i2c-[0-1]*\", MODE=\"0666\"`\nto the file with your favorite editor.\n```\n$ sudo vi local.rules\n```\n\n## Contributing\n\n**Contributions are welcome!**\n\nWe develop and test this driver using our company internal tools (version\ncontrol, continuous integration, code review etc.) and automatically\nsynchronize the master branch with GitHub. But this doesn't mean that we don't\nrespond to issues or don't accept pull requests on GitHub. In fact, you're very\nwelcome to open issues or create pull requests :)\n\nThis Sensirion library uses\n[`clang-format`](https://releases.llvm.org/download.html) to standardize the\nformatting of all our `.c` and `.h` files. Make sure your contributions are\nformatted accordingly:\n\nThe `-i` flag will apply the format changes to the files listed.\n\n```bash\nclang-format -i *.c *.h\n```\n\nNote that differences from this formatting will result in a failed build until\nthey are fixed.\n\n\n## License\n\nSee [LICENSE](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsensirion%2Fraspberry-pi-i2c-stc3x","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsensirion%2Fraspberry-pi-i2c-stc3x","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsensirion%2Fraspberry-pi-i2c-stc3x/lists"}