hybridgroup.gobot/platforms/raspi
deadprogram 0339118fd7 docs: correct Raspberry Pi README link
Signed-off-by: deadprogram <ron@hybridgroup.com>
2016-12-21 10:55:29 +01:00
..
LICENSE misc: update all LICENSE files for current year 2016-08-27 13:12:47 +02:00
README.md docs: update GOARM values as needed for cross-compilation 2016-12-20 18:22:24 +01:00
doc.go docs: correct Raspberry Pi README link 2016-12-21 10:55:29 +01:00
raspi_adaptor.go core: use canonical import domain of gobot.io for all code 2016-12-08 13:24:03 +01:00
raspi_adaptor_test.go core: use canonical import domain of gobot.io for all code 2016-12-08 13:24:03 +01:00
raspi_pin_map.go raspi: Add missing godocs and small refactors for platform 2016-12-01 15:08:01 +01:00

README.md

Raspberry Pi

The Raspberry Pi is an inexpensive and popular ARM based single board computer with digital & PWM GPIO, and i2c interfaces built in.

The Gobot adaptor for the Raspberry Pi should support all of the various Raspberry Pi boards such as the Raspberry Pi 3 Model B, Raspberry Pi 2 Model B, Raspberry Pi 1 Model A+, and Raspberry Pi Zero.

We recommend updating to the latest Raspian Jessie OS when using the Raspberry Pi, however Gobot should also support older versions of the OS, should your application require this.

For more info about the Raspberry Pi platform, click here.

How to Install

go get -d -u gobot.io/x/gobot/... && go install gobot.io/x/gobot/platforms/raspi

How to Use

The pin numbering used by your Gobot program should match the way your board is labeled right on the board itself.

package main

import (
        "time"

        "gobot.io/x/gobot"
        "gobot.io/x/gobot/drivers/gpio"
        "gobot.io/x/gobot/platforms/raspi"
)

func main() {
        r := raspi.NewAdaptor()
        led := gpio.NewLedDriver(r, "7")

        work := func() {
                gobot.Every(1*time.Second, func() {
                        led.Toggle()
                })
        }

        robot := gobot.NewRobot("blinkBot",
                []gobot.Connection{r},
                []gobot.Device{led},
                work,
        )

        robot.Start()
}

How to Connect

Compiling

Simply compile your Gobot program like this:

$ GOARM=6 GOARCH=arm GOOS=linux examples/raspi_blink.go

Use the following GOARM values to compile depending on which model Raspberry Pi you are using:

GOARM=6 (Raspberry Pi A, A+, B, B+, Zero) GOARM=7 (Raspberry Pi 2, 3)

Once you have compiled your code, you can simply upload your program over the network from your host computer to the Raspi

$ scp raspi_blink pi@192.168.1.xxx:/home/pi/

and execute it on your Raspberry Pi with

$ ./raspi_blink

Enabling PWM output on GPIO pins.

For extended PWM support on the Raspberry Pi, you will need to use a program called pi-blaster. You can follow the instructions for pi-blaster install in the pi-blaster repo here:

https://github.com/sarfata/pi-blaster