tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/README.md (about) 1 # TinyGo Drivers 2 3 [![PkgGoDev](https://pkg.go.dev/badge/tinygo.org/x/drivers)](https://pkg.go.dev/tinygo.org/x/drivers) [![Build](https://github.com/tinygo-org/drivers/actions/workflows/build.yml/badge.svg?branch=dev)](https://github.com/tinygo-org/drivers/actions/workflows/build.yml) 4 5 6 This package provides a collection of 102 different hardware drivers for devices such as sensors and displays that can be used together with [TinyGo](https://tinygo.org). 7 8 For the complete list, please see: 9 https://tinygo.org/docs/reference/devices/ 10 11 ## Installing 12 13 ```shell 14 go get tinygo.org/x/drivers 15 ``` 16 17 ## How to use 18 19 Here is an example in TinyGo that uses the BMP180 digital barometer: 20 21 ```go 22 package main 23 24 import ( 25 "time" 26 27 "machine" 28 29 "tinygo.org/x/drivers/bmp180" 30 ) 31 32 func main() { 33 machine.I2C0.Configure(machine.I2CConfig{}) 34 sensor := bmp180.New(machine.I2C0) 35 sensor.Configure() 36 37 connected := sensor.Connected() 38 if !connected { 39 println("BMP180 not detected") 40 return 41 } 42 println("BMP180 detected") 43 44 for { 45 temp, _ := sensor.ReadTemperature() 46 println("Temperature:", float32(temp)/1000, "°C") 47 48 pressure, _ := sensor.ReadPressure() 49 println("Pressure", float32(pressure)/100000, "hPa") 50 51 time.Sleep(2 * time.Second) 52 } 53 } 54 ``` 55 56 ## Contributing 57 58 Your contributions are welcome! 59 60 Please take a look at our [CONTRIBUTING.md](./CONTRIBUTING.md) document for details. 61 62 ## License 63 64 This project is licensed under the BSD 3-clause license, just like the [Go project](https://golang.org/LICENSE) itself.