项目作者: d2r2

项目描述 :
Golang library to interact with Sensirion SHT3x relative humidity and temperature sensor's family via I2C-bus from Raspberry PI.
高级语言: Go
项目地址: git://github.com/d2r2/go-sht3x.git
创建时间: 2018-10-14T02:44:27Z
项目社区:https://github.com/d2r2/go-sht3x

开源协议:MIT License

下载


Sensirion SHT3x relative humidity and temperature sensor’s family

Build Status
Go Report Card
GoDoc
MIT License

SHT30, SHT31, SHT35 (general specification, alert mode specification) high accuracy temperature and relative humidity sensor. Easily integrated with Arduino and Raspberry PI via i2c communication interface:
image

This sensor has extra feature - integrated heater which could be helpfull in some specific application (such as periodic condensate removal, for example).

Here is a library written in Go programming language for Raspberry PI and counterparts, which gives you in the output relative humidity and temperature values (making all necessary i2c-bus interracting and values computing).

Golang usage

  1. func main() {
  2. // Create new connection to i2c-bus on 0 line with address 0x44.
  3. // Use i2cdetect utility to find device address over the i2c-bus
  4. i2c, err := i2c.NewI2C(0x44, 0)
  5. if err != nil {
  6. log.Fatal(err)
  7. }
  8. defer i2c.Close()
  9. sensor := sht3x.NewSHT3X()
  10. temp, rh, err := sensor.ReadTemperatureAndRelativeHumidity(i2c, sht3x.REPEATABILITY_LOW)
  11. if err != nil {
  12. log.Fatal(err)
  13. }
  14. log.Printf("Temperature and relative humidity = %v*C, %v%%", temp, rh)

Getting help

GoDoc documentation

Installation

  1. $ go get -u github.com/d2r2/go-sht3x

Troubleshoting

  • How to obtain fresh Golang installation to RPi device (either any RPi clone):
    If your RaspberryPI golang installation taken by default from repository is outdated, you may consider
    to install actual golang mannualy from official Golang site. Download
    tar.gz file containing armv6l in the name. Follow installation instructions.

  • How to enable I2C bus on RPi device:
    If you employ RaspberryPI, use raspi-config utility to activate i2c-bus on the OS level.
    Go to “Interfaceing Options” menu, to active I2C bus.
    Probably you will need to reboot to load i2c kernel module.
    Finally you should have device like /dev/i2c-1 present in the system.

  • How to find I2C bus allocation and device address:
    Use i2cdetect utility in format “i2cdetect -y X”, where X may vary from 0 to 5 or more,
    to discover address occupied by peripheral device. To install utility you should run
    apt install i2c-tools on debian-kind system. i2cdetect -y 1 sample output:

    1. 0 1 2 3 4 5 6 7 8 9 a b c d e f
    2. 00: -- -- -- -- -- -- -- -- -- -- -- -- --
    3. 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    4. 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    5. 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    6. 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    7. 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    8. 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    9. 70: -- -- -- -- -- -- 76 --

Contact

Please use Github issue tracker for filing bugs or feature requests.

License

Go-sht3x is licensed under MIT License.