Home

Awesome

Raspberry Pi Golang Examples

Go Report Card
License: MIT

If you liked this project, you may also like one of these projects rp2040-examples, golang-examples, golang-benchmarks or sql-examples.

About

These examples explain how to use different Raspberry Pi accessories and hardware with Golang. There will be more examples from time to time.

if you like, feel free to add more examples. Many thanks to all contributors.

Install go(lang)

with homebrew:

sudo brew install go

with apt-get:

sudo apt-get install golang

install Golang manually or compile it yourself

Get a Pi

of course you also need a Raspberry Pi, normaly you can get one at Amazon, BerryBase or Reichelt.
Sometimes Raspberrys are unfortunately difficult to obtain, but there is the great website rpilocator, which shows very clearly which dealers have the various Raspberry models on stock.

Examples

NAU7802

The nau7802 is a chip that makes it easy to query load cells with the RaspberryPi via I2C. You can buy the Adafruit nau7802-board on Amazon, or this one from SparkFun.

HX711

The hx711 is a chip that makes it possible to query load cells with the RaspberryPi (or other systems, e.g. the Arduino). You can buy boards with the hx711-chip on Amazon. There are also complete sets with a hx711 board and a load cell.

PCA9685

The pca9685 is a PWM driver with 12-bit resolution (4096 steps) for up to 16 separately controllable devices with an operating voltage of up to 6V. This makes it possible to control up to 16 PWM outputs with just two pins on the RaspberryPi. The pca9685 is controlled via I2C, which means that several pca9685 can be connected in a row and with up to 62 selectable addresses, up to 992 PWM outputs with 2 pins can be controlled. You can buy a great board with the pca9685-chip on Amazon.

PCF8574

The PCF8574 is an 8-bit I/O port expander connected via the I2C bus. Anyone who has ever suffered from "lack of pins" in one of their applications knows what is meant. Here, too, only two pins are required to control 8 pins (per board). There are some pcf8574 boards available on Amazon.

WS2812

The ws2812 is an "intelligent" LED, the chip not only contains 3 LEDs (in the colors red, green and blue), but also an IC which enables the control of the LEDs. The LEDs can be controlled in brightness and combination. The ws2812 light chains are available in a wide variety of variants, they differ in the distance between the LEDs, there are waterproof light chains, different colors of the circuit board, ... For example, Amazon has this 144 "pixel" per meter ws2812 light chain with white PCB.