https://github.com/ndoornekamp/senseair_s8
Python module for reading CO2 concentration from a Senseair S8 sensor connected to a Raspberry Pi
https://github.com/ndoornekamp/senseair_s8
co2 co2-sensor python python-3 raspberry-pi senseair-s8
Last synced: 9 months ago
JSON representation
Python module for reading CO2 concentration from a Senseair S8 sensor connected to a Raspberry Pi
- Host: GitHub
- URL: https://github.com/ndoornekamp/senseair_s8
- Owner: ndoornekamp
- License: mit
- Created: 2020-11-15T13:44:19.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-11-28T18:54:41.000Z (over 2 years ago)
- Last Synced: 2025-02-01T12:44:13.518Z (over 1 year ago)
- Topics: co2, co2-sensor, python, python-3, raspberry-pi, senseair-s8
- Language: Python
- Homepage:
- Size: 231 KB
- Stars: 13
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Senseair S8 for Python
Python module for reading CO2 concentration from a Senseair S8 sensor connected to a Raspberry Pi
## Connecting the Senseair S8 to your Raspberry Pi
Hook up the Senseair S8 to your Raspberry Pi using the following schematic:

Image source:
## Module installation
```bash
pip install senseair-s8
```
## Usage
As a module:
```python
from senseair_s8 import SenseairS8, SenseairS8Exception
sensor = SenseairS8()
try:
co2 = sensor.co2()
print(f"CO2 concentration: {co2} ppm")
except SenseairS8Exception as e:
print(f"Failed to read CO2: {e}")
```
From the command line (this logs the CO2 concentration at ~1 second intervals):
```bash
python -m senseair_s8
```
## Troubleshooting
- This module expects the sensor to be connected to port `/dev/ttyS0`. It was only tested using that port, but you can override this setting when initializing the sensor:
```python
sensor = SenseairS8(port='/dev/ttyS0')
```
- Out of the box, `/dev/ttyS0` is disabled on a Raspberry Pi, resulting in a `permission denied` error. You can enable it by:
1. Run `sudo raspi-config`
2. Select Interfacing options
3. Select P6 Serial
4. Select No for login console
5. Select Yes for serial port hardware
6. OK, Finish, Reboot - Yes