Coder Social home page Coder Social logo

sht1x's Introduction

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

sht1x's People

Contributors

griffina avatar

Watchers

Mattt Eliot avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.