Skip to content

oltoko/go-am2320

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Go Report Card GoDoc

go-am2320

Code to access an AM2320 via i2c on Raspberry Pi. Also see Datasheet.

Usage

package main

import (
    "log"

    "github.com/oltoko/go-am2320"
)

func main() {

    sensor := am2320.Create(am2320.DefaultI2CAddr)

    values, err := sensor.Read()
    if err != nil {
        log.Fatalln("Failed to read from Sensor", err)
    }

    log.Printf("%.2f °C", values.Temperature)
    log.Printf("%.2f %%", values.Humidity)
}