drivers

package module
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2020 License: BSD-3-Clause Imports: 1 Imported by: 0

README

TinyGo Drivers

GoDoc CircleCI

This package provides a collection of hardware drivers for devices that can be used together with TinyGo.

Installing

go get tinygo.org/x/drivers

How to use

Here is an example in TinyGo that uses the BMP180 digital barometer:

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)
    }
}

Currently supported devices

The following 44 devices are supported.

Device Name Interface Type
ADT7410 I2C Temperature Sensor I2C
ADXL345 accelerometer I2C
APA102 RGB LED SPI
AT24CX 2-wire serial EEPROM I2C
BH1750 ambient light sensor I2C
BlinkM RGB LED I2C
BME280 humidity/pressure sensor I2C
BMP180 barometer I2C
Buzzer GPIO
DS1307 real time clock I2C
DS3231 real time clock I2C
"Easystepper" stepper motor controller GPIO
ESP32 as WiFi Coprocessor with Arduino nina-fw SPI
ESP8266/ESP32 AT Command set for WiFi/TCP/UDP UART
GPS module I2C/UART
HD44780 LCD controller GPIO
HUB75 RGB led matrix SPI
ILI9341 TFT color display SPI
L293x motor driver GPIO/PWM
L9110x motor driver GPIO/PWM
LIS3DH accelerometer I2C
LSM6DS3 accelerometer I2C
MAG3110 magnetometer I2C
MCP3008 analog to digital converter (ADC) SPI
BBC micro:bit LED matrix GPIO
Microphone - PDM I2S/PDM
MMA8653 accelerometer I2C
MPU6050 accelerometer/gyroscope I2C
PCD8544 display SPI
Resistive Touchscreen (4-wire) GPIO
Semihosting Debug
Shift register GPIO
SHT3x Digital Humidity Sensor I2C
SSD1306 OLED display I2C / SPI
SSD1331 TFT color display SPI
ST7735 TFT color display SPI
ST7789 TFT color display SPI
Thermistor ADC
VEML6070 UV light sensor I2C
VL53L1X time-of-flight distance sensor I2C
Waveshare 2.13" e-paper display SPI
Waveshare 2.13" (B & C) e-paper display SPI
WS2812 RGB LED GPIO

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.

Documentation

Overview

Package drivers provides a collection of hardware drivers for TinyGo (https://tinygo.org) for devices such as sensors and displays.

Here is an example in TinyGo that uses the BMP180 digital barometer:

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)
	}
}

Each individual driver is contained within its own sub-package within this package and there are no interdependencies in order to minimize the final size of compiled code that uses any of these drivers.

Index

Constants

View Source
const Version = "0.10.0"

Version returns a user-readable string showing the version of the drivers package for support purposes. Update this value before release of new version of software.

Variables

This section is empty.

Functions

This section is empty.

Types

type Displayer

type Displayer interface {
	// Size returns the current size of the display.
	Size() (x, y int16)

	// SetPizel modifies the internal buffer.
	SetPixel(x, y int16, c color.RGBA)

	// Display sends the buffer (if any) to the screen.
	Display() error
}

Directories

