{"id":19738445,"url":"https://github.com/sensirion/raspberry-pi-i2c-sfa3x","last_synced_at":"2026-04-18T05:32:33.955Z","repository":{"id":149346058,"uuid":"348045058","full_name":"Sensirion/raspberry-pi-i2c-sfa3x","owner":"Sensirion","description":"RaspberryPi driver for Sensirion SFA3x sensor module","archived":false,"fork":false,"pushed_at":"2025-03-18T09:59:19.000Z","size":1123,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-18T10:39:10.095Z","etag":null,"topics":["driver","gas-sensor","i2c","raspberry-pi","sensirion","sfa30","sfa3x"],"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-03-15T16:31:04.000Z","updated_at":"2024-05-23T18:21:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"fcb683f6-dd24-4e55-b405-0c514d350ef1","html_url":"https://github.com/Sensirion/raspberry-pi-i2c-sfa3x","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Sensirion/raspberry-pi-i2c-sfa3x","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sensirion%2Fraspberry-pi-i2c-sfa3x","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sensirion%2Fraspberry-pi-i2c-sfa3x/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sensirion%2Fraspberry-pi-i2c-sfa3x/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sensirion%2Fraspberry-pi-i2c-sfa3x/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sensirion","download_url":"https://codeload.github.com/Sensirion/raspberry-pi-i2c-sfa3x/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sensirion%2Fraspberry-pi-i2c-sfa3x/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31957558,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"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","gas-sensor","i2c","raspberry-pi","sensirion","sfa30","sfa3x"],"created_at":"2024-11-12T01:14:16.381Z","updated_at":"2026-04-18T05:32:33.949Z","avatar_url":"https://github.com/Sensirion.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sensirion Raspberry Pi I²C SFA3X Driver\n\nThe repository provides a driver for setting up a SFA3X sensor to run on a Raspberry Pi over I²C.\n\n\u003cimg src=\"images/sfa3x.png\" width=\"300px\"\u003e\n\nClick [here](https://sensirion.com/products/catalog/SEK-SFA30) to learn more about the Sensirion SFA3X sensor.\n\n\n\nThe default I²C address of [SFA3X](https://sensirion.com/products/catalog/SFA30) is **0x5D**.\n\n\n\n## Connect the sensor\n\nYour sensor has 5 different connectors: VDD, GND, SDA, SCL, SEL.\nUse the following pins to connect your SFA3X:\n\n| *SFA3X* | *Cable Color*  |   *Raspberry Pi*   |\n| :----------------: | -------------- | ------------------ |\n| VDD | red | Pin 1\n| GND | black | Pin 6\n| SDA | green | Pin 3\n| SCL | yellow | Pin 5\n| SEL | blue | Pin 9\n\n\n\u003cimg src=\"images/raspi-i2c-pinout-3.3V-SEL.png\" width=\"400px\"\u003e\n\n\n### Detailed sensor pinout\n\n\u003cimg src=\"images/sfa3x-pinout.png\" width=\"300px\"\u003e\n\n| *Pin* | *Cable Color* | *Name* | *Description*  | *Comments* |\n|-------|---------------|:------:|----------------|------------|\n| 1 | red | VDD | Supply Voltage | 3.15V to 5.5V\n| 2 | black | GND | Ground |\n| 3 | green | SDA | I2C: Serial data input / output |\n| 4 | yellow | SCL | I2C: Serial clock input |\n| 5 | blue | SEL | Interface select | Pull to GND to select I2C (leaving it floating selects UART)\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 SFA3X driver from [Github](https://github.com/Sensirion/raspberry-pi-i2c-sfa3x) and extract the `.zip` on your Raspberry Pi\n- Connect the SFA3X sensor as explained in the [section above](#connect-the-sensor)\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-sfa3x`\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 sfa3x_i2c_example_usage\n       cc -Os -Wall -fstrict-aliasing -Wstrict-aliasing=1 -Wsign-conversion -fPIC -I. -o sfa3x_i2c_example_usage  sfa3x_i2c.h sfa3x_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 sfa3x_i2c_example_usage.c\n       ```\n- Test your connected sensor\n    - Run `./sfa3x_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 `./sfa3x_i2c_example_usage` but do not get sensor readings but something like this instead\n\n```\nError executing device_reset(): -1\nError executing get_device_marking(): -1\nError executing start_continuous_measurement(): -1\n...\n```\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 ./sfa3x_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\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-sfa3x","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsensirion%2Fraspberry-pi-i2c-sfa3x","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsensirion%2Fraspberry-pi-i2c-sfa3x/lists"}