Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pvainio/scd30
Sensirion SCD30 CO2 sensor I2C driver
https://github.com/pvainio/scd30
co2 co2-sensor i2c i2c-device i2c-sensors iot scd30 sensirion sensirion-scd30
Last synced: 21 days ago
JSON representation
Sensirion SCD30 CO2 sensor I2C driver
- Host: GitHub
- URL: https://github.com/pvainio/scd30
- Owner: pvainio
- License: gpl-3.0
- Created: 2021-11-01T09:45:50.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-10T20:06:21.000Z (about 2 years ago)
- Last Synced: 2024-11-30T04:06:10.471Z (25 days ago)
- Topics: co2, co2-sensor, i2c, i2c-device, i2c-sensors, iot, scd30, sensirion, sensirion-scd30
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sensirion SCD30 CO2 sensor i2c driver module for Golang
## Overview
With this module Sensirion SCD30 CO2 sensor can be accessed throug i2c bus.
Implemented:
- starting and stopping continuous measurements
- checking for ready measurement
- reading ready measurement
- getting and setting temperature compensation## Example
```go
package mainimport (
"log"
"time""github.com/pvainio/scd30"
"periph.io/x/conn/v3/i2c/i2creg"
"periph.io/x/host/v3"
)func main() {
if _, err := host.Init(); err != nil {
log.Fatal(err)
}bus, err := i2creg.Open("")
if err != nil {
log.Fatal(err)
}
defer bus.Close()dev, err := scd30.Open(bus)
if err != nil {
log.Fatal(err)
}var interval uint16 = 5
dev.StartMeasurements(interval)
for {
time.Sleep(time.Duration(interval) * time.Second)
if hasMeasurement, err := dev.HasMeasurement(); err != nil {
log.Fatalf("error %v", err)
} else if !hasMeasurement {
return
}m, err := dev.GetMeasurement()
if err != nil {
log.Fatalf("error %v", err)
}log.Printf("Got measure %f ppm %f%% %fC", m.CO2, m.Humidity, m.Temperature)
}
}
```