mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-04 23:17:47 +00:00
0f7b458d9c
Signed-off-by: Ron Evans <ron@hybridgroup.com>
74 lines
2.4 KiB
Markdown
74 lines
2.4 KiB
Markdown
# TinyGo Drivers
|
|
|
|
[](https://godoc.org/github.com/tinygo-org/drivers)
|
|
|
|
This package provides a collection of hardware drivers for devices that can be used together with [TinyGo](https://tinygo.org).
|
|
|
|
## Installing
|
|
|
|
```shell
|
|
go get github.com/tinygo-org/drivers
|
|
```
|
|
|
|
## How to use
|
|
|
|
Here is an example in TinyGo that uses the BMP180 digital barometer:
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"time"
|
|
|
|
"machine"
|
|
|
|
"github.com/tinygo-org/drivers/bmp180"
|
|
)
|
|
|
|
func main() {
|
|
machine.I2C0.Configure(machine.I2CConfig{})
|
|
sensor := bmp180.New(machine.I2C0)
|
|
sensor.Configure()
|
|
|
|
connected := sensor.Connected()
|
|
if !connected {
|
|
println("BMP180 not detected")
|
|
return
|
|
}
|
|
println("BMP180 detected")
|
|
|
|
for {
|
|
temp, _ := sensor.Temperature()
|
|
println("Temperature:", float32(temp)/1000, "ºC")
|
|
|
|
pressure, _ := sensor.Pressure()
|
|
println("Pressure", float32(pressure)/100000, "hPa")
|
|
|
|
time.Sleep(2 * time.Second)
|
|
}
|
|
}
|
|
```
|
|
|
|
## Currently supported devices
|
|
|
|
| Device Name | Interface Type |
|
|
|----------|-------------|
|
|
| [APA102 RGB LED](https://cdn-shop.adafruit.com/product-files/2343/APA102C.pdf) | SPI |
|
|
| [BH1750 ambient light sensor](https://www.mouser.com/ds/2/348/bh1750fvi-e-186247.pdf) | I2C |
|
|
| [BlinkM RGB LED](http://thingm.com/fileadmin/thingm/downloads/BlinkM_datasheet.pdf) | I2C |
|
|
| [BMP180 barometer](https://cdn-shop.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf) | I2C |
|
|
| ["Easystepper" stepper motor controller](https://en.wikipedia.org/wiki/Stepper_motor) | GPIO |
|
|
| [ESP8266/ESP32 AT Command set for WiFi/TCP/UDP](https://github.com/espressif/esp32-at) | UART |
|
|
| [MAG3110 magnetometer](https://www.nxp.com/docs/en/data-sheet/MAG3110.pdf) | I2C |
|
|
| [MMA8653 accelerometer](https://www.nxp.com/docs/en/data-sheet/MMA8653FC.pdf) | I2C |
|
|
| [MPU6050 accelerometer/gyroscope](https://store.invensense.com/datasheets/invensense/MPU-6050_DataSheet_V3%204.pdf) | I2C |
|
|
| [WS2812 RGB LED](https://cdn-shop.adafruit.com/datasheets/WS2812.pdf) | GPIO |
|
|
|
|
## Contributing
|
|
|
|
This collection of drivers is part of the [TinyGo](https://github.com/tinygo-org/tinygo) project. Patches are welcome but new drivers should follow the patterns established by similar existing drivers.
|
|
|
|
## License
|
|
|
|
This project is licensed under the BSD 3-clause license, just like the [Go project](https://golang.org/LICENSE) itself.
|