SHT1x

Created: 2014-05-18 21:05
Updated: 2015-06-25 19:10
go

README.md

SHT1x

SHT1x is a Golang implementation of Luca Nobili's rpiSht1x

For using the Sensirion SHT (SHT71/SHT75/SHT15/SHT11/SHT10) series of temperature and humidity sensors on a Raspberry Pi in Go.

Using a modified version of gpio for Go

Full example

This needs to be run as root

package main

import "fmt"
import "github.com/griffina/SHT1x"
import "github.com/griffina/gpio/rpi"

func main() {

	fmt.Println("Create SHT sensor")
	sht := SHT1x.New(rpi.GPIO_P1_11, rpi.GPIO_P1_07)

	fmt.Println("read temp")
	temp := sht.ReadTemperature()
	fmt.Printf("temp (°C): %.2f\n", temp)

	humid := sht.ReadHumidity()
	fmt.Printf("Humid (rel%%): %.2f\n", humid)

	temp2, humid2 := sht.ReadTempAndHumidity()

	fmt.Printf("temp (°C): %.2f\n", temp2)
	fmt.Printf("Humid (rel%%): %.2f\n", humid2)

	sht.CleanUp()

}

To install the SHT1x package:

go get github.com/griffia/SHT1x

To build Go on the Raspberry Pi follow these instructions

Documentation

SHT1x Datasheet

TODO:

  • Calculate the CRC
  • Return errors on failures
  • Some tests
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more