gobot.io/x/gobot/v2@v2.1.0/platforms/rockpi/README.md (about) 1 # Radxa Rock Pi 2 3 The [Radxa Rock Pi board series](https://wiki.radxa.com/Rock4/getting_started) are clones of the popular Raspberry Pi Single Board Computers (SBCs) with GPIO/PWM/I2C functionalities built-in. 4 5 The Gobot adaptor is currently compatible with: 6 7 - Rock Pi 4 8 - Rock Pi 4C+ 9 10 With the possibility to expand its compatibility into past and future models. 11 12 Check out the output of `cat /proc/device-tree/model` to see which model you have if you're not sure. The 4C+ model has a Rockchip 3399_T SoC, while the regular 4 has the 3399. Both are similar, but have slightly different GPIO pin configurations. 13 14 ## How to Install 15 16 Make sure you've installed an official Linux image from Radxa with working drivers. See the [ROCK 4 Installation Wiki](https://wiki.radxa.com/Rock4/install) for your SBC setup. 17 18 > Some versions or Armbian ISOs do not detect the newer SoC chips. 19 20 As for your Gobot development, treat this as a regular Go package. It can be cross-compiled and copied over, or simply compiled on the SBC itself (tested and working with go 1.15.15 on linux/arm64, RockPi4C+). 21 22 ## How to Use 23 24 The pin numbering used by your Gobot program should match the way your board is labeled right on the board itself. 25 26 That is, follow the **colored Pin# numbers** in the middle in the [GPIO mapping Wiki](https://wiki.radxa.com/Rock4/hardware/gpio). These have been translated for you into their corresponding underlying GPIO numbers. 27 28 ```go 29 package main 30 31 import ( 32 "time" 33 34 "gobot.io/x/gobot/v2" 35 "gobot.io/x/gobot/v2/drivers/gpio" 36 "gobot.io/x/gobot/v2/platforms/rockpi" 37 ) 38 39 func main() { 40 r := rockpi.NewAdaptor() 41 led := gpio.NewLedDriver(r, "7") 42 43 work := func() { 44 gobot.Every(1*time.Second, func() { 45 led.Toggle() 46 }) 47 } 48 49 robot := gobot.NewRobot("blinkBot", 50 []gobot.Connection{r}, 51 []gobot.Device{led}, 52 work, 53 ) 54 55 robot.Start() 56 } 57 ``` 58 59 If you want to use I2C, RockPi4 offers three I2C buses: I2C2 (pins 27, 28), I2C6 (pins 29, 31) and I2C7 (pins 3, 5) of which I2C7 is the default. 60 Changing this is a matter of passing the right bus number using `i2c.WithBus`: 61 62 ```go 63 a := rockpi.NewAdaptor() 64 adc2 := i2c.NewADS1115Driver(a, i2c.WithBus(6)) 65 ``` 66 67 There are mapped to `/dev/i2c-[bus]`, just like the Gobot raspi implementation. 68 69 ### What's currently supported? 70 71 - General digital pin GPIO access works, but not through the new character device driver. 72 - The I2C buses 2, 6, 7 work 73 - SPI buses 1, 2 work 74 75 PWM interaction is currently not yet supported. 76 77 Please see the [official Radxa Rock Pi documentation](https://wiki.radxa.com/Rockpi4/dev/libmraa) on how `librmaa` can be utilized in combination with this module, and how these work. 78 79 ### Compiling 80 81 Compile your Gobot program on your workstation like this: 82 83 ```bash 84 $ GOARCH=arm64 GOOS=linux go build examples/rockpi_blink.go 85 ``` 86 87 Rock Pi 4s are ARM64 machines. 88