Path Synopsis
Package adxl345 provides a driver for the ADXL345 digital accelerometer.
Package adxl345 provides a driver for the ADXL345 digital accelerometer.
Package apa102 implements a driver for the APA102 SPI LED.
Package apa102 implements a driver for the APA102 SPI LED.
Package at24cx provides a driver for the AT24C32/64/128/256/512 2-wire serial EEPROM Datasheet: https://www.openimpulse.com/blog/wp-content/uploads/wpsc/downloadables/24C32-Datasheet.pdf
Package at24cx provides a driver for the AT24C32/64/128/256/512 2-wire serial EEPROM Datasheet: https://www.openimpulse.com/blog/wp-content/uploads/wpsc/downloadables/24C32-Datasheet.pdf
Package bh1750 provides a driver for the BH1750 digital Ambient Light Datasheet: https://www.mouser.com/ds/2/348/bh1750fvi-e-186247.pdf
Package bh1750 provides a driver for the BH1750 digital Ambient Light Datasheet: https://www.mouser.com/ds/2/348/bh1750fvi-e-186247.pdf
Package blinkm implements a driver for the BlinkM I2C RGB LED.
Package blinkm implements a driver for the BlinkM I2C RGB LED.
Package bme280 provides a driver for the BME280 digital combined humidity and pressure sensor by Bosch.
Package bme280 provides a driver for the BME280 digital combined humidity and pressure sensor by Bosch.
Package bmp180 provides a driver for the BMP180 digital pressure sensor by Bosch.
Package bmp180 provides a driver for the BMP180 digital pressure sensor by Bosch.
Package buzzer provides a very simplistic driver for a connected buzzer or low-fidelity speaker.
Package buzzer provides a very simplistic driver for a connected buzzer or low-fidelity speaker.
Package ds1307 provides a driver for the DS1307 RTC Datasheet: https://datasheets.maximintegrated.com/en/ds/DS1307.pdf
Package ds1307 provides a driver for the DS1307 RTC Datasheet: https://datasheets.maximintegrated.com/en/ds/DS1307.pdf
Package ds3231 provides a driver for the DS3231 RTC Datasheet: https://datasheets.maximintegrated.com/en/ds/DS3231.pdf
Package ds3231 provides a driver for the DS3231 RTC Datasheet: https://datasheets.maximintegrated.com/en/ds/DS3231.pdf
Package easystepper provides a simple driver to rotate a 4-wire stepper motor.
Package easystepper provides a simple driver to rotate a 4-wire stepper motor.
Package espat implements TCP/UDP wireless communication over serial with a separate ESP8266 or ESP32 board using the Espressif AT command set across a UART interface.
Package espat implements TCP/UDP wireless communication over serial with a separate ESP8266 or ESP32 board using the Espressif AT command set across a UART interface.
examples
apa102
Connects to an APA102 SPI RGB LED strip with 30 LEDS.
Connects to an APA102 SPI RGB LED strip with 30 LEDS.
apa102/itsybitsy-m0
This example demostrates how to control the "Dotstar" (APA102) LED included on the Adafruit Itsy Bitsy M0 board.
This example demostrates how to control the "Dotstar" (APA102) LED included on the Adafruit Itsy Bitsy M0 board.
blinkm
Connects to an BlinkM I2C RGB LED.
Connects to an BlinkM I2C RGB LED.
ds3231
Connects to an MAG3110 I2C magnetometer.
Connects to an MAG3110 I2C magnetometer.
espat/espconsole
This is a console to a ESP8266/ESP32 running on the device UART1.
This is a console to a ESP8266/ESP32 running on the device UART1.
espat/esphub
This is a sensor hub that uses a ESP8266/ESP32 running on the device UART1.
This is a sensor hub that uses a ESP8266/ESP32 running on the device UART1.
espat/espstation
This is a sensor station that uses a ESP8266 or ESP32 running on the device UART1.
This is a sensor station that uses a ESP8266 or ESP32 running on the device UART1.
espat/mqttclient
This is a sensor station that uses a ESP8266 or ESP32 running on the device UART1.
This is a sensor station that uses a ESP8266 or ESP32 running on the device UART1.
espat/mqttsub
This is a sensor station that uses a ESP8266 or ESP32 running on the device UART1.
This is a sensor station that uses a ESP8266 or ESP32 running on the device UART1.
espat/tcpclient
This is a sensor station that uses a ESP8266 or ESP32 running on the device UART1.
This is a sensor station that uses a ESP8266 or ESP32 running on the device UART1.
ili9341/pyportal_boing
Port of Adafruit's "pyportal_boing" demo found here: https://github.com/adafruit/Adafruit_ILI9341/blob/master/examples/pyportal_boing
Port of Adafruit's "pyportal_boing" demo found here: https://github.com/adafruit/Adafruit_ILI9341/blob/master/examples/pyportal_boing
lis3dh
Connects to a LIS3DH I2C accelerometer on the Adafruit Circuit Playground Express.
Connects to a LIS3DH I2C accelerometer on the Adafruit Circuit Playground Express.
lsm6ds3
Connects to an LSM6DS3 I2C a 6 axis Inertial Measurement Unit (IMU)
Connects to an LSM6DS3 I2C a 6 axis Inertial Measurement Unit (IMU)
mag3110
Connects to an MAG3110 I2C magnetometer.
Connects to an MAG3110 I2C magnetometer.
mcp3008
Connects to a MCP3008 ADC via SPI.
Connects to a MCP3008 ADC via SPI.
microphone
Example using the i2s hardware interface on the Adafruit Circuit Playground Express to read data from the onboard MEMS microphone.
Example using the i2s hardware interface on the Adafruit Circuit Playground Express to read data from the onboard MEMS microphone.
mma8653
Connects to an MMA8653 I2C accelerometer.
Connects to an MMA8653 I2C accelerometer.
mpu6050
Connects to an MPU6050 I2C accelerometer/gyroscope.
Connects to an MPU6050 I2C accelerometer/gyroscope.
thermistor
This example uses the settings for the thermistor that is built in to the Adafruit Circuit Playground Express.
This example uses the settings for the thermistor that is built in to the Adafruit Circuit Playground Express.
touch/resistive/fourwire
demo of 4-wire touchscreen as described in app note: http://ww1.microchip.com/downloads/en/Appnotes/doc8091.pdf
demo of 4-wire touchscreen as described in app note: http://ww1.microchip.com/downloads/en/Appnotes/doc8091.pdf
wifinina/mqttclient
This is a sensor station that uses a ESP8266 or ESP32 running on the device UART1.
This is a sensor station that uses a ESP8266 or ESP32 running on the device UART1.
wifinina/mqttsub
This is a sensor station that uses a ESP8266 or ESP32 running on the device UART1.
This is a sensor station that uses a ESP8266 or ESP32 running on the device UART1.
wifinina/tcpclient
This example opens a TCP connection using a device with WiFiNINA firmware and sends some data, for the purpose of testing speed and connectivity.
This example opens a TCP connection using a device with WiFiNINA firmware and sends some data, for the purpose of testing speed and connectivity.
wifinina/webclient
This example opens a TCP connection using a device with WiFiNINA firmware and sends a HTTP request to retrieve a webpage, based on the following Arduino example: https://github.com/arduino-libraries/WiFiNINA/blob/master/examples/WiFiWebClientRepeating/
This example opens a TCP connection using a device with WiFiNINA firmware and sends a HTTP request to retrieve a webpage, based on the following Arduino example: https://github.com/arduino-libraries/WiFiNINA/blob/master/examples/WiFiWebClientRepeating/
ws2812
Connects to an WS2812 RGB LED strip with 10 LEDS.
Connects to an WS2812 RGB LED strip with 10 LEDS.
Package gps provides a driver for GPS receivers over UART and I2C
Package gps provides a driver for GPS receivers over UART and I2C
Package hd44780 provides a driver for the HD44780 LCD controller.
Package hd44780 provides a driver for the HD44780 LCD controller.
Package hub75 implements a driver for the HUB75 LED matrix.
Package hub75 implements a driver for the HUB75 LED matrix.
Package l293x provides a driver to the L293/L293D H-bridge chip typically used to control DC motors.
Package l293x provides a driver to the L293/L293D H-bridge chip typically used to control DC motors.
Package l9110x provides a driver to the L9110/L9110S H-bridge chip typically used to control DC motors.
Package l9110x provides a driver to the L9110/L9110S H-bridge chip typically used to control DC motors.
Package lis3dh provides a driver for the LIS3DH digital accelerometer.
Package lis3dh provides a driver for the LIS3DH digital accelerometer.
Package lsm6ds3 implements a driver for the LSM6DS3 a 6 axis Inertial Measurement Unit (IMU) Datasheet: https://www.st.com/resource/en/datasheet/lsm6ds3.pdf
Package lsm6ds3 implements a driver for the LSM6DS3 a 6 axis Inertial Measurement Unit (IMU) Datasheet: https://www.st.com/resource/en/datasheet/lsm6ds3.pdf
Package mag3110 implements a driver for the MAG3110 3-axis magnetometer by Freescale/NXP.
Package mag3110 implements a driver for the MAG3110 3-axis magnetometer by Freescale/NXP.
Package mcp3008 implements a driver for the MCP3008 Analog to Digital Converter.
Package mcp3008 implements a driver for the MCP3008 Analog to Digital Converter.
Package microbitmatrix implements a driver for the BBC micro:bit's LED matrix.
Package microbitmatrix implements a driver for the BBC micro:bit's LED matrix.
Package microphone implements a driver for a PDM microphone.
Package microphone implements a driver for a PDM microphone.
Package mma8653 provides a driver for the MMA8653 3-axis accelerometer by Freescale/NXP.
Package mma8653 provides a driver for the MMA8653 3-axis accelerometer by Freescale/NXP.
Package mpu6050 provides a driver for the MPU6050 accelerometer and gyroscope made by InvenSense.
Package mpu6050 provides a driver for the MPU6050 accelerometer and gyroscope made by InvenSense.
net
package net is intended to provide compatible interfaces with the Go standard library's net package.
package net is intended to provide compatible interfaces with the Go standard library's net package.
mqtt
Package mqtt is intended to provide compatible interfaces with the Paho mqtt library.
Package mqtt is intended to provide compatible interfaces with the Paho mqtt library.
tls
Package tls is intended to provide a minimal set of compatible interfaces with the Go standard library's tls package.
Package tls is intended to provide a minimal set of compatible interfaces with the Go standard library's tls package.
Package pcd8544 implements a driver for the PCD8544 48x84 pixels matrix LCD, used in Nokia's 5110 and 3310 phones.
Package pcd8544 implements a driver for the PCD8544 48x84 pixels matrix LCD, used in Nokia's 5110 and 3310 phones.
Package semihosting implements parts of the ARM semihosting specification, for communicating over a debug connection.
Package semihosting implements parts of the ARM semihosting specification, for communicating over a debug connection.
Package shifter is for 8bit shift register, most common are 74HC165 and 74165
Package shifter is for 8bit shift register, most common are 74HC165 and 74165
Package sht3x provides a driver for the SHT3x digital humidity sensor series by Sensirion.
Package sht3x provides a driver for the SHT3x digital humidity sensor series by Sensirion.
Package ssd1306 implements a driver for the SSD1306 led matrix controller, it comes in various colors and screen sizes.
Package ssd1306 implements a driver for the SSD1306 led matrix controller, it comes in various colors and screen sizes.
Package ssd1331 implements a driver for the SSD1331 TFT color displays.
Package ssd1331 implements a driver for the SSD1331 TFT color displays.
Package st7735 implements a driver for the ST7735 TFT displays, it comes in various screen sizes.
Package st7735 implements a driver for the ST7735 TFT displays, it comes in various screen sizes.
Package st7789 implements a driver for the ST7789 TFT displays, it comes in various screen sizes.
Package st7789 implements a driver for the ST7789 TFT displays, it comes in various screen sizes.
Package thermistor is for temperature sensing using a thermistor such as the NTC 3950.
Package thermistor is for temperature sensing using a thermistor such as the NTC 3950.
Package veml6070 provides a driver for the VEML6070 digital UV light sensor by Vishay.
Package veml6070 provides a driver for the VEML6070 digital UV light sensor by Vishay.
Package vl53l1x provides a driver for the VL53L1X time-of-flight distance sensor Datasheet: https://www.st.com/resource/en/datasheet/vl53l1x.pdf This driver was based on the library https://github.com/pololu/vl53l1x-arduino and ST's VL53L1X API (STSW-IMG007) https://www.st.com/content/st_com/en/products/embedded-software/proximity-sensors-software/stsw-img007.html
Package vl53l1x provides a driver for the VL53L1X time-of-flight distance sensor Datasheet: https://www.st.com/resource/en/datasheet/vl53l1x.pdf This driver was based on the library https://github.com/pololu/vl53l1x-arduino and ST's VL53L1X API (STSW-IMG007) https://www.st.com/content/st_com/en/products/embedded-software/proximity-sensors-software/stsw-img007.html
epd2in13
Package epd2in13 implements a driver for Waveshare 2.13in black and white e-paper device.
Package epd2in13 implements a driver for Waveshare 2.13in black and white e-paper device.
epd2in13x
Package epd2in13x implements a driver for Waveshare 2.13in (B & C versions) tri-color e-paper device.
Package epd2in13x implements a driver for Waveshare 2.13in (B & C versions) tri-color e-paper device.
Package wifinina implements TCP wireless communication over SPI with an attached separate ESP32 board using the Arduino WiFiNINA protocol.
Package wifinina implements TCP wireless communication over SPI with an attached separate ESP32 board using the Arduino WiFiNINA protocol.
Package ws2812 implements a driver for WS2812 and SK6812 RGB LED strips.
Package ws2812 implements a driver for WS2812 and SK6812 RGB LED strips.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL