Skip to content

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.

License

Notifications You must be signed in to change notification settings

tinygo-org/drivers

Folders and files

NameName
Last commit message
Last commit date
Oct 23, 2024
Oct 6, 2023
Jul 2, 2023
Feb 24, 2024
Jan 18, 2025
Jul 2, 2023
May 30, 2021
Jul 2, 2023
Aug 8, 2023
Oct 6, 2023
Jul 2, 2023
Sep 25, 2022
Sep 25, 2022
Aug 8, 2023
Jul 2, 2023
May 30, 2021
Jul 2, 2023
Jul 2, 2023
Jul 2, 2023
Dec 19, 2022
Sep 18, 2021
Feb 21, 2025
Oct 5, 2023
Dec 21, 2022
Jul 2, 2023
Oct 23, 2024
Jul 2, 2023
Jun 12, 2022
Feb 29, 2024
Jun 14, 2024
Mar 11, 2025
Dec 21, 2022
Apr 21, 2024
Sep 25, 2022
Apr 13, 2023
Apr 12, 2020
Sep 25, 2022
Sep 25, 2022
Jul 2, 2023
Jan 4, 2025
May 14, 2023
Mar 11, 2025
Dec 21, 2022
Oct 24, 2024
Jul 2, 2023
Jul 2, 2023
Jul 13, 2022
Jul 2, 2023
Mar 26, 2021
Sep 25, 2022
Jul 2, 2023
Sep 25, 2022
Jul 2, 2023
Jul 2, 2023
Oct 26, 2023
Aug 8, 2023
Jul 2, 2023
Jul 2, 2023
Jul 2, 2023
Jul 2, 2023
Jul 2, 2023
Jul 2, 2023
Sep 16, 2022
Mar 11, 2025
Mar 11, 2025
Jul 2, 2023
Dec 11, 2023
Sep 25, 2022
May 12, 2024
Dec 21, 2022
Dec 18, 2024
Jul 2, 2023
Jul 2, 2023
May 20, 2023
Aug 27, 2023
Aug 11, 2023
Mar 4, 2025
Feb 21, 2025
Oct 23, 2024
Mar 11, 2025
Jul 2, 2023
Sep 25, 2022
Sep 20, 2023
May 10, 2021
Oct 29, 2024
Oct 28, 2024
Jul 2, 2023
Apr 1, 2024
Sep 25, 2022
May 20, 2023
Dec 4, 2023
Sep 25, 2022
Oct 23, 2024
Dec 1, 2023
Oct 25, 2023
Jan 28, 2025
Dec 21, 2022
Mar 4, 2020
Sep 25, 2022
Sep 19, 2023
Sep 25, 2022
Dec 21, 2022
Oct 27, 2024
Sep 25, 2022
Sep 25, 2022
Nov 23, 2023
Nov 23, 2023
Mar 20, 2023
Mar 11, 2025
Jul 2, 2023
Sep 25, 2022
Sep 25, 2022
Jan 28, 2025
Mar 11, 2025
Jul 2, 2023
Sep 25, 2022
Oct 25, 2024
May 20, 2023
Oct 27, 2024
Sep 25, 2022
Nov 15, 2022
Sep 25, 2022
Mar 11, 2025
Apr 1, 2024
Dec 4, 2023
Dec 14, 2021
Mar 28, 2021
Mar 4, 2025
Jul 30, 2020
Mar 4, 2025
Jun 10, 2024
Dec 6, 2023
Aug 25, 2024
Apr 27, 2023
Sep 25, 2022
Feb 18, 2025
Feb 18, 2025
Jul 2, 2023
Aug 11, 2023
Dec 6, 2023
Feb 21, 2025
Dec 15, 2020
Apr 2, 2021
Mar 4, 2025

Repository files navigation

TinyGo Drivers

PkgGoDev Build

This package provides a collection of over 100 different hardware drivers for devices such as sensors, displays, wireless adaptors, and actuators, that can be used together with TinyGo.

For the complete list, please see: https://tinygo.org/docs/reference/devices/

Installing

go get tinygo.org/x/drivers

How to use

Here is an example in TinyGo that uses the BMP180 digital barometer. This example should work on any board that supports I2C:

package main

import (
    "time"

    "machine"

    "tinygo.org/x/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)
    }
}

Examples Using GPIO or SPI

If compiling these examples directly you are likely to need to make minor changes to the defined variables to map the pins for the board you are using. For example, this block in main.go:

var (
        spi   = machine.SPI0
        csPin = machine.D5
)

It might not be obvious, but you need to change these to match how you wired your specific board. Constants are defined for each supported microcontroller.

For example, to change the definitions for use on a Raspberry Pi Pico using typical wiring, you might need to do this:

var (
        spi   = machine.SPI0
        csPin = machine.GP17
)

Contributing

Your contributions are welcome!

Please take a look at our CONTRIBUTING.md document for details.

License

This project is licensed under the BSD 3-clause license, just like the Go project itself.