Dexter Industries BrickPi/BrickPi+¶
This page describes the drivers that are specific to Dexter Industries BrickPi and BrickPi+ These controllers are LEGO MINDSTORMS compatible addon boards for Raspberry Pi.
Note
BrickPi is identified by hardware v1.7.3 and BrickPi+ is identified as v2.8.
Input Ports¶
The BrickPi and BrickPi+ have 4 input ports that can be used with LEGO MINDSTORMS compatible sensors. It works with most sensors, but there are some exceptions. It only supports the LEGO brand EV3/UART Sensors and EV3/Analog Sensors. Also, there are currently some limitations on the supported NXT/I2C Sensors (See the I2C Sensor Driver). Any type of NXT/Analog Sensors will work.
Note
Unlike the EV3, BrickPi cannot automatically detect sensors! You
must manually specify the type of sensor that is attached to the port
using the mode
and set_device
attributes.
General Info¶
Module | brickpi |
Driver name | brickpi-in-port |
Connection types | NXT/Analog, NXT/I2C, EV3/Analog, EV3/UART |
Connection prefix | ``S`` [1] |
Number of modes | 6 |
Modes¶
Name | Description |
---|---|
none |
No sensor |
nxt-analog [2] |
NXT/Analog sensor |
nxt-color |
LEGO NXT Color sensor |
nxt-i2c [3] |
NXT/I2C sensor |
ev3-analog [4] |
EV3/Analog sensor |
ev3-uart [5] |
EV3/UART sensor |
Notes¶
[1] | The full port name includes the parent device
node. So, the address attribute will return something like
ttyAMA0:S1 . |
[2] | The nxt-analog driver will be
loaded when this mode is set. You must manually specify
the correct driver for your sensor using set_device
if you want to use another driver. Any driver with a
connection type of NXT/Analog is allowed. |
[3] | No sensors are loaded by default. You must address manually specify the sensor that is connected and its by using the set_device attribute. This is equivalent to manually loading I2C devices. The sensor port address will be the BrickPi port address with “:i2c” and the decimal I2C address appended. The I2C Sensor Driver section has information regarding the use of sensors connected to a brickpi-in-port. |
[4] | Only the LEGO EV3 Touch sensor is supported.The driver will load by default. |
[5] | Only the LEGO EV3 Ultrasonic, Color,
Gyro, and Infrared sensors are supported. They cannot be
automatically detected, so you must specify the sensor
manually using the set_device attribute. No sensors
are loaded by default. |
Input Port 5¶
Note
Only the original BrickPi has an Input Port 5. BrickPi+ does not.
Input Port 5 on the BrickPi is physically wired to the I2C pins on the Raspberry
Pi and I2C is supported by the i2c_bcm2708
kernel module (there is no
ev3dev-specific driver for this port).
Only NXT/I2C Sensors and Other/I2C Sensors work on port 5.
Tip
Sensor types are listed in the Supported Sensors table.
Configuration¶
For Input Port 5 to work with most LEGO compatible sensors, you have to make sure that correct baudrate for the sensor is set and load the driver manually. NXT/I2C Sensors should work with the slow 9600 baudrate used originally by LEGO MINDSTORMS NXT.
You can temporarily change the baudrate on a running system. This change will be reset after a reboot:
sudo modprobe -r i2c_bcm2708 # remove module
sudo modprobe i2c_bcm2708 baudrate=9600 # load module specifying baudrate
Note
Some devices behave erratically if baudrate is changed while they are plugged in. If needed unplug your sensor, change the baudrate and plug the sensor again.
Or, you can permanently change the baudrate by editing /boot/flash/config.txt
with the following line (requires reboot to take effect):
dtparam=i2c_baudrate=9600
Usage¶
To use a sensor, you have to tell the I2C adapter the driver and I2C address
to use. When you write this to /sys/bus/i2c/devices/i2c-1/new_device
,
a new sensor device will appear in /sys/class/lego-sensor/
which can be
used as you would any other sensor.
Tip
You can find the driver name and default I2C address in the sensor information pages.
Example: Loading Microinfinity CruizCore XG1300L driver manually:
sudo sh -c 'echo "mi-xg1300l 0x01" > /sys/bus/i2c/devices/i2c-1/new_device'
I2C Sensor Driver¶
There is currently not a standard I2C adapter driver for BrickPi/BrickPi+
(i.e. You will not find /dev/i2c-X
for the BrickPi input ports. Instead,
this driver is used for working with NXT/I2C Sensors.
To load this driver, set the BrickPi input port to nxt-i2c
mode and then
write the driver name and I2C address of the sensor to the set_device
attribute. You can find the driver name and default I2C address on the
sensor’s information page.
Example:
echo "nxt-i2c" > /sys/class/lego-port/port0/mode
echo "ht-angle 0x01" > /sys/class/lego-port/port0/set_device
Once the driver has been loaded, there will be a new sensor device node added in the The lego-sensor Subsytem.
Unfortunately, some sensors require special operations that are not currently
supported in this driver, so attempting to use one of those sensors will
fail (check dmesg
). If you have a BrickPi, you can use Input
Port 5 instead.
Output Ports¶
BrickPi3 has four output ports labeled M1, M2, M3 and M4. These ports are very similar to EV3 output ports with a motor controller and quadrature encoder feedback. However, they cannot automatically detected when a motor is attached or removed. By default, the NXT motor driver is already loaded for these ports, so you don’t have to set the mode unless you want to use a different type of driver.
General Info¶
Module | brickpi |
Driver name | brickpi-out-port |
Connection types | tacho-motor, dc-motor, led |
Connection prefix | M [6] |
Number of modes | 3 |
Modes¶
Name | Description |
---|---|
tacho-motor |
NXT/EV3 Large Motor |
dc-motor |
RCX/Power Functions motor |
led |
RCX/Power Functions LED |
Battery¶
Note
The BrickPi+ battery driver is only available on BrickPi+ (HW v2.8), not the earlier BrickPi models.
- This driver is used to get information about the BrickPi+ battery.
- It uses the power_supply subsytem.
- It registers a sysfs device node at
/sys/class/power_supply/brickpi-battery/
.
Tip
This driver is enabled by the line dtparam=brickpi_battery=okay
in /boot/flash/config.txt
.
scope |
Always returns System . |
voltage_now |
Returns the battery voltage in microvolts. |
Line Discipline¶
This driver is a tty line discipline that runs on top of a serial port. It is the core driver that facilitates communication between the Rapberry Pi and the BrickPi.
The driver is loaded by attaching the line discipline:
sudo ldattach 29 /dev/ttyAMA0
Once this driver is successfully loaded, it will load the input and output drivers for the BrickPi.
Tip
Technically, it is possible to use the BrickPi with any 3.3V serial port. It does not necessarily have to be use with a Rapsberry Pi.