Mike Hughes 936a255df9 Add support for CEVA BNO08x 9DoF sensor (#809)
* Add support for CEVA BNO08x 9DoF sensor. Also includes implementation of CEVA SH-2 and SHTP protocols.

* Replace machine.I2C with drivers.I2C interface to remove dependency on machine package

* Replace Pin functionality with that provided by tinygo.org/x/drivers/internal/pin

* Unexport fields on SensorValue and replace with accessor methods. Add check for correct SensorID validation

* Add example to smoketest.sh

* Change build target for smoketest to match development environment.. Probably not important, but matches reality.

* Fix decoding of some sensor data: Step Counter, Tap Detector, Flip Detector. These are experimental.

* Refactor to allow SPI/UART etc. SPI is currently under development, but is omitted from this commit.

Example code has been moved to i2c subdirectory.

This commit introduces some major refactoring changes. It introduces a "Buser" interface and tries to remove any I2C specific code from the core. It still retains a couple of I2C specific fields in the "Config" struct ("Address" and "ReadChunk") but they are ignored in the as yet uncommited SPI code.

* Fix CRLF -> LF for gofmt

* Update smoketest to point to new example file
2025-12-10 19:07:04 +01:00
2023-07-02 18:30:11 +02:00
2025-01-18 07:45:09 +01:00
2023-07-02 18:30:11 +02:00
2025-11-11 10:42:28 +01:00
2023-07-02 18:30:11 +02:00
2023-07-02 18:30:11 +02:00
2022-09-25 13:23:16 +02:00
2022-09-25 13:23:16 +02:00
2023-07-02 18:30:11 +02:00
2025-11-11 10:42:28 +01:00
2023-07-02 18:30:11 +02:00
2023-07-02 18:30:11 +02:00
2025-11-11 10:42:28 +01:00
2022-12-21 17:47:14 -05:00
2024-10-23 12:32:32 +01:00
2023-07-02 18:30:11 +02:00
2025-11-11 10:22:28 +01:00
2025-08-10 10:05:18 +02:00
2025-11-11 10:42:28 +01:00
2022-09-25 13:23:16 +02:00
2025-08-13 09:39:18 +02:00
2025-11-11 10:42:28 +01:00
2022-09-25 13:23:16 +02:00
2023-07-02 18:30:11 +02:00
2025-01-04 16:20:10 +01:00
2024-10-24 07:45:33 +02:00
2023-07-02 18:30:11 +02:00
2021-03-26 18:10:39 +01:00
2023-07-02 18:30:11 +02:00
2022-09-25 13:23:16 +02:00
2022-09-25 13:23:16 +02:00
2023-07-02 18:30:11 +02:00
2023-07-02 18:30:11 +02:00
2023-07-02 18:30:11 +02:00
2023-07-02 18:30:11 +02:00
2025-11-11 10:42:28 +01:00
2025-11-11 10:42:28 +01:00
2025-11-11 10:42:28 +01:00
2022-09-25 13:23:16 +02:00
2023-07-02 18:30:11 +02:00
2023-07-02 18:30:11 +02:00
2023-05-20 15:49:13 +02:00
2023-08-27 11:38:33 +02:00
2024-10-23 12:32:32 +01:00
2023-07-02 18:30:11 +02:00
2025-11-11 10:42:28 +01:00
2023-09-20 19:14:17 +02:00
2023-07-02 18:30:11 +02:00
2022-09-25 13:23:16 +02:00
2023-10-25 09:57:40 +02:00
2025-01-28 12:17:12 +01:00
2022-09-25 13:23:16 +02:00
2023-09-19 08:31:43 +02:00
2022-09-25 13:23:16 +02:00
2023-07-02 18:30:11 +02:00
2022-09-25 13:23:16 +02:00
2022-09-25 13:23:16 +02:00
2025-05-20 12:27:30 +02:00
2023-07-02 18:30:11 +02:00
2022-09-25 13:23:16 +02:00
2023-05-21 00:32:05 +02:00
2022-09-25 13:23:16 +02:00
2022-09-25 13:23:16 +02:00
2025-08-10 10:05:18 +02:00
2021-12-14 09:14:10 +09:00
2021-03-28 12:23:16 +02:00
2022-09-25 13:23:16 +02:00
2023-07-02 18:30:11 +02:00
2025-03-04 10:11:02 -08:00
2021-04-02 17:31:28 +02:00

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.

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%