Sensirion SCD30 CO2 sensor i2c driver module for Golang

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

package main

import (
	"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)
	}
}
Similar Resources

A simple project/module generated tool written in go

A module generator written in go This is a project/module generator written in go. It is intended to generate standard project/module layouts in the t

Oct 17, 2022

Module to ease interaction with Pact's development server & ScalableBFT

go-pact Module to ease interaction with Pact's development server & ScalableBFT Install go install github.com/jfamousket/go-pact@latest Functions H

Dec 9, 2021

A go module for "friendly" IDs

go-eyed A go module for "friendly" IDs. THIS MODULE IS INCOMPLETE AND NOT CURRENTLY BEING MAINTAINED. THEREFORE, IT SHOULD NOT BE USED Contribution If

Dec 17, 2021

ProtonMail module for waybar/polybar/yabar/i3blocks

protoncheck  lightweight, fast waybar/polybar/yabar/i3blocks module to check the amount of unread emails in a ProtonMail inbox. Installation You may

Sep 27, 2022

Flesch-go - Go-based implementation of the Flesch reading ease readability formula module.

flesch-go Go-based implementation of the Flesch reading ease readability formula module. Thanks for the flesch-index project. Installation Run the fol

Nov 9, 2022

Go-poolsuite - Poolsuite FM player as Go module

go-poolsuite Poolsuite FM (formerly Poolside FM) player as a Go module. Example

May 4, 2022

Gosfdc module - a collection of packages containing the data structures from the various Salesforce APIs and Tools

Gosfdc module - a collection of packages containing the data structures from the various Salesforce APIs and Tools

Jan 21, 2022

An interactive menu for Magisk's module installer with tools to alter Android

JD's Toolbox I'll update this with some details later, just getting the source code out for now... LICENSE The source code for JD's Toolbox is release

Jan 24, 2022

gonewire: one wire library that uses the w1 kernel module

gonewire one wire library that uses the w1 kernel module. current support: DS18(S)20

Jan 25, 2022
Related tags
Some plain Go/Golang i2c sensor bindings to Waveshare Sense HAT for raspberry pi

i2c some plain Go/Golang i2c sensor bindings to Waveshare Sense HAT for raspberry pi using https://periph.io Supported hardware: Raspberry Zero W 1 ht

Dec 31, 2021
A go driver for the adafruit I2C 7 Segment display

A go driver for the adafruit I2C 7 Segment display

Nov 21, 2021
A simple LCD controller package for raspberry pi liquid crystal I²C displays.

A simple LCD controller package for raspberry pi liquid crystal I²C displays.

Nov 1, 2022
A reimplementation of the TinyGo drivers package for communicating with multiples of the same (supported) devices on one individual I2C bus.

tinygo-multi-i2c A reimplementation of the TinyGo drivers package for communicating with multiples of the same (supported) devices on one individual I

Mar 10, 2022
Go/TinyGo driver for Lumissil IS31FL3731 matrix LED driver
Go/TinyGo driver for Lumissil IS31FL3731 matrix LED driver

IS31FL3731 Go/TinyGo driver for Lumissil IS31FL3731 matrix LED driver. PR to include this driver to the official TinyGo driver list What's implemented

Feb 6, 2022
A Go library for reading sensor data from the Adafruit SCD-40 and SCD-41

A Go module for reading CO2, temperature, and humidity data from the Sesirion SCD4x family of sensors. Example sensors are the Adafruit SCD-40 and Adafruit SCD-41. The former was used during the development of this module.

Dec 23, 2022
Golang-module-references - A reference for how to setup a Golang project with modules - Task Management + Math Examples

Golang Module Project The purpose of this project is to act as a reference for setting up future Golang projects using modules. This project has a mat

Jan 2, 2022
Watchdog for the unreliable nut-driver on the Raspberry Pi

nut-watcher For some reason, nut-driver on the Raspberry Pi likes to break. Every few days it stalls out trying to talk to my UPS. nut-watcher is a si

Dec 6, 2021
Sa818 - Sa818 UHF/VHF walkie talkie module control library for golang
Sa818 - Sa818 UHF/VHF walkie talkie module control library for golang

SA818 golang library for serial control This library written in Go programming l

Jan 23, 2022
Elytrium Billing: Module-based billing platform made with Go

In development Elling - Elytrium Billing Module-based billing platform made with Go The main idea of this product - make a stable billing platform for

Jun 4, 2022