rpi-devices

module
v0.0.0-...-791007e Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: MIT

README

rpi-devices

Build Status

rpi-devices let you drive the devices and sensors using a raspberry pi in pure golang. The following devices & sensors had been implemented in the current version, and I will keep implementing new devices and sensors.

Sensors Image Description Example App
Button Button module example vedio-monitor
Buzzer Buzzer module N/A car, door-dog
Collision Switch A switch for deteching collision example car
DHT11 Temperature & Humidity sensor example home-asst
DS18B20 Temperature sensor example auto-fan
Encoder Encoder sensor example car
GPS ) location sensor example gps-tracker
HC-SR04 ultrasonic distance meter example auto-light, doordog
Infrared Infrared sensor example N/A
L298N motor driver N/A car
Led Led light example car, vedio-monitor
Led Display led digital module example auto-air
Oled Oled display module example home-asst
PMS7003 Air quality sensor example auto-air
Relay Relay module example auto-fan
RX480E-4 Wireless remote control example remote-light
SG90 Servo motor example auto-air, car, vedio-monitor
Step Motor Step motor example N/A
SW-420 Shaking sensor example auto-air-out
US-100 ultrasonic distance meter example car
Voice Voice sensor N/A N/A
ZE08-CH2O CH2O sensor example ch2o-monitor

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 app.pi 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 app.pi 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.

$ ssh pi@192.168.31.57
$ ./devices.pi

# or, run it in background
$ nohub ./devices.pi > devices.pi 2>&1 &

App

Self-Dirving Car
Video Monitor
Auto-Air
Auto-Light

Auto-Fan

Jump to

Keyboard shortcuts

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