A Go library for reading sensor data from the Adafruit SCD-40 and SCD-41

scd4x

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.

Scope

The module implements the following sensor functions through an i2c bus:

  • Starting periodic measurements
  • Reading the current sensor values
  • Stopping periodic measurements

Once the sensor has started periodic measurements, it automatically records new sensor data every 5 seconds into its internal buffer. A ReadMeasurement call retrieves the most recent sensor data from SCD4x.

Example CLI Monitor

The example_monitor.go provides a simple CLI monitor with syntax similar to other CLI tools like iostat and vmstat.

Installation

Clone this repository and navigate to the examples/ directory. Then build with go.

go build example_monitor.go

You should now have an executable file called example_monitor

Syntax

pi@sliceofpi:~/scd4x/examples $ ./example_monitor -h
Usage:
 ./example_monitor [options] [delay [count]]
  -f	Use degrees Fahrenheit (default: Celsius)
  -init
    	Get sensor in state ready for measurements.
  -v	Verbose output

Like other system tools, delay is the number of seconds to wait between measurements, and count is the total number of measurements to take. Both field are optional. Not specifying the delay will take one measurement and exit. Specifying a delay but not a count will run the monitor indefinitely, until it receives an interrupt (e.g. Ctrl+C).

If you're not sure what state the sensor is in, i.e. whether its in an idle state or already in a periodic measurement state, you can use the --init flag, which will issue a StopMeasurement followed by a StartMeasurement command. The --init operation takes about 7 seconds to complete. You should only ever need to use the flag once.

Output

Verbose output:

pi@sliceofpi:~/scd4x/examples $ ./example_monitor -f -v 10
Time                            CO2   Temp    RH
[2022-01-30T10:31:10-07:00]  801ppm 71.0*F 18.9%
[2022-01-30T10:31:20-07:00]  782ppm 70.9*F 19.0%
[2022-01-30T10:31:30-07:00]  780ppm 70.9*F 19.0%
[2022-01-30T10:31:40-07:00]  780ppm 70.9*F 18.9%
[2022-01-30T10:31:50-07:00]  780ppm 70.9*F 18.9%

Minimal output:

pi@sliceofpi:~/scd4x/examples $ ./example_monitor -f 10
665 71.0 18.1
665 71.0 18.1
663 71.0 18.0
663 71.0 18.0
663 71.0 18.0
663 71.1 18.0
Similar Resources

Gountries provides: Countries (ISO-3166-1), Country Subdivisions(ISO-3166-2), Currencies (ISO 4217), Geo Coordinates(ISO-6709) as well as translations, country borders and other stuff exposed as struct data.

gountries Inspired by the countries gem for ruby. Countries (ISO-3166-1), Country Subdivisions(ISO-3166-2), Currencies (ISO 4217), Geo Coordinates(ISO

Dec 22, 2022

Self hosted search engine for data leaks and password dumps

Self hosted search engine for data leaks and password dumps

Self hosted search engine for data leaks and password dumps. Upload and parse multiple files, then quickly search through all stored items with the power of Elasticsearch.

Aug 2, 2021

Tool, language and decoders for inspecting binary data.

fq Tool, language and decoders for inspecting binary data. In most cases fq works the same way as jq but instead of reading JSON it reads binary data.

Jan 4, 2023

This utility parses stackoverflow data and pushes it to Zinc/Elasticsearch

Gostack This utility parses stackoverflow data and pushes it to Zinc/Elasticsear

Jun 8, 2022

Quickly collect data from thousands of exposed Elasticsearch or Kibana instances and generate a report to be reviewed.

Quickly collect data from thousands of exposed Elasticsearch or Kibana instances and generate a report to be reviewed.

elasticpwn Quickly collects data from exposed Elasticsearch or Kibana instances and generates a report to be reviewed. It mainly aims for sensitive da

Nov 9, 2022

Store - Read and write data structures

Store - Read and write data structures Store provides the ability to write the data structures to a file and read from a file in the Go programming la

Jan 3, 2022

batcher collect a data and flush it if the batch is full or the interval is elapsed.

Batcher batcher collect a data and flush it if the batch is full or the interval is elapsed. Installation go get github.com/gotidy/batcher Examples ba

Jan 6, 2022

Decrypts and dumps K3s bootstrap data read from stdin.

k3s-dump-bootstrap Decrypts and dumps K3s bootstrap data read from stdin. Note: token parameter should be just the bare passphrase, not a full K10-f

Jan 12, 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
Related tags
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. Implement

Oct 9, 2022
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 challenge in Go. A simple backend responding to API calls reading/writing data from to PostgreSQL db.

Go Challenge The challenge has been executed in two different steps. Steps 1 Hour tag: 1 hour: As the challenge required, the tag is a snapshot of wha

Dec 4, 2021
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
traning helper. Reading real METARs

pptrain Train reading real METARs Example: $ pptrain

Jan 23, 2022
Exercise for solve problem data processing, performance and something wrong in passing data

Citcall Exercise Exercise for solve problem data processing, performance and something wrong in passing data Pengolahan data data processing - Readme

Nov 25, 2021
Go package providing tools for working with Library of Congress data.

go-libraryofcongress Go package providing tools for working with Library of Congress data. Documentation Tools $> make cli go build -mod vendor -o bin

Jan 3, 2023
Go package for working with Library of Congress data in an SFO Museum context.

go-sfomuseum-libraryofcongress Go package for working with Library of Congress data in an SFO Museum context. Documentation Documentation is incomplet

Oct 19, 2021
Library to work with MimeHeaders and another mime types. Library support wildcards and parameters.

Mime header Motivation This library created to help people to parse media type data, like headers, and store and match it. The main features of the li

Nov 9, 2022
Random fake data and struct generator for Go.

Faker Random fake data and struct generator for Go. More than 100 generator functions Struct generator Unique data generator Builtin types support Eas

Oct 3, 2022