Skip to content
/ SHT1x Public

Golang interface for the Sensirion SHT (SHT71/SHT75/SHT15/SHT11/SHT10) Temperature and Humidity sensors

Notifications You must be signed in to change notification settings

griffina/SHT1x

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

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

SHT1x Datasheet

TODO:

  • Calculate the CRC
  • Return errors on failures
  • Some tests

About

Golang interface for the Sensirion SHT (SHT71/SHT75/SHT15/SHT11/SHT10) Temperature and Humidity sensors

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages