mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-07-26 10:38:41 +00:00
c259da1f1788f80399f94943033add26378cbefe
Signed-off-by: Ron Evans <ron@hybridgroup.com>
i2c: refactor all i2c drivers to use Address property of Driver. Allows variations to override the default address as discussed in #14 (#30)
i2c: refactor all i2c drivers to use Address property of Driver. Allows variations to override the default address as discussed in #14 (#30)
i2c: refactor all i2c drivers to use Address property of Driver. Allows variations to override the default address as discussed in #14 (#30)
i2c: refactor all i2c drivers to use Address property of Driver. Allows variations to override the default address as discussed in #14 (#30)
i2c: refactor all i2c drivers to use Address property of Driver. Allows variations to override the default address as discussed in #14 (#30)
TinyGo Drivers
This package provides a collection of hardware drivers for devices that can be used together with TinyGo.
Installing
go get github.com/tinygo-org/drivers
How to use
Here is an example in TinyGo that uses the BMP180 digital barometer:
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.ReadTemperature()
println("Temperature:", float32(temp)/1000, "ºC")
pressure, _ := sensor.ReadPressure()
println("Pressure", float32(pressure)/100000, "hPa")
time.Sleep(2 * time.Second)
}
}
Currently supported devices
| Device Name | Interface Type |
|---|---|
| ADXL345 accelerometer | I2C |
| APA102 RGB LED | SPI |
| BH1750 ambient light sensor | I2C |
| BlinkM RGB LED | I2C |
| BMP180 barometer | I2C |
| DS3231 real time clock | I2C |
| "Easystepper" stepper motor controller | GPIO |
| ESP8266/ESP32 AT Command set for WiFi/TCP/UDP | UART |
| HUB75 RGB led matrix | SPI |
| LIS3DH accelerometer | I2C |
| MAG3110 magnetometer | I2C |
| BBC micro:bit LED matrix | GPIO |
| MMA8653 accelerometer | I2C |
| MPU6050 accelerometer/gyroscope | I2C |
| PCD8544 display | SPI |
| SHT3x Digital Humidity Sensor | I2C |
| SSD1306 OLED display | I2C / SPI |
| Thermistor | ADC |
| VL53L1X time-of-flight distance sensor | I2C |
| Waveshare 2.13" (B & C) e-paper display | SPI |
| WS2812 RGB LED | GPIO |
Contributing
This collection of drivers is part of the 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 itself.
Releases
10
Languages
Go
99.1%
Shell
0.7%