TinyGo Drivers

GoDoc

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.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 SPI
BlinkM RGB LED I2C
BMP180 barometer I2C
MAG3110 magnetometer I2C
MMA8653 accelerometer I2C
MPU6050 accelerometer/gyroscope I2C
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.

S
Description
TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
Readme BSD-3-Clause 26 MiB
Latest
2026-04-21 08:44:44 +00:00
Languages
Go 99.1%
Shell 0.7%