rpi-devices
rpi-devices implements the drivers of devices or sensors for raspberry pi in pure golang. The drivers for the sensors below have been implemented, and I will keep developing for new sensors.
Compile & Deploy
It is very easy to cross-compile and deploy for golang. It is an example that compiles the binary for raspberry pi on MacOS.
$ CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -o test main.go
If you aren't sure the cpu info of your raspberry pi, check it out by,
$ lscpu
# those are the cpu info of my raspberry pi 2.
# ------------------------------------------------------------
# Architecture: armv6l
# Byte Order: Little Endian
# CPU(s): 1
# On-line CPU(s) list: 0
# Thread(s) per core: 1
# Core(s) per socket: 1
# Socket(s): 1
# Vendor ID: ARM
# Model: 7
# Model name: ARM1176
# Stepping: r0p7
# CPU max MHz: 700.0000
# CPU min MHz: 700.0000
# BogoMIPS: 697.95
# Flags: half thumb fastmult vfp edsp java tls
# ------------------------------------------------------------
And then, deploy the binary to your raspberry pi by,
$ scp test pi@192.168.31.57:/home/pi
192.168.31.57
is the ip address of my raspberry pi, you need to replace it with yours.
ssh to you raspberry pi, and run the binary.
# from /home/pi
$ ssh pi@192.168.31.57
$ ./test
# or, run it in background
$ nohub ./test > test.log 2>&1 &
App
Using the driver programs, I built several applications. The most complex and interesting project is the self-driving car, more than 10 sensers were used to build the smart car. I highlight few interesting apps here, please go to app for all apps I development. You can learn how to use the driver programs from my apps.
play the video on youtube.