Linux Kernel Drivers for ev3dev-stretch¶
This is the documentation for the ev3dev-specific Linux kernel drivers that are part of the ev3dev-stretch operating system.
The drivers use sysfs to interact with user space (user space is anything outside of the kernel). Each hardware device is represented by a directory in sysfs called a device node. Each device node has attributes that are represented by files. You monitor and control the hardware by reading and writing these attribute files.
Sensors / Input Devices¶
The EV3 has four input ports for connecting sensors and other devices (like sensor multiplexers or motor controllers). If you are trying to use something that plugs into one of those ports, you are in the right place.
Supported Sensors¶
This is a list of sensors that currently have drivers available in the ev3dev kernel. The Part Number column links to the vendor website. The Name column links to the sensor’s entry in Appendix A.
[1] | Only touch sensors that shipped with the NXT 2.0 set can be automatically detected. Older touch sensors that shipped with the original NXT sets are missing an electrical connection (pin 2 is not internally connected to pin 3) and cannot be automatically detected. |
[2] | (1, 2, 3, 4, 5, 6) The automatic detection algorithm detects this sensor
as an NXT/Analog type sensor but it cannot determine
the exact sensor type. The generic analog driver (nxt-analog ) will be
loaded by default for this sensor. See the The lego-port Subsystem for
information on how to manually load the correct driver. |
[3] | (1, 2, 3) The automatic detection algorithm detects this sensor as an I2C sensor and the port is automatically put into I2C mode. However, the sensor does not follow the LEGO MINDSTORMS convention for I2C sensors, so the exact type of sensor cannot be determined. See Appendix C: I2C Devices for information on how to manually load the correct driver. |
[4] | The automatic detection algorithm detects this sensor as an I2C sensor and the port is automatically put into I2C mode. However, this sensor only partially follows the LEGO MINDSTORMS convention for I2C sensors, so the driver must be loaded manually. See the sensor’s page for more information. |
[5] | The Dexter Industries dFlex sensor cannot be automatically
detected (because pin 2 is not connected to pin 3). In order to use this
sensor, you must manually set the port to nxt-analog mode and then set
the driver to di-dflex . |
Unsupported Sensors¶
One of the goals of ev3dev is to support as many sensors as possible. In fact, even if a manufacturer’s documentation says that a device does not work with the EV3, chances are it will work with ev3dev.
If you have a sensor that is not supported yet, let us know about it by opening an issue on GitHub. For many sensors adding a driver is trivial - even if you are not a “kernel hacker” or a “c programmer”. For the non-trivial sensors, see the contributing page for information on how to write a driver or how to donate hardware to someone who will.
Using Sensors¶
Automatic Detection¶
The EV3 has “smart” sensor ports that can identify most sensors. Beware! Full automatic detection works on EV3 only. And even on EV3, some sensors cannot be automatically detected. See notes below in the table of supported sensors.
For sensors that cannot be automatically detected, you can manually control the input port mode. Read more about it on Input / Output Ports page.
On FatcatLab’s EVB, EV3/Analog and EV3/UART sensors can be automatically detected. For NXT/Analog sensors, you must manually set the mode. Most NXT/I2C sensors should be automatically detected.
On BrickPi, BrickPi+ and BrickPi3, sensors cannot be automatically detected at all. You must manually configure the input ports for all sensors.
On PiStorms, detection of EV3/UART, EV3/Analog and NXT/I2C sensors is
semi-automatic. If you put the input port into ev3-uart
, ev3-analog
,
or i2c-thru
mode, the specific type of sensor will be automatically detected
(assuming it is a LEGO compatible sensor). So you usually don’t have to write to
the set_device
attribute of the port for these sensors.
MINDSTORMS Compatible Sensors¶
Most of the supported sensors are designed to work with LEGO MINDSTORMS. These
sensors use the LEGO sensor class. You can find these
in sysfs at /sys/class/lego-sensor/
. The sensors have modes that select
what type of data is read from the sensor. Generally, you will select a mode
and then read the data value from the sensor. Follow the link above for more
details.
Other Sensors and Advanced Usage¶
Many sensors that were not specifically designed for LEGO MINDSTORMS can be used
with ev3dev too. You can read more about the “Other” sensor types below. Also,
some MINDSTORMS compatible sensor may have advanced features that are not
accessible using the lego-sensor
class.
When using sensors this way, often automatic detection will not work correctly,
therefore it is usually best to manually select the mode of input port (e.g.
other-i2c
or other-uart
).
For more information on using I2C sensors, check out Appendix C: I2C Devices.
Types of Sensors¶
When dealing with sensors in ev3dev, it is useful to know how it communicates with the EV3 brick. There are three basic kinds of communication that the input ports can use to get information from the sensor, Analog Sensors, I2C Sensors and UART Sensors, plus one special type for LEGO NXT Color Sensors.
Analog Sensors¶
These are the simplest type of sensor. The measured value is converted to a voltage (0-5VDC) that is read by the EV3.
EV3/Analog Sensors¶
These are sensors that were designed specifically for the EV3 and will not work on the NXT because the pinout is different. They contain an ID resistor so that the EV3 can tell different types of sensors apart. The actual analog value is measured on pin6.
NXT/Analog Sensors¶
These sensors are designed for the NXT, but also work on the EV3. The EV3 cannot differentiate between most of these sensors though, so you have to tell it which one your have or just use the generic driver.
RCX/Analog Sensors¶
RCX sensors also fall into this category, but do not work with the EV3 - at least not with the converter cable described in the NXT Hardware Developers kit. This is due to a difference in the input port pins between the EV3 and the NXT. If someone wants design a new converter cable, we could make them work.
WeDo/Analog Sensors¶
WeDo sensors are also analog sensors. They are actually electrically similar to
EV3/Analog sensors (require 5V power and have ID resistor). Currently, we only
support WeDo sensors attached to a WeDo hub, but if someone would like to design
a cable and modify the wedo-sensor
and lego-ports
drivers, we could
easily make them work with the input ports on the EV3.
LEGO NXT Color Sensors¶
The LEGO NXT Color Sensor is in a class of its own. It uses a hybrid of analog and (non-standard) digital communications. The NXT Color Sensor is not usable at this point in time. We can detect it with the auto-detect, but we don’t have a driver for it yet.
I2C Sensors¶
I2C sensors are sensors that communicate with the intelligent brick via the I2C protocol. In the NXT documentation, they are referred to a “digital” sensors. These sensors can be sorted into two categories.
NXT/I2C Sensors¶
These are sensors designed using LEGO’s guidelines for NXT digital sensors. NXT/I2C sensors can be automatically detected because they contain vendor and product IDs at specific I2C registers.
Other/I2C Sensors¶
These can be any off-the-shelf I2C device or 3rd party sensors that are designed for LEGO MINDSTORMS, but do not follow the guidelines of NXT/I2C sensors.
UART Sensors¶
The EV3 has a UART transceiver connected to each input port that can be used to communicate with many devices using this widely used standard.
EV3/UART Sensors¶
These is a new type of sensor that is designed specifically for the EV3 (they don’t work with the NXT). These sensors are a bit “smarter” in that in addition to sending the data of what they measure, they also send information about their capabilities. This means that any new EV3/UART sensors should “just work” without us having to write new drivers.
Other/UART Sensors¶
In addition to sensors designed to work with EV3, any UART device can be connected. But, be careful of voltage levels. The EV3 uses 3.3V I/O. It is safe to connect other devices that use 3.3V or 5V I/O. But, don’t connect anything with higher voltage!
The lego-sensor Subsytem¶
The lego-sensor
class provides a uniform interface for using most of the
sensors available for the EV3. The various underlying device drivers will
create a lego-sensor
device for interacting with the sensors.
Sensors are primarily controlled by setting the mode
and monitored by
reading the value<N>
attributes. Values can be converted to floating
point if needed by value<N>
/ 10.0 ^ decimals
.
Identifying sensors¶
Since the name of the sensor<N>
device node does not correspond to the
port that a sensor is plugged in to, you must look at the address
attribute if you need to know which port a sensor is plugged in to. However,
if you don’t have more than one sensor of each type, you can just look for a
matching driver_name
. Then it will not matter which port a sensor is
plugged in to - your program will still work.
Sysfs¶
Sensors can be found at /sys/class/lego-sensor/sensor<N>
, where <N>
is incremented each time a sensor is loaded.
Note
The number <N>
is not related to the port address.
Attribute | Access | Description |
---|---|---|
address |
read-only | Returns the name of the port that the sensor is connected to, e.g.
in1 . I2C sensors also include the I2C address (decimal), e.g.
in1:i2c8 . |
bin_data |
read-only | Reading the file will give the unscaled raw values in the value<N>
attributes. Use bin_data_format , num_values and the individual
sensor documentation to determine how to interpret the data. |
bin_data_format |
read-only | Returns the format of the values in
|
command |
write-only | Sends a command to the sensor. See the individual sensor documentation
for possible commands. Sensors that do not support commands will
return -EOPNOTSUPP when writing to this attribute. |
commands |
read-only | Returns a space separated list of the valid commands for the
sensor. Returns -EOPNOTSUPP if no commands are supported. |
direct |
read/write | Allows direct communication with the sensor for using advanced
features that are not otherwise available through the lego-sensor
class. Returns -EOPNOTSUPP if the sensor does not support this.
Currently this only works with I2C sensors. For I2C sensors, use
:c:func:`seek()` to set the register to read or write from, then read or
write the number of bytes required. |
decimals |
read-only | Returns the number of decimal places for the values in the
value<N> attributes of the current mode. |
driver_name |
read-only | Returns the name of the sensor device/driver. See the list of supported sensors for a complete list of drivers. |
fw_version |
read-only | Returns the firmware version of the sensor if available. Currently only NXT/I2C sensors support this. |
mode |
read/write | Returns the current mode. Writing one of the values returned by
modes sets the sensor to that mode. See the individual sensor
documentation for a description of the modes available for each type
of sensor. |
modes |
read-only | Returns a space separated list of the valid modes for the sensor. |
num_values |
read-only | Returns the number of value<N> attributes that will return a
valid value for the current mode. |
poll_ms |
read/write | Returns the polling period of the sensor in milliseconds. Writing
sets the polling period. Setting to 0 disables polling. Returns
-EOPNOTSUPP if changing polling is not supported. Note: Setting
poll_ms too high can cause the input port autodetection to fail.
If this happens, use the mode attribute of the port to force the
port to nxt-i2c mode. Values must not be negative. |
units |
read-only | Returns the units of the measured value for the current mode. May return empty string if units are unknown. |
value<N> |
read-only | Returns the value or values measured by the sensor. Check
num_values to see how many values there are. Values with
N >= num_values will return an error. The values are fixed point
numbers, so check decimals to see if you need to divide to get
the actual value. |
text_value |
read-only | Returns a space delimited string representing sensor-specific text
values. Returns -EOPNOTSUPP if a sensor does not support text
values. |
Events¶
In addition to the usual add
and remove
events, the kernel change
event is emitted when mode
or poll_ms
is changed. The value<N>
attributes change too rapidly to be handled this way and therefore do not
trigger any uevents.
Sensor Modules¶
The sensor drivers are implemented in the following modules:
EV3/Analog¶
The ev3-analog-sensor
module provides all of the drivers for EV3/Analog
sensors.
You can a list of the the devices implemented by this module by reading the
driver_names
attribute in the /sys/bus/lego/drivers/ev3-analog-sensor/
.
EV3/UART¶
The ev3-uart-sensor-ld
module is a tty line discipline that runs on
top of a tty. It listens for the information data that is sent from EV3/UART
sensors. When it receives valid data, it negotiates with the sensor, telling
the sensor to enter data sending mode.
This line discipline has been assigned the number 29. To attach this line
discipline to a tty, run ldattach 29 /dev/tty<N>
where <N>
is the name
of the tty you want to connect to.
Note
This driver works with any tty, which means the sensor does not necessarily have to be plugged into one of the input ports on the EV3.
EV3/UART sensors do not require individual driver implementations like other
types of sensors. Instead, all of the needed info to sent from the sensor in
a common format. As a result, the name returned by the driver_name
attribute may not be a real driver name. For well-known sensors (the LEGO
EV3 sensors and FatcatLab sensors) it will return a name like lego-ev3-color
.
For unknown sensors it returns ev3-uart-<N>
, where <N>
is the type id
of the sensor.
The ev3-uart-sensor
module provides all of the drivers for EV3/UART
sensors. This module is only used on devices that can’t use the line
discipline.
You can a list of the the devices implemented by this module by reading the
driver_names
attribute in the /sys/bus/lego/drivers/ev3-uart-sensor/
.
NXT/Analog¶
The nxt-analog-sensor
module provides all of the drivers for NXT/Analog
sensors. These drivers scale the analog voltage read from the sensor to a
useful value.
You can a list of the the devices implemented by this module by reading the
driver_names
attribute in the /sys/bus/lego/drivers/nxt-analog-sensor/
.
NXT/I2C¶
The nxt-i2c-sensor
module provides all of the drivers for NXT/I2C sensors.
allow_autodetect |
Setting to N disables probing of sensors. Default is Y . |
default_poll_ms |
This provides the default value for the poll_ms attribute. A value
of 0 will disable polling by default. Changes only affect sensors
plugged in after the change was made. Default is 100 msec. Values must
not be negative. |
Note
These parameters can be changed at runtime by writing to
/sys/module/nxt_i2c_sensor/parameters/<parameter>
.
You can a list of the the devices implemented by this module by reading the
driver_names
attribute in the /sys/bus/lego/drivers/nxt-i2c-sensor/
.
Motors / Output Devices¶
The EV3 has four output ports for connecting motors and other devices (like LEDs). If you are trying to use something that plugs into one of the output ports, then you are in the right place. If you are working with a motor that connects to a motor controller which plugs into an input port, you will find information on the motor controller on the [sensors] page.
This page lists well-known devices, however any device that is rated for 9VDC, requires 500mA or less and can handle pulse width modulation is safe to connect directly to the output ports on the EV3.
Supported Motors¶
Part Number | Name | Driver | Type | Auto-detect | |
---|---|---|---|---|---|
Actuonix | |||||
L12-EV3-100 | L12 EV3 100mm | act-l12-ev3-100 |
ev3 | N [1] | |
L12-EV3-50 | L12 EV3 50mm | act-l12-ev3-50 |
ev3 | N [1] | |
LEGO | |||||
43362 | Motor 9V Mini-motor, newer lighter weight | lego-43362 |
rcx | N | |
45502 | EV3 Large Servo Motor | lego-ev3-l-motor |
ev3 | Y [1] | |
45503 | EV3 Medium Servo Motor | lego-ev3-m-motor |
ev3 | Y [1] | |
47154 | Technic Motor 9V Geared | lego-47154 |
rcx | N | |
70823 | Motor 9V Micromotor | lego-70823 |
rcx | N | |
71427 | Motor 9V Mini-motor, older heavier weight | lego-71427 |
rcx | N | |
74569 | Technic Motor 9V | lego-74569 |
rcx | N | |
88002 | Power Functions Train Motor | lego-88002 |
rcx | N | |
88003 | Power Functions L-Motor | lego-88003 |
rcx | N | |
88004 | Power Functions Servo Motor | lego-88004 |
rcx | N | |
8882 | Power Functions XL-Motor | lego-8882 |
rcx | N | |
8883 | Power Functions M-Motor | lego-8883 |
rcx | N | |
9670 | Power Functions E-Motor | lego-9670 |
rcx | N | |
9842 | NXT (Interactive Servo) Motor | lego-nxt-motor |
ev3 | Y [1] |
[1] | (1, 2, 3, 4, 5) Motors are only automatically detected on the LEGO MINDSTORMS EV3 platform. LEGO NXT Motors are detected as LEGO EV3 Large motors. 3rd party motors will not be correctly detected and must be manually specified. |
Types of Motors¶
There are currently three basic types of classes of devices that are supported in ev3dev. Tacho motors, DC motors and LEDs.
Tacho Motors¶
Tacho motors get their name from the LMS2012 (official LEGO) source code. Tacho is short for tachometer. This is probably a bit of a misnomer because the motor itself does not have a tachometer. Instead, the EV3 brick acts as the tachometer. Technically speaking the motors have a incremental rotary encoder (also called quadrature encoder) that is used by the EV3 to determine the speed and direction of rotation.
DC Motors¶
DC motors are just “plain” motors. They do not have a quadrature encoder for feedback.
LEDs¶
Any 9VDC rated (i.e. it has an appropriately sized resistor) LED can be used.
Using Motors and LEDs¶
Currently, only NXT and EV3 motors can be automatically detected. To use other devices, see the [EV3 Output Port Driver] for information on how to set the mode of the output port.
RCX compatible (aka 9V) motors and LEDs can be connected to the EV3 using a LEGO 8528 cable.
Power Functions motors and LEDs can be connected using a LEGO 8528 cable plus a LEGO 8886 cable or LEGO 8871 cable.
tacho-motor Subsystem¶
The tacho-motor
class provides a uniform interface for using motors with
positional and directional feedback such as the EV3 and NXT motors. This
feedback allows for precise control of the motors.
Sysfs¶
Tacho motors can be found at /sys/class/tacho-motor/motor<N>
, where
<N>
is incremented each time a motor is loaded.
Note
The number <N>
is not related to the port the motor is
plugged in to.
Attribute | Access | Description |
---|---|---|
address |
read-only | Returns the name of the port that the motor is connected to. |
command |
write-only | Sends a command to the motor controller. Possible values are:
Not all commands may be supported. Read the |
commands |
read-only | Returns a space separated list of commands that are supported by the motor controller. |
count_per_rot |
read-only | Returns the number of tacho counts in one rotation of the motor. Tacho counts are used by the position and speed attributes, so you can use this value to convert from rotations or degrees to tacho counts. (rotation motors only) |
count_per_m |
read-only | Returns the number of tacho counts in one meter of travel of the motor. Tacho counts are used by the position and speed attributes, so you can use this value to convert from distance to tacho counts. (linear motors only) |
full_travel_count |
read-only | Returns the number of tacho counts in the full travel of the motor. When combined with the count_per_m atribute, you can use this value to calculate the maximum travel distance of the motor. (linear motors only) |
driver_name |
read-only | Returns the name of the driver that provides this tacho motor device. |
duty_cycle |
read-only | Returns the current duty cycle of the motor. Units are percent. Values are -100 to 100. |
duty_cycle_sp |
read/write | Writing sets the duty cycle setpoint. Reading returns the current value. Units are in percent. Valid values are -100 to 100. A negative value causes the motor to rotate in reverse. |
polarity |
read/write | Sets the polarity of the motor. Valid values are:
|
position |
read/write | Returns the current position of the motor in pulses of the rotary encoder. When the motor rotates clockwise, the position will increase. Likewise, rotating counter-clockwise causes the position to decrease. Writing will set the position to that value. The range is -2,147,483,648 and +2,147,483,647 tachometer counts (32-bit signed integer). |
hold_pid/Kd |
read/write | The derivative constant for the position PID. |
hold_pid/Ki |
read/write | The integral constant for the position PID. |
hold_pid/Kp |
read/write | The proportional constant for the position PID. |
max_speed |
read | Returns the maximum value that is accepted by the speed_sp
attribute. This value is the speed of the motor at 9V with no load.
Note: The actual maximum obtainable speed will be less than this and
will depend on battery voltage and mechanical load on the motor. |
position_sp |
read/write | Writing specifies the target position for the run-to-abs-pos and
run-to-rel-pos commands. Reading returns the current value. Units
are in tacho counts. You can use the value returned by
counts_per_rot to convert tacho counts to/from rotations or
degrees. The range is -2,147,483,648 and +2,147,483,647 tachometer
counts (32-bit signed integer). |
speed |
read-only | Returns the current motor speed in tacho counts per second. Note, this
is not necessarily degrees (although it is for LEGO motors). Use the
count_per_rot attribute to convert this value to RPM or deg/sec. |
speed_sp |
read/write | Writing sets the target speed in tacho counts per second used for all
run-* commands except run-direct . Reading returns the current
value. A negative value causes the motor to rotate in reverse with
the exception of run-to-*-pos commands where the sign is ignored.
Use the count_per_rot attribute to convert RPM or deg/sec to
tacho counts per second. Use the count_per_m attribute to convert
m/s to tacho counts per second. |
ramp_up_sp |
read/write | Writing sets the ramp up setpoint. Reading returns the current value.
Units are in milliseconds and must be positive. When set to a non-zero
value, the motor speed will increase from 0 to 100% of max_speed
over the span of this setpoint. The actual ramp time is the ratio of
the difference between the speed_sp and the current speed and
max_speed multiplied by ramp_up_sp . Values must not be negative. |
ramp_down_sp |
read/write | Writing sets the ramp down setpoint. Reading returns the current
value. Units are in milliseconds and must be positive. When set to a
non-zero value, the motor speed will decrease from 0 to 100% of
max_speed over the span of this setpoint. The actual ramp time is
the ratio of the difference between the speed_sp and the current
speed and max_speed multiplied by ramp_down_sp . Values
must not be negative. |
speed_pid/Kd |
read/write | The derivative constant for the speed regulation PID. |
speed_pid/Ki |
read/write | The integral constant for the speed regulation PID. |
speed_pid/Kp |
read/write | The proportional constant for the speed regulation PID. |
state |
read-only | Reading returns a space separated list of state flags. Possible flags are:
|
stop_action |
read/write | Reading returns the current stop action. Writing sets the stop
action. The value determines the motors behavior when
Not all actions may be supported. Read |
stop_actions |
read-only | Returns a space-separated list of stop actions supported by the motor controller. |
time_sp |
read/write | Writing specifies the amount of time the motor will run when using
the run-timed command. Reading returns the current value. Units
are in milliseconds. Values must not be negative. |
dc-motor Subsystem¶
The dc-motor
class provides a uniform interface for using regular DC
motors with no fancy controls or feedback. This includes LEGO MINDSTORMS RCX
motors and LEGO Power Functions motors.
Sysfs¶
DC motors can be found at /sys/class/dc-motor/motor<N>
, where <N>
is incremented each time a motor is loaded.
Note
The number <N>
is not related to the port address.
Attribute | Access | Description |
---|---|---|
address |
read-only | Returns the name of the port that the motor is connected to. |
command |
write-only | Sets the command for the motor. Possible values are:
Not all commands may be supported. Read |
commands |
read-only | Returns a space separated list of commands supported by the motor controller. |
driver_name |
read-only | Returns the name of the motor driver that loaded this device. See the list of supported motors for a list of drivers. |
duty_cycle |
read-only | Shows the current duty cycle of the PWM signal sent to the motor. Values are -100 to 100 (-100% to 100%). |
duty_cycle_sp |
read/write | Writing sets the duty cycle setpoint of the PWM signal sent to the motor. Valid values are -100 to 100 (-100% to 100%). Reading returns the current setpoint. |
polarity |
read/write | Sets the polarity of the motor. Valid values are:
|
state |
read-only | Gets a space separated list of flags indicating the motor status. Possible flags are:
|
stop_action |
write-only | Sets the stop action that will be used when the motor stops. Possible values are:
Not all values may be supported. Read stop_actions to find out which actions are supported for a particular driver. |
stop_actions |
read-only | Gets a space separated list of supported stop actions. |
ramp_down_sp |
read/write | Sets the time in milliseconds that it take the motor to ramp down from 100% to 0%. Valid values are 0 to 10000 (10 seconds). Default is 0. |
ramp_up_sp |
read/write | Sets the time in milliseconds that it take the motor to up ramp from 0% to 100%. Valid values are 0 to 10000 (10 seconds). Default is 0. |
time_sp |
read/write | Sets the time setpoint used with the run-timed command.
Units are in milliseconds. Values must not be negative. |
servo-motor Subsystem¶
The servo-motor
class provides a uniform interface for using hobby type
servo motors.
Note
LEGO calls the NXT and EV3 motors, “servo” motors on their website.
Technically, that is a correct name for them because they provide position
feedback. However, the servo-motor
class is only used for a very
specific type of servo motor that uses a 50MHz control signal.
It is not used by any LEGO brand motors.
Sysfs¶
Servo motors can be found at /sys/class/servo-motor/motor<N>
, where
<N>
is incremented each time a servo is loaded.
Note
The number <N>
is not related to the port the motor is
plugged in to.
Attribute | Access | Description |
---|---|---|
address |
read-only | Returns the name of the port that the motor is connected to. |
command |
write-only | Sets the command for the servo. Possible values are:
|
driver_name |
read-only | Returns the name of the motor driver that loaded this device. |
max_pulse_sp |
read/write | Used to set the pulse size in milliseconds for the signal that tells
the servo to drive to the maximum (clockwise) position_sp . Default
value is 2400. Valid values are 2300 to 2700. You must write to the
position_sp attribute for changes to this attribute to take
effect. Values must not be negative. |
mid_pulse_sp |
read/write | Used to set the pulse size in milliseconds for the signal that tells
the servo to drive to the mid position_sp. Default value is 1500.
Valid values are 1300 to 1700. For example, on a 180 degree servo,
this would be 90 degrees. On continuous rotation servo, this is the
“neutral” position where the motor does not turn. You must write to
the position_sp attribute for changes to this attribute to take
effect. Values must not be negative. |
min_pulse_sp |
read/write | Used to set the pulse size in milliseconds for the signal that tells
the servo to drive to the minimum (counter-clockwise) position.
Default value is 600. Valid values are 300 to 700. You must write to
the position_sp attribute for changes to this attribute to take
effect. Values must not be negative. |
polarity |
read/write | Sets the polarity of the servo. Valid values are:
|
position_sp |
read/write | Reading returns the current position_sp of the servo. Writing
instructs the servo to move to the specified position_sp. Units are
percent. Valid values are -100 to 100 (-100% to 100%) where -100
corresponds to min_pulse_sp , 0 corresponds to mid_pulse_sp
and 100 corresponds to max_pulse_sp . |
rate_sp |
read/write | Sets the rate_sp at which the servo travels from 0 to 100.0% (half of
the full range of the servo). Units are in milliseconds. Example:
Setting rate_sp to 1000 means that it will take a 180 degree servo
2 seconds to move from 0 to 180 degrees. Note: Some servo controllers
may not support this in which case reading and writing will fail with
-EOPNOTSUPP . In continuous rotation servos, this value will affect
the rate at which the speed ramps up or down. Values must not be
negative. |
state |
read-only | Returns a space separated list of flags indicating the state of the servo. Possible flag is:
|
Motor Modules¶
EV3/EVB Motors¶
The legoev3-motor
module is used on devices like the EV3 where motors
are connected directly to the CPU rather than an external controller.
Generic DC Motors¶
The rcx-motor
module provides a dc-motor Subsystem interface for RCX
motors, Power Functions motors or any other 9V rated DC motor connected to an
output port. You can find the devices bound to this driver in the directory
/sys/bus/lego/drivers/rcx-motor
.
Input / Output Ports¶
This page is about the kind of ports that you plug sensors and motors into. Ports that have more than one connection type will have drivers that let you control the port itself. The input and output ports on the EV3 itself and some sensor multiplexers fall into this category (see list below). Simple multiplexers that only support one connection type will not have a separate driver for the port.
Input Port 5 on the BrickPi is physically wired to the I2C pins on the RaspberryPi. See BrickPi Input Port 5 for the details.
Port drivers use the lego-port-class to provide a common interface for interacting with individual ports. Follow the link for more information.
List of port drivers¶
This is a list of port drivers that are currently available in the ev3dev kernel.
Name | Description | Connection Types | Module |
---|---|---|---|
ht-nxt-smux-port |
HiTechnic NXT Sensor Multiplexer Input Port | NXT/I2C, NXT/Analog | ht-nxt-smux |
ms-ev3-smux-port |
mindsensors.com EV3 Sensor Multiplexer Input Port | EV3/UART, EV3/Analog | ms-ev3-smux |
brickpi3-out-port |
Dexter Industries BrickPi3 Output Port | tacho-motor, dc-motor, led | brickpi3 |
ev3-input-port |
EV3 Input Port | NXT/Analog, NXT/I2C, Other/I2C, EV3/Analog, EV3/UART, Other/UART | ev3_ports |
brickpi-out-port |
Dexter Industries BrickPi Output Port | tacho-motor, dc-motor, led | brickpi |
pistorms-in-port |
mindsensors.com PiStorms Input Port | NXT/Analog, NXT/Color, NXT/I2C, Other/I2C, EV3/Analog, EV3/UART | pistorms |
wedo-port |
LEGO WeDo Port | WeDo/Analog, dc-motor, led | wedo |
pistorms-out-port |
mindsensors.com PiStorms Output Port | tacho-motor | pistorms |
ev3-output-port |
EV3 Output Port | tacho-motor, dc-motor, led | ev3_ports |
ms-nxtmmx-out-port |
mindsensors.com NXTMMX Output Port | tacho-motor | ms-nxtmmx |
brickpi3-in-port |
Dexter Industries BrickPi3 Input Port | NXT/Analog, NXT/I2C, EV3/Analog, EV3/UART | brickpi3 |
brickpi-in-port |
Dexter Industries BrickPi Input Port | NXT/Analog, NXT/I2C, EV3/Analog, EV3/UART | brickpi |
The lego-port Subsystem¶
The lego-port
class provides an interface for working with input and
output ports that are compatible with LEGO MINDSTORMS RCX/NXT/EV3, LEGO
WeDo and LEGO Power Functions sensors and motors. Supported devices include
the LEGO MINDSTORMS EV3 Intelligent Brick, the LEGO WeDo USB hub and
various sensor multiplexers from 3rd party manufacturers.
Some types of ports may have multiple modes of operation. For example, the input ports on the EV3 brick can communicate with sensors using UART, I2C or analog validate signals - but not all at the same time. Therefore there are multiple modes available to connect to the different types of sensors.
In most cases, ports are able to automatically detect what type of sensor
or motor is connected. In some cases though, this must be manually specified
using the mode
and set_device
attributes. The mode
attribute
affects how the port communicates with the connected device. For example the
input ports on the EV3 brick can communicate using UART, I2C or analog
but not all at the same time, so the mode must be set to the one that is
voltages, appropriate for the connected sensor. The set_device
attribute
is used to specify the exact type of sensor that is connected. Note: the
mode must be correctly set before setting the sensor type.
Sysfs¶
Ports can be found at /sys/class/lego-port/port<N>
where <N>
is
incremented each time a new port is registered.
Note
The number <N>
is not related to the actual port at all - use
the address
attribute to find a specific port.
Attribute | Access | Description |
---|---|---|
address |
read-only | Returns the name of the port. See individual driver documentation for the name that will be returned. |
driver_name |
read-only | Returns the name of the driver that loaded this device. You can find the complete list of drivers in the list of port drivers. |
modes |
read-only | Returns a space separated list of the available modes of the port. |
mode |
read/write | Reading returns the currently selected mode. Writing sets the mode. Generally speaking when the mode changes any sensor or motor devices associated with the port will be removed new ones loaded, however this will depend on the individual driver implementing this class. |
set_device |
write-only | For modes that support it, writing the name of a driver will cause a
new device to be registered for that driver and attached to this port.
For example, since the exact type of an NXT/Analog sensor cannot be
automatically detected, you must use this attribute to load the
correct driver. For I2C sensors, you must write the I2C address in
addition to the driver name. Returns -EOPNOTSUPP if setting a
device is not supported for the current mode of the port. |
status |
read-only | In most cases, reading status will return the same value as mode .
In cases where there is an auto mode additional values may be
returned, such as no-device or error . See individual port
driver documentation for the full list of possible values. |
Events¶
In addition to the usual add
and remove
events, the kernel change
event is emitted when mode
or status
changes.
Port Multiplexers¶
Port multiplexers are used to connect more than one sensor or motor to a single input or output port. Some multiplexers are treated as a single sensor while others have their own port drivers.
Supported Multiplexers¶
Part Number | Name | Ports | Supported connections |
---|---|---|---|
HiTechnic | |||
NTX1060 | NXT Touch Sensor Multiplexer | 4 | LEGO NXT Touch sensor |
NSX2020 | HiTechnic Sensor Multiplexer | 4 | NXT/Analog and NXT/I2C sensors |
mindsensors.com | |||
EV3SensorMux | EV3 Sensor Multiplexer for EV3 or NXT | 3 | LEGO EV3 sensors (no 3rd party sensors) |
NXTMMX-v2 | Multiplexer for NXT/EV3 Motors | 3 | LEGO EV3/NXT motors |
NXTServo-v3 | 8 Channel Servo Controller for NXT or EV3 | 8 | Hobby type RC servo motors |
NXTTouchMux | Touch Sensor Multiplexer for NXT | 3 | LEGO NXT Touch sensors |
SPLIT-Nx-v2 | Port Splitter for NXT Digital Sensors | 3 | All I2C sensors |
HiTechnic¶
NXT Touch Sensor Multiplexer¶
This multiplexer allows connecting up to 4 LEGO NXT Touch sensors to a single
input port. This device is treated as a single sensor, so there are is no
lego-port
driver loaded.
HiTechnic Sensor Multiplexer¶
The sensor multiplexer provides 4 sensor ports via one input port. A port
device is registered for each port. These can be found in /sys/class/lego-port/
.
Any type of NXT/Analog sensor can be used with this multiplexer. Most NXT/I2C sensors can be uses as well, but they can only be operated as read-only.
This device cannot detect when motors are attached or removed. However, there is a command that can be used to attempt to detect sensors after they have been attached. This only works for certain LEGO and HiTechnic NXT sensors.
General Info¶
Module | ht-nxt-smux |
Driver name | ht-nxt-smux-port |
Connection types | NXT/I2C, NXT/Analog |
Connection prefix | mux [1] |
Number of modes | 2 |
Notes¶
[1] | The full For example, if we are looking at port 1 of this mux plugged into
input port 2 on the EV3, the address will be |
[2] | The generic 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] | If one of the supported sensors
was detected by invoking the DETECT command on the
HiTechnic NXT Sensor Multiplexer associated with this port, then the
appropriate driver will be automatically loaded. Otherwise,
you can use set_device to load the correct driver for
your sensor. Most drivers with a connection type of NXT/I2C
are allowed. |
A ht-smux-i2c-sensor
device is loaded by the HiTechnic NXT Sensor Multiplexer driver
when it is detected by the sensor mux (automatic detection only works with
the sensors listed in the linked page) or when manually specified by setting
the port to i2c
mode and writing the device name to set_device
.
You can use any one of the sensors that has the nxt-i2c-sensor
module
from the Supported Sensors. Keep in mind though that the sensor mux
operates in a read-only mode with I2C sensors. You will not be able to use
commands with these sensors. Additionally, some modes of I2C sensors require
writing data to the sensor and as a result, these modes will not be usable
either.
Mindsensors.com¶
EV3 Sensor Multiplexer for EV3 or NXT¶
This multiplexer allows connecting three EV3 sensors to a single input port. Only LEGO brand EV3 sensors are supported - 3rd party EV3 sensors won’t work.
General Info¶
Module | ms-ev3-smux |
Driver name | ms-ev3-smux-port |
Connection types | EV3/UART, EV3/Analog |
Connection prefix | mux [4] |
Number of modes | 2 |
Notes¶
[4] | The full For example, if we are looking at port 1 of this mux plugged into
input port 2 on the EV3, the address will be |
[5] | UART sensor types are not
automatically detected. By default, the Supported sensors are:
|
[6] | Currently only the LEGO EV3
Touch sensor is supported. The lego-ev3-touch driver
is loaded when this mode is set. |
Multiplexer for NXT/EV3 Motors¶
The NXT motor multiplexer provides 3 motor ports via one input port. A port
device is registered for each port. These can be found in /sys/class/lego-port/
.
This device cannot detect when motors are attached or removed.
General Info¶
Module | ms-nxtmmx |
Driver name | ms-nxtmmx-out-port |
Connection types | tacho-motor |
Connection prefix | M [7] |
Number of modes | 1 |
Modes¶
Name | Description |
---|---|
tacho-motor |
NXT/EV3 Large Motor |
8 Channel Servo Controller for NXT or EV3¶
This multiplexer allows connecting up to 8 hobby type RC servo motors to a single input port. There is no port device associated with this. When connected, It loads 8 servo-motor Subsystem devices that are used to control the motors.
Touch Sensor Multiplexer for NXT¶
This multiplexer allows connecting up to 3 LEGO NXT Touch sensors to a single
input port. This device is treated as a single sensor, so there are is no
lego-port
driver loaded.
Port Splitter for NXT Digital Sensors¶
This multiplexer allows connecting up to 3 I2C sensors to a single input port. This is a passive device, so there are no drivers. All connected I2C devices must have a unique I2C address.
LEGO MINDSTORMS EV3¶
Input / Output Ports¶
By default, a sysfs device is created for each input and output port on the
EV3. See the input ports and output ports driver descriptions for more
information on how these work. There is a single module for input and output
ports named ev3_ports
. This module has some module parameters.
Name | Description |
---|---|
disable_in_port |
Used to prevent the input port device from being loaded. This is useful if you want to use input port 1 for printing kernel messages this if you want while you are debugging the Linux kernel. You may also want to do to control the input port gpios directly. |
disable_out_port |
Used to prevent the output port from being loaded. This leaves the pwm device and gpios used by the port free to be controlled directly or used by other drivers. |
Input Ports¶
LEGO MINDSTORMS EV3 has four input ports labeled 1, 2, 3 and 4. These ports
are used with LEGO MINDSTORMS EV3 and NXT compatible sensors and other
devices. Most sensors can be automatically detected when plugged in.
Unlike the EV3, however, NXT analog sensors cannot be detected, so to use
these sensors, the port has to be placed in nxt-analog
mode manually.
General Info¶
Module | ev3_ports |
Driver name | ev3-input-port |
Connection types | NXT/Analog, NXT/I2C, Other/I2C, EV3/Analog, EV3/UART, Other/UART |
Connection prefix | in |
Number of modes | 9 |
Modes¶
Name | Description |
---|---|
auto [1] |
Automatically detect most sensors. |
nxt-analog [2] |
Configures the port for NXT/Analog sensors |
nxt-color [3] |
Configures the port for the LEGO NXT Color sensor |
nxt-i2c |
Configure for I2C communications and load the nxt-i2c-host device. |
other-i2c |
Configure for I2C communications but do not probe for NXT sensors. Also configure pin 1 to output 9V (battery voltage). |
ev3-analog |
Configures the port for EV3/Analog sensors |
ev3-uart |
Configure for UART communications and load the ev3-uart-host device. |
other-uart |
Configure for UART communications but do not load any device. |
raw [4] |
Provide access to low level drivers. |
Notes¶
[1] | In auto mode, the port will attempt to automatically detect the type of sensor that was connected and load the appropriate driver. See the list of Supported Sensors to determine if a sensor can be automatically detected. |
[2] | This loads the generic
NXT/Analog sensor nxt-analog driver. Use
set_device to load the appropriate device/driver. |
[3] | NXT Color sensor driver has not been implemented yet, so right now, this mode does nothing. |
[4] | Exports gpios and analog/digital converter values to sysfs so that they can be controlled directly. |
Output Ports¶
The EV3 has four output ports labeled A, B, C and D. These ports are used with LEGO MINDSTORMS EV3, NXT and RCX compatible motors and other devices. EV3 motors can be automatically detected when plugged in. Other motors with position feedback (such as the NXT motor) are usually detected as an EV3 Large Motor. RCX motors and LEDs cannot be automatically detected and the mode of the output port must be manually set to use these types of devices.
General Info¶
Module | ev3_ports |
Driver name | ev3-output-port |
Connection types | tacho-motor, dc-motor, led |
Connection prefix | out |
Number of modes | 5 |
Modes¶
Name | Description |
---|---|
auto [5] |
Automatically detect motors when they are connected. |
tacho-motor [6] |
Configure the port for NXT/EV3 motors. |
dc-motor [7] |
Load the port for RCX/Power Functions motors. |
led [8] |
Load the port for RCX/Power Functions LEDs. |
raw [9] |
Provide access to low level drivers. |
Notes¶
[5] | Only the EV3/NXT large motors and the EV3 medium motor can be automatically detected. All other devices must be manually configured. |
[6] | Configures the port to use
the tacho-motor Subsystem. The default driver is
the EV3 Large Motor (lego-ev3-l-motor ). You can change
the driver using the set_device attribute. |
[7] | This can be use with MINDSTORMS RCX motors, Power Functions motors and any other “plain” DC motor. By “plain”, we mean the motor is just a motor without any feedback. |
[8] | This can be used with MINDSTORMS RCX LEDs, Power Functions LEDs or any other LED connected to pins 1 and 2 of the output port. |
[9] | Exports gpios, pwm and analog/digital converter values to sysfs so that they can be controlled directly. |
Buttons¶
The EV3 buttons use the standard Linux input subsystem. You can find the event
device node at /dev/input/by-path/platform-gpio-keys.0-event
. The buttons
are mapped to Linux key codes as shown in the table below.
Button | Linux key code (value) |
---|---|
Back | KEY_BACKSPACE (14) |
Center | KEY_ENTER (28) |
Up | KEY_UP (103) |
Left | KEY_ENTER (105) |
Right | KEY_ENTER (106) |
Down | KEY_DOWN (108) |
LEDs¶
The EV3 brick status LEDs used the standard Linux LEDs subsystem. You can
find the LED devices at /sys/class/leds/
. There are two bi-color LEDs.
The color for each LED is controlled separately, so there is a green
and
red
device node for each LED. Turning both of these on at the same time
will make the LED appear orange(ish).
The LEDs are controlled by a PWM signal, so you can vary the brightness between
0 and max_brightness
.
Display¶
The EV3 display uses the standard Linux frame buffer subsystem (fbdev). The
display memory can be directly accessed by reading and writing or memory mapping
/dev/fb0
. Display attributes such as width, height and row stride can be
read using FBIOGET_VSCREENINFO
and FBIOGET_FSCREENINFO
ioctls.
Note
You must make sure that you control the active virtual console before drawing on the display, otherwise other programs could be writing to the display at the same time, causing unexpected results.
Sound¶
The snd-legoev3
module provedes an ALSA driver for PCM playback and a
Linux input device with sound capabilities (EV_SND
) for producing tones.
The ALSA driver can be used with standard tools such as alsamixer
and
aplay
. Tones can be produced by using the beep
command, ioctls such
as KDMKTONE
(must run on local console or as root for ioctls) or by
writing SND_*
events to the event device (must be member of input
group for this).
Battery¶
- This driver is used to get information about the EV3 battery.
- It uses the power_supply subsystem.
- It registers a sysfs device node at
/sys/class/power_supply/lego-ev3-battery/
.
current_now |
Returns the battery current in microamps. |
scope |
Always returns System . |
technology |
Returns Unknown or Li-ion depending on if the rechargeable
battery is present. If the technology is Unknown , you can write
NiMH to this attribute if you are using rechargeable NiMH batteries. |
type |
Always returns Battery . |
voltage_max_design |
Returns the nominal “full” battery voltage. The value returned
depends on technology . |
voltage_min_design |
Returns the nominal “empty” battery voltage. The value returned
depends on technology . |
voltage_now |
Returns the battery voltage in microvolts. |
LEGO WeDo¶
I/O Ports¶
The WeDo USB hub has 2 I/O ports. These can be connected to WeDo sensors or Power Functions Motors.
Note
The hub can only provide 5V to motors, so they will not be as powerful as if you were using a proper Power Functions battery. You also need to be careful not to overload your USB port. Most ports are limited to 500mA per the USB specification. However, the EV3 will supply up to 1A.
General Info¶
Module | wedo |
Driver name | wedo-port |
Connection types | WeDo/Analog, dc-motor, led |
Connection prefix | wedo [1] |
Number of modes | 1 |
Modes¶
Name | Description |
---|---|
auto |
The attached device is automatically detected. |
Notes¶
[1] | The full usb<usb-path>:wedo<n>
The USB path might be something like For example, this: /: Bus 05.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/4p, 480M
|__ Port 4: Dev 5, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 2: Dev 6, If 0, Class=Human Interface Device, Driver=wedo, 1.5M
...translates to |
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.
Dexter Industries BrickPi3¶
This page describes the drivers that are specific to Dexter Industries BrickPi3 These controllers are LEGO MINDSTORMS compatible addon boards for Raspberry Pi. Unlike the previous versions of BrickPi, the BrickPi3 uses the SPI interface on the Raspberry Pi to communicate.
You can confirm that the brickpi3
module has loaded successfully by
checking dmesg
. You should see something like this:
[ 3.053862] brickpi3 spi0.1: Mfg: Dexter Industries
[ 3.060030] brickpi3 spi0.1: Board: BrickPi3
[ 3.063114] brickpi3 spi0.1: HW: 3.2.1
[ 3.076690] brickpi3 spi0.1: FW: 1.2.0
[ 3.090078] brickpi3 spi0.1: ID: FAD3CABB504B5354392E314BFF0F2C38
Input Ports¶
The BrickPi3 has four input ports, labeled S1, S2, S3 and S4. These ports are similar to the input ports on the EV3, but lack the ability to automatically detect sensors.
General Info¶
Module | brickpi3 |
Driver name | brickpi3-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
spi0.1: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 manually specify the sensor that is connected and
its address by using the set_device attribute. This
is equivalent to manually loading I2C devices. The
sensor port address will be the BrickPi3 port address
with :i2c and the decimal I2C address appended. |
[4] | Only the LEGO EV3 Touch sensor is
supported. The lego-ev3-touch sensor driver will
load automatically when this port mode is set. |
[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 sensor
drivers are loaded by default. |
I2C Adapters¶
The brickpi3
modules creates one I2C adapter for each input port. These
are available at /dev/i2c-X
where X
is the number of the input port
plus 2. The adapters can only be used when the port is set to nxt-i2c
mode. Only SMBUS messages are supported and are limited to 16 bytes.
Output Ports¶
The BrickPi3 has four output ports, labeled M1, M2, M3 and M4, for driving
motors or other devices. The ports are similar to the output ports on the
EV3, except that they cannot automatically detect when a motor is connected.
By default, the lego-nxt-motor
driver is loaded, so you don’t need to
manually set the mode or device unless you want to use something else.
General Info¶
Module | brickpi3 |
Driver name | brickpi3-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 |
LEDs¶
The BrickPi3 has one user-controllable LED. It is turned on by default when
the brickpi3
module is loaded. It uses the mainline kernel LEDs class
subsystem. You can find it in sysfs at /sys/class/leds/brickpi3:amber:ev3dev
.
Battery¶
- 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/
.
scope |
Always returns System . |
voltage_now |
Returns the battery voltage in microvolts. |
Voltages¶
The BrickPi3 monitors four different voltages for the on-board regulators (these are coming from the BrickPi3 itself, not the Raspberry Pi). There is one for 3.3V, one for 5V, one for 9V and one for direct battery voltage.
These voltages are read using the mainline kernel Industrial I/O driver.
You can read the values at /sys/bus/iio/devices/iio\:device0/in_voltage_N_input
where N
is one of 3V3
, 5V
, 9V
or VCC
(battery).
Tip
You can use the Battery driver for monitoring the battery instead of using this driver.
Mindsensors PiStorms¶
The pistorms
module provides drivers for most of the functionality of the
mindsensors.com PiStorms including lego-port class instances
for the input and output ports, an evdev driver (evdev is not to be confused
with ev3dev) for the touchscreen and GO button, a power_supply driver for
monitoring the battery and an leds driver for the multi-color LEDs.
Input Ports¶
The PiStorms has four LEGO MINDSTORMS EV3 compatible input ports. There are some differences though. Sensors cannot be automatically detected, so you must manually specify the mode of the port before using a sensors. And in many cases, you must also manually specify the type of sensor that is attached. Furthermore, all four ports share a single I2C adapter (master) instead of each port having its own.
General Info¶
Module | pistorms |
Driver name | pistorms-in-port |
Connection types | NXT/Analog, NXT/Color, NXT/I2C, Other/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 |
NXT/Color sensor |
i2c-thru [3] |
I2C pass through |
ev3-analog [4] |
EV3/Analog sensor |
ev3-uart [5] |
EV3/UART sensor |
Notes¶
[1] | The full pistorms:B<b><prefix><n>
For example, if we are looking at the port labeled “BBS2” on the
PiStorms, the address will be |
[2] | The generic nxt-analog
driver will be loaded when this mode is set. You must
manually specify thecorrect 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] | I2C signals are passed through
the input port to NXT/I2C sensors will be automatically detected, otherwise
you must manually specify the sensor that is connected by
using the |
[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. When this mode is set, a sensor device will be registered for the type of sensor that is attached (or was most recently attached). |
Output Ports¶
The PiStorms has four LEGO MINDSTORMS compatible output ports. Unlike the EV3, motors cannot be automatically detected when attached. By default, the ports are configured with the NXT motor driver, which will work for most cases.
General Info¶
Module | pistorms |
Driver name | pistorms-out-port |
Connection types | tacho-motor |
Connection prefix | M [6] |
Number of modes | 1 |
Modes¶
Name | Description |
---|---|
tacho-motor |
NXT/EV3 Large Motor |
Touchscreen and GO Button¶
The pistorms
module registers an input device node for the touchscreen
an the GO button on the PiStorms.
The touchscreen provides ABS_X
and ABS_Y
events to indicate where the
screen was touched and BTN_TOUCH
to indicate when a touch event starts
and stops.
The GO button is mapped to KEY_ENTER
.
LEDs¶
The pistorms
module provides six LED devices for controlling the LEDs
on the Pistorms. There are two tri-color LEDs. Each component (red, green,
blue) is controlled separately.
The device nodes can be found at /sys/class/leds/pistorms:B<bank>:<color>:ev3dev
where <bank>>
is A
or B
and <color>
is red
, green
or
blue
.
Note
Some models of PiStorms only have one LED. The driver will still provide controls for two, but only one will actually work.
Battery¶
- This driver is used to get information about the PiStorms battery.
- It uses the power_supply subsytem.
- It registers a sysfs device node at
/sys/class/power_supply/pistorms-battery/
.
scope |
Always returns System . |
voltage_now |
Returns the battery voltage in microvolts. |
FatcatLab EVB¶
The FatcatLab EVB is a LEGO MINDSTORMS EV3 compatible cape for BeagleBone.
Input / Output Ports¶
The EVB uses the LEGO MINDSTORMS EV3 input and output port drives, so please refer to Input / Output Ports in the EV3 section.
Input Port I2C Adapters¶
The ev3dev PRU firmware for FatcatLab EVB creates one I2C
adapter for each input port. These are available at /dev/i2c-X
where
X
is the number of the input port plus 2. The adapters can only be used
when the port is set to nxt-i2c
or other-i2c
mode.
Buttons / Joystick¶
The EVB has a directional joystick and a single button for user input. These are mapped to keyboard keys so that they provided the same input signals as the EV3.
Note
Simultaneous button presses are ignored.
Button/Direction | Linux key code (value) |
---|---|
Back button press | KEY_BACKSPACE (14) |
Joystick button press | KEY_ENTER (28) |
Joystick up | KEY_UP (103) |
Joystick left | KEY_ENTER (105) |
Joystick right | KEY_ENTER (106) |
Joystick down | KEY_DOWN (108) |
Battery¶
- This driver is used to get information about the FatcatLab EVB battery.
- It uses the power_supply subsytem.
- It registers a sysfs device node at
/sys/class/power_supply/evb-battery/
.
scope |
Always returns System . |
voltage_now |
Returns the battery voltage in microvolts. |
Sound¶
The snd-evb
module provedes an ALSA driver for PCM playback and a
Linux input device with sound capabilities (EV_SND
) for producing tones.
The ALSA driver can be used with standard tools such as alsamixer
and
aplay
. Tones can be produced by using the beep
command, ioctls such
as KDMKTONE
(must run on local console or as root for ioctls) or by
writing SND_*
events to the event device (must be member of input
group for this).
User Space Drivers¶
Configfs Interface¶
This driver provides a configfs interface for creating user-defined devices that use the various ev3dev drivers. Currently, only ports, sensors and LEDs are implemented. Motors could be added in the future.
Usage¶
Note
All commands assume root privileges.
Here is an example of how to create a port and a sensor:
Make sure module is loaded:
modprobe user-lego-configfs
Go to the configfs directory for this driver:
cd /sys/kernel/config/lego_user_device
Create a new port called p1:
mkdir p1
Check out the new port - there should be
live
andsensors
directories:cd p1 ls
This also creates a new port that is linked to
sys/class/lego-port
:ls /sys/devices/lego_user_device/lego-port/
Now create a sensor named
s1
attached to this port:mkdir sensors/s1
Check out the sensor:
ls sensors/s1
These attributes correspond to attributes in the
lego-sensor
class. Set them as appropriate. For example:echo "my-driver" > sensors/s1/driver_name
Once the attributes have been set, export the sensor by linking it to
live
:ln -s sensors/s1 live
There will be two new devices created, one in
/sys/class/user-lego-sensor/
and one in/sys/class/lego-sensor
. Thelego-sensor
class device is used just as any other sensor. Theuser-lego-sensor
device is used to feed data into the sensor. See the user-lego-sensor-class docs for more info.To remove the sensor and port, perform the operations in reverse:
rm link/s1 rmdir sensors/s1 cd .. rmdir p1
The user-lego-sensor Subsystem¶
The user-lego-sensor
class provides an interface for implementing user-defined
sensors in userspace.
Identifying sensors¶
Since the name of the sensor<N>
device node does not correspond to the port
that a sensor is plugged in to, you must look at the address
attribute if
you need to know which port a sensor is plugged in to. This will match the
address
of the corresponding sensor in the lego-sensor
class.
Sysfs¶
Sensors can be found at /sys/class/user-lego-sensor/sensor<N>
, where <N>
is incremented each time a sensor is loaded.
Note
The number <N>
does not correspond to the address of sensor.
Attribute | Access | Description |
---|---|---|
bin_data |
write-only | Writing stores the data which can be read using the bin_data
and value<N> attributes in the corresponding lego-sensor
class device. |
text_value |
write-only | Writing stores the value which can be read using the text_value
attribute in the corresponding lego-sensor class device.
It is currently limited to 512 bytes in length. |
Appendix A: Sensor Data¶
This page contains sensor-specific data for each type of supported sensor.
Generic EV3 Analog Sensor¶
General Info¶
Driver Name | ev3-analog-XX |
Connection Type | EV3/Analog |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
ANALOG |
Raw analog value | V (volts) |
3 | 1 | value0 : Voltage (0 - 5000) |
Commands¶
This sensor does not support commands.
Generic NXT Analog Sensor¶
General Info¶
Driver Name | nxt-analog |
Connection Type | NXT/Analog |
Number of Modes | 2 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
ANALOG-0 |
Raw analog value | V (volts) |
3 | 1 | value0 : Voltage (0 - 5000) |
ANALOG-1 |
Raw analog value - pin 5 high | V (volts) |
3 | 1 | value0 : Voltage (0 - 5000) |
Commands¶
This sensor does not support commands.
Charmed Labs Pixy (CMUcam5) for LEGO¶
General Info¶
Driver Name | pixy-lego |
Website | charmedlabs.com |
Connection Type | NXT/I2C |
Default Address | 0x01 |
Vendor ID | Pixy |
Product ID | Pixy |
Number of Modes | 8 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
ALL |
All | none | 0 | 6 |
|
SIG1 |
Signature #1 | none | 0 | 5 |
|
SIG2 |
Signature #2 | none | 0 | 5 |
|
SIG3 |
Signature #3 | none | 0 | 5 |
|
SIG4 |
Signature #4 | none | 0 | 5 |
|
SIG5 |
Signature #5 | none | 0 | 5 |
|
SIG6 |
Signature #6 | none | 0 | 5 |
|
SIG7 |
Signature #7 | none | 0 | 5 |
|
Commands¶
This sensor does not support commands.
Dexter Industries Flexible Sensor for Mindstorms NXT¶
General Info¶
Driver Name | di-dflex |
Website | www.dexterindustries.com |
Connection Type | NXT/Analog |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
FLEX |
Flex | none | 0 | 1 | value0 : Flex (0-100) |
Commands¶
This sensor does not support commands.
Fatcatlab 9DOF Sensor¶
General Info¶
Driver Name | fcl-9dof |
Website | fatcatlab.com |
Connection Type | EV3/UART |
Number of Modes | 3 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
GYRO |
Gyroscope | d/s (degrees per second) |
1 | 3 |
|
ACC |
Accelerometer | g (standard gravity) |
3 | 3 |
|
MAGNET |
Magnetometer | uT (microteslas) |
0 | 3 |
|
Commands¶
This sensor does not support commands.
Fatcatlab ADC Adapter¶
General Info¶
Driver Name | fcl-adc |
Website | fatcatlab.com |
Connection Type | EV3/UART |
Number of Modes | 3 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
CH1-VOLTAGE |
Channel 1 | mV (millivolts) |
0 | 1 | value0 : Voltage (0 to 3300) |
CH2-VOLTAGE |
Channel 2 | mV (millivolts) |
0 | 1 | value0 : Voltage (0 to 3300) |
VOLTAGE |
Both Channels | mV (millivolts) |
0 | 2 |
|
Commands¶
This sensor does not support commands.
Fatcatlab Altitude Sensor¶
General Info¶
Driver Name | fcl-altitude |
Website | fatcatlab.com |
Connection Type | EV3/UART |
Number of Modes | 2 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
PRESSURE |
Pressure | hPa (hectopascals) |
1 | 1 | value0 : Pressure (3000 to 11000) |
ALTITUDE |
Altitude | m (meters) |
1 | 1 | value0 : Altitude (-5000 to 90000) |
Commands¶
This sensor does not support commands.
Fatcatlab Gesture Sensor¶
General Info¶
Driver Name | fcl-gesture |
Website | fatcatlab.com |
Connection Type | EV3/UART |
Number of Modes | 4 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
GESTURE |
Gesture | none | 0 | 1 | value0 : Gesture (0 to 6) [1] |
PROXIMITY |
Proximity | none | 0 | 1 | value0 : Voltage (0 to 127) |
RGB-RAW |
Color | none | 0 | 3 |
|
CLEAR [2] |
Clear | none | 0 | 1 | value0 : Always 1 |
Commands¶
This sensor does not support commands.
Fatcatlab Humidity Sensor¶
General Info¶
Driver Name | fcl-humidity |
Website | fatcatlab.com |
Connection Type | EV3/UART |
Number of Modes | 3 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
CENTIGRADE |
Temperature (Celsius) | C (degrees Celsius) |
1 | 1 | value0 : Temperature (-400 to 1250) |
FAHRENHEIT |
Temperature (Fahrenheit) | F (degrees Fahrenheit) |
1 | 1 | value0 : Temperature (-400 to 2570) |
HUMIDITY |
Humidity | %RH (percent relative humidity) |
1 | 1 | value0 : Humidity (0 to 1000) |
Commands¶
This sensor does not support commands.
Fatcatlab IR Receiver¶
General Info¶
Driver Name | fcl-ir |
Website | fatcatlab.com |
Connection Type | EV3/UART |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
IR DATA |
IR Remote Control | none | 0 | 1 | value0 : Channel 1 (0 to 60) [3] |
Commands¶
This sensor does not support commands.
Fatcatlab Light Sensor¶
General Info¶
Driver Name | fcl-light |
Website | fatcatlab.com |
Connection Type | EV3/UART |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
ILLUMINANCE |
Illuminance | lx (lux) |
0 | 1 | value0 : Illuminance (0 to 65535) |
Commands¶
This sensor does not support commands.
HiTechnic NXT Color Sensor¶
General Info¶
Driver Name | ht-nxt-color |
Connection Type | NXT/I2C |
Default Address | 0x01 |
Vendor ID | HiTechnc |
Product ID | Color |
Number of Modes | 7 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
COLOR |
Color | none | 0 | 1 | value0 : Color (0 to 17) [4] |
RED |
Red component | none | 0 | 1 | value0 : Reflected light intensity (0 to 255) |
GREEN |
Green component | none | 0 | 1 | value0 : Reflected light intensity (0 to 255) |
BLUE |
Blue component | none | 0 | 1 | value0 : Reflected light intensity (0 to 255) |
RAW |
Raw values | none | 0 | 3 |
|
NORM |
Normalized values | none | 0 | 4 |
|
ALL |
All values | none | 0 | 4 |
|
Commands¶
This sensor does not support commands.
HiTechnic NXT Angle Sensor¶
General Info¶
Driver Name | ht-nxt-angle |
Website | www.hitechnic.com |
Connection Type | NXT/I2C |
Default Address | 0x01 |
Vendor ID | HITECHNC |
Product ID | AnglSnsr |
Number of Modes | 3 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
ANGLE |
Angle | deg (degrees) |
0 | 1 | value0 : Angle (0 to 359) |
ANGLE-ACC |
Accumulated angle | deg (degrees) |
0 | 1 | value0 : Angle (-2147483648 to 2147483647) |
SPEED |
Rotational speed | RPM (revolutions per minute) |
0 | 1 | value0 : Angle (-32768 to 32768) |
HiTechnic NXT Acceleration / Tilt Sensor¶
General Info¶
Driver Name | ht-nxt-accel |
Website | www.hitechnic.com |
Connection Type | NXT/I2C |
Default Address | 0x01 |
Vendor ID | HITECHNC |
Product ID | Accel. |
Number of Modes | 2 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
ACCEL |
Single-axis acceleration | none | 0 | 1 | value0 : Acceleration (coarse value) [6] |
ALL |
Three-axis acceleration | none | 0 | 6 |
|
Commands¶
This sensor does not support commands.
HiTechnic NXT Barometric Sensor¶
General Info¶
Driver Name | ht-nxt-barometric |
Website | www.hitechnic.com |
Connection Type | NXT/I2C |
Default Address | 0x01 |
Vendor ID | HiTechnc |
Product ID | Barometr |
Number of Modes | 2 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
PRESS |
Barometric Pressure | m (???) |
1 | 1 | value0 : Absolute Pressure (0 to 3000) |
TEMP |
Temperature | C (degrees Celsius) |
1 | 1 | value0 : Absolute Pressure (0 to 1000) |
Commands¶
This sensor does not support commands.
HiTechnic NXT Color Sensor V2¶
General Info¶
Driver Name | ht-nxt-color-v2 |
Website | www.hitechnic.com |
Connection Type | NXT/I2C |
Default Address | 0x01 |
Vendor ID | HiTechnc |
Product ID | ColorPD |
Number of Modes | 5 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
COLOR |
Color | none | 0 | 1 | value0 : Color (0 to 17) [8] |
RGB |
Color component values | none | 0 | 4 |
|
NORM |
Normalized values | none | 0 | 4 |
|
PASSIVE |
Passive values | none | 0 | 4 |
|
RAW |
Raw values | none | 0 | 4 |
|
Commands¶
Command | Description |
---|---|
50HZ |
Configure sensor for 50Hz power mains. |
60HZ |
Configure sensor for 60Hz power mains. |
HiTechnic NXT EOPD¶
General Info¶
Driver Name | ht-nxt-eopd |
Website | www.hitechnic.com |
Connection Type | NXT/Analog |
Number of Modes | 2 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
LONG |
Proximity (long range) | none | 0 | 1 | value0 : Proximity (0-100) [9] |
SHORT |
Proximity (short range) | none | 0 | 1 | value0 : Proximity (0-100) [9] |
Commands¶
This sensor does not support commands.
HiTechnic NXT Force Sensor¶
General Info¶
Driver Name | ht-nxt-force |
Website | www.hitechnic.com |
Connection Type | NXT/Analog |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
FORCE |
Raw value (non-linear) | none | 0 | 1 | value0 : (0-1023) |
Commands¶
This sensor does not support commands.
HiTechnic NXT Gyro Sensor¶
General Info¶
Driver Name | ht-nxt-gyro |
Website | www.hitechnic.com |
Connection Type | NXT/Analog |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
GYRO |
Angular speed | d/s (degrees per second) |
0 | 1 | value0 : Angular speed (-540 to 400) |
Commands¶
This sensor does not support commands.
HiTechnic NXT IRLink Sensor¶
General Info¶
Driver Name | ht-nxt-ir-link |
Website | www.hitechnic.com |
Connection Type | NXT/I2C |
Default Address | 0x01 |
Vendor ID | HiTechnc |
Product ID | IRLink |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
IRLINK |
??? | none | 0 | 1 | value0 : ??? |
Commands¶
This sensor does not support commands.
HiTechnic NXT IRReceiver Sensor¶
General Info¶
Driver Name | ht-nxt-ir-receiver |
Website | www.hitechnic.com |
Connection Type | NXT/I2C |
Default Address | 0x01 |
Vendor ID | HiTechnc |
Product ID | IRRecv |
Number of Modes | 2 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
1-MOTOR |
Single Motor Control | pct (percent) |
0 | 1 | value0 : Motor 1A Speed (-128 and -100 to 100) [10] [11] |
8-MOTOR |
Eight Motor Controls | pct (percent) |
0 | 8 |
|
Commands¶
This sensor does not support commands.
Notes¶
[10] | (1, 2, 3, 4, 5, 6, 7, 8, 9) Value of -128 is brake. Speed values only occur in discrete steps (-100, -86, -72, -58, -44, -30, -16, 0, 16, 30, 44, 58, 72, 86 and 100). |
[11] | (1, 2, 3, 4, 5, 6, 7, 8, 9) In the description, “Motor NX”, the number N is the channel, and the letter X is the channel. “A”” is the red/left control and “B”” is the blue/right control. |
HiTechnic NXT PIR Sensor¶
General Info¶
Driver Name | ht-nxt-pir |
Website | www.hitechnic.com |
Connection Type | NXT/I2C |
Default Address | 0x01 |
Vendor ID | HITECHNC |
Product ID | PIR |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
PROX |
IR Proximity | pct (percent) |
0 | 1 | value0 : Proximity (-100 to 100) |
Commands¶
This sensor does not support commands.
HiTechnic NXT Compass Sensor¶
General Info¶
Driver Name | ht-nxt-compass |
Website | www.hitechnic.com |
Connection Type | NXT/I2C |
Default Address | 0x01 |
Vendor ID | HITECHNC (or HiTechnc ) |
Product ID | Compass |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
COMPASS |
Compass Direction | deg (degrees) |
0 | 1 | value0 : Direction (0 to 359) |
Commands¶
This sensor does not support commands.
HiTechnic NXT Magnetic Sensor¶
General Info¶
Driver Name | ht-nxt-mag |
Website | www.hitechnic.com |
Connection Type | NXT/Analog |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
MAG |
Magnetic field??? | none | 0 | 1 | value0 : ??? |
Commands¶
This sensor does not support commands.
HiTechnic NXT IRSeeker V2¶
General Info¶
Driver Name | ht-nxt-ir-seek-v2 |
Website | www.hitechnic.com |
Connection Type | NXT/I2C |
Default Address | 0x08 |
Vendor ID | HiTechnc |
Product ID | NewIRDir |
Number of Modes | 4 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
DC |
Direction (unmodulated) | none | 0 | 1 | value0 : Direction (0 to 9) [12] |
AC |
Direction (modulated) | none | 0 | 1 | value0 : Direction (0 to 9) [12] |
DC-ALL |
All values (unmodulated) | none | 0 | 7 |
|
AC-ALL |
All values (modulated) | none | 0 | 6 |
|
Commands¶
This sensor does not support commands.
HiTechnic NXT Sensor Multiplexer¶
General Info¶
Driver Name | ht-nxt-smux |
Website | www.hitechnic.com |
Connection Type | NXT/I2C |
Default Address | 0x08 |
Vendor ID | HiTechnc |
Product ID | SensrMUX |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
MUX |
Status | none | 0 | 2 |
|
Notes¶
[13] | Run state:
|
[14] | Status bits:
|
[15] | The sensor mux must be halted before sending the detect command, otherwise it will result an error (-EPERM). |
[16] | Only these sensors can be automatically detected:
|
HiTechnic NXT SuperPro Prototype Board¶
General Info¶
Driver Name | ht-super-pro |
Website | www.hitechnic.com |
Connection Type | NXT/I2C |
Default Address | 0x08 |
Vendor ID | HiTechnc |
Product ID | SuperPro |
Number of Modes | 5 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
AIN |
Analog inputs | none | 0 | 4 |
|
DIN |
Digital inputs | none | 0 | 1 | value0 : Bits B0-B7 (0 to 255) |
DOUT |
Digital outputs | none | 0 | 1 | value0 : Bits B0-B7 (0 to 255) |
DCTRL |
Digital input/output controls | none | 0 | 1 | value0 : Bits B0-B7 (0 to 255) |
STROBE |
Strobe output | none | 0 | 1 | value0 : Bits S0-S3 (0 to 15) |
LED |
LED control | none | 0 | 1 | value0 : LED state [17] |
AOUT-0 |
Analog output O0 | none | 0 | 5 |
|
AOUT-1 |
Analog output O1 | none | 0 | 5 |
|
Commands¶
This sensor does not support commands.
LEGO EV3 Ultrasonic Sensor¶
General Info¶
Driver Name | lego-ev3-us |
Website | education.lego.com |
Connection Type | EV3/UART |
Number of Modes | 7 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
US-DIST-CM |
Continuous measurement - sets LEDs on, steady | cm (centimeters) |
1 | 1 | value0 : Distance (0-2550) |
US-DIST-IN |
Continuous measurement - sets LEDs on, steady | in (inches) |
1 | 1 | value0 : Distance (0-1003) |
US-LISTEN |
Listen - sets LEDs on, blinking | none | 0 | 1 | value0 : Presence (0-1) [18] |
US-SI-CM |
Single measurement - LEDs on momentarily when mode is set, then off | cm (centimeters) |
1 | 1 | value0 : Distance (0-2550) [19] |
US-SI-IN |
Single measurement - sets LED on momentarily when mode is set, then off | in (inches) |
1 | 1 | value0 : Distance (0-1003) [19] |
US-DC-CM [20] |
??? - sets LEDs on, steady | cm (centimeters) |
1 | 1 | value0 : Distance (0-2550) |
US-DC-IN [20] |
??? sets LEDs on, steady | in (inches) |
1 | 1 | value0 : Distance (0-1003) |
Commands¶
This sensor does not support commands.
Notes¶
[18] | A value of 1 indicates that another ultrasonic sensor has been detected. A 1 can also be triggered by a loud noise such as clapping. |
[19] | (1, 2) A measurement
is taken when the mode is set and value0
will not change after this. To take another
measurement set the mode again. NOTE:
If you write the mode too frequently (e.g.
every 100msec), the sensor will sometimes
lock up and writing to the mode attribute
will return an error. A delay of 250msec
between each write to the mode attribute
seems sufficient to keep the sensor from
locking up. |
[20] | (1, 2) Not sure what DC mode stands for. Seems to work like the continuous measurement modes. |
LEGO EV3 Gyro Sensor¶
General Info¶
Driver Name | lego-ev3-gyro |
Website | education.lego.com |
Connection Type | EV3/UART |
Number of Modes | 7 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
GYRO-ANG [21] |
Angle | deg (degrees) |
0 | 1 | value0 : Angle (-32768 to 32767) [22] [23] |
GYRO-RATE [24] |
Rotational Speed | d/s (degrees per second) |
0 | 1 | value0 : Rotational Speed (-440 to 440) [23] |
GYRO-FAS |
Rotational Speed | none | 0 | 1 | value0 : Rotational Speed (-1464 to 1535) [23] |
GYRO-G&A [21] [24] |
Angle and Rotational Speed | none | 0 | 2 |
|
GYRO-CAL |
Calibration ??? | none | 0 | 4 |
|
TILT-RATE [25] |
Rotational Speed (2nd axis) | d/s (degrees per second) |
0 | 1 | value0 : Rotational Speed (-440 to 440) [26] |
TILT-ANG [25] |
Angle (2nd axis) | deg (degrees) |
0 | 1 | value0 : Angle (-32768 to 32767) [26] |
Commands¶
This sensor does not support commands.
Notes¶
[21] | (1, 2) The angle in
GYRO-ANG or GYRO-G&A modes can
be reset by changing to a different mode
and changing back. |
[22] | (1, 2) If
you spin around too many times in GYRO-ANG
or GYRO-G&A mode, it will get stuck at
32767 or overflow through -32768 depending
on when the sensor was manufactured. |
[23] | (1, 2, 3, 4, 5) Clockwise is positive when looking at the side of the sensor with the arrows. |
[24] | (1, 2) With older
versions of this sensor (date code ending in
2 or 3), the sensor is calibrated when the
GYRO-RATE or the GYRO-G&A mode is set.
If the sensor is moving when setting the mode,
the calibration will be off. |
[25] | (1, 2) This mode is not present in older sensors (date code ending with 2 or 3). |
[26] | (1, 2) Clockwise is positive when looking at the side of the sensor opposite the cable jack. |
LEGO EV3 Color Sensor¶
General Info¶
Driver Name | lego-ev3-color |
Website | education.lego.com |
Connection Type | EV3/UART |
Number of Modes | 6 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
COL-REFLECT |
Reflected light - sets LED color to red | pct (percent) |
0 | 1 | value0 : Reflected light intensity (0 to 100) |
COL-AMBIENT |
Ambient light - sets LED color to blue (dimly lit) | pct (percent) |
0 | 1 | value0 : Ambient light intensity (0 to 100) |
COL-COLOR |
Color - sets LED color to white (all LEDs rapidly cycling) | col (color) |
0 | 1 | value0 : Detected color (0 to 7) [27] |
REF-RAW |
Raw Reflected - sets LED color to red | none | 0 | 2 |
|
RGB-RAW |
Raw Color Components - sets LED color to white (all LEDs rapidly cycling) | none | 0 | 3 |
|
COL-CAL [28] |
Calibration ??? - sets LED color to red, flashing every 4 seconds, then goes continuous | none | 0 | 4 |
|
Commands¶
This sensor does not support commands.
LEGO EV3 Touch Sensor¶
General Info¶
Driver Name | lego-ev3-touch |
Website | education.lego.com |
Connection Type | EV3/Analog |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
TOUCH |
Button state | none | 0 | 1 | value0 : State (0 or 1) [29] |
Commands¶
This sensor does not support commands.
LEGO EV3 Infrared Sensor¶
General Info¶
Driver Name | lego-ev3-ir |
Website | education.lego.com |
Connection Type | EV3/UART |
Number of Modes | 6 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
IR-PROX |
Proximity | pct (percent) |
0 | 1 | value0 : Distance (0 to 100) [30] |
IR-SEEK |
IR Seeker | pct (percent) |
0 | 8 |
|
IR-REMOTE |
IR Remote Control | btn (button) |
0 | 4 |
|
IR-REM-A |
IR Remote Control | none | 0 | 1 | value0 : Channel 1 [35] |
IR-S-ALT [36] |
Alternate IR Seeker ??? | pct (percent) |
0 | 4 |
|
IR-CAL |
Calibration ??? | none | 0 | 2 |
|
Commands¶
This sensor does not support commands.
Notes¶
[30] | 100% is approximately 70cm/27in. |
[31] | (1, 2, 3, 4) When looking in the same direction as the sensor, -25 is far left and +25 is far right. |
[32] | (1, 2, 3, 4) 100% is approximately 200cm/78in. |
[33] | (1, 2, 3, 4) The absence of a beacon on a channel can be detected when distance == -128 (and heading == 0). |
[34] | (1, 2, 3, 4) Button values:
red == left and blue == right Pressing more that 2 buttons at one time is not supported. It will usually read 0. Pressing an up/down button while beacon mode is activated with turn off beacon mode. |
[35] | Button values:
X = button pressed The most significant byte is always 0x01. In the least significant byte, the 4 most significant bits represent each button. Bit 7 is the blue down button, bit 6 is the blue up button, bit 5 is the red down button, bit 4 is the red up button. Beware that when no buttons are pressed, bit 7 is set (value == 384). You can test that bits 0-3 are all 0 to check this. Example: if ((value & 0x0F) == 0) {
// no buttons are pressed
} else {
if (value & 0x80)
// blue down button is pressed
if (value & 0x40)
// blue up button is pressed
if (value & 0x20)
// red down button is pressed
if (value & 0x10)
// red up button is pressed
}
Bits 0-3 seem to be some sort of checksum or parity check. Bit 0 = bit 4, bit 1 = ~(bit 5), bit 2 = ~(bit 6), bit 3 = 0 if bits 0-2 are even or 1 if bits 0-2 are odd. Also, when the beacon mode is active or for about 1 second after any button is released the value is 262. This mode only works with the remote on channel 1. |
[36] | IR-S-ALT mode is
not usable. When switching to this mode,
the sensor quits responding to the keep-alive
messages and the sensor resets. |
LEGO WeDo USB Hub¶
General Info¶
Driver Name | wedo-hub |
Website | education.lego.com |
Connection Type | USB |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
HUB |
Hub status | none | 0 | 2 |
|
Commands¶
Command | Description |
---|---|
OUT-OFF |
Turns off the outputs of the ports. |
OUT-ON |
Turns on the outputs of the ports. |
CLEAR-ERR |
Clears error. |
LEGO WeDo Motion Sensor¶
General Info¶
Driver Name | wedo-motion |
Website | education.lego.com |
Connection Type | Wedo/Analog |
Number of Modes | 2 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
PROX |
Proximity | pct (percent) |
0 | 1 | value0 : Proximity (0 - 100) |
RAW |
Raw analog value | none | 0 | 1 | value0 : Proximity (0 - 255) |
Commands¶
This sensor does not support commands.
LEGO WeDo Tilt Sensor¶
General Info¶
Driver Name | wedo-tilt |
Website | education.lego.com |
Connection Type | Wedo/Analog |
Number of Modes | 3 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
TILT |
Tilt status | none | 0 | 1 | value0 : Tilt (0 to 5) [38] |
TILT-AXIS |
Tilt around 2 separate axes | none | 0 | 3 |
|
RAW |
Raw analog value | none | 0 | 1 | value0 : Tilt (0 - 255) [40] |
Commands¶
This sensor does not support commands.
Notes¶
[38] | Tilt values:
|
[39] | (1, 2, 3) Axis values:
|
[40] | Raw values:
|
LEGO Energy Display¶
General Info¶
Driver Name | lego-power-storage |
Website | education.lego.com |
Connection Type | NXT/I2C |
Default Address | 0x02 |
Vendor ID | LEGO |
Product ID | Store |
Number of Modes | 8 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
IN-VOLT |
Input Voltage | V (volts) |
3 | 1 | value0 : Voltage (0 to 10000) |
IN-AMP |
Input Current | A (amps) |
3 | 1 | value0 : Current (0 to 10000) |
OUT-VOLT |
Output Voltage | V (volts) |
3 | 1 | value0 : Voltage (0 to 10000) |
OUT-AMP |
Output Current | A (amps) |
3 | 1 | value0 : Current (0 to 10000) |
JOULE |
Energy | J (Joules) |
0 | 1 | value0 : Energy (0 to 100) |
IN-WATT |
Input Power | W (Watts) |
3 | 1 | value0 : Power (0 to 10000) |
OUT-WATT |
Output Power | W (Watts) |
3 | 1 | value0 : Power (0 to 10000) |
ALL |
All | none | 3 | 7 |
|
Commands¶
This sensor does not support commands.
LEGO NXT Temperature Sensor¶
General Info¶
Driver Name | lego-nxt-temp |
Website | education.lego.com |
Connection Type | NXT/I2C |
Default Address | 0x4C |
Vendor ID | LEGO |
Product ID | Temp. |
Number of Modes | 2 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
NXT-TEMP-C |
Continuous measurement | C (°C) |
1 | 1 | value0 : Temperature (-550 to 1280) |
NXT-TEMP-F |
Continuous measurement | F (°F) |
1 | 1 | value0 : Temperature (-670 to 2624) |
Commands¶
This sensor does not support commands.
LEGO NXT Touch Sensor¶
General Info¶
Driver Name | lego-nxt-touch |
Website | shop.lego.com |
Connection Type | NXT/Analog |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
TOUCH |
Button state | none | 0 | 1 | value0 : State (0 or 1) [41] |
Commands¶
This sensor does not support commands.
LEGO NXT Light Sensor¶
General Info¶
Driver Name | lego-nxt-light |
Website | shop.lego.com |
Connection Type | NXT/Analog |
Number of Modes | 2 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
REFLECT |
Reflected light - LED on | pct (percent) |
1 | 1 | value0 : Reflected light intensity (0 to 1000) |
AMBIENT |
Ambient light - LED off | pct (percent) |
1 | 1 | value0 : Ambient light intensity (0 to 1000) |
Commands¶
This sensor does not support commands.
LEGO NXT Sound Sensor¶
General Info¶
Driver Name | lego-nxt-sound |
Website | shop.lego.com |
Connection Type | NXT/Analog |
Number of Modes | 2 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
DB |
Sound pressure level - Flat weighting | pct (percent) |
1 | 1 | value0 : Sound pressure level (0 to 1000) |
DBA |
Sound pressure level - A weighting | pct (percent) |
1 | 1 | value0 : Sound pressure level (0 to 1000) |
Commands¶
This sensor does not support commands.
LEGO NXT Ultrasonic Sensor¶
General Info¶
Driver Name | lego-nxt-us |
Website | shop.lego.com |
Connection Type | NXT/I2C |
Default Address | 0x01 |
Vendor ID | LEGO |
Product ID | Sonar |
Number of Modes | 5 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
US-DIST-CM |
Continuous measurement | cm (centimeters) |
0 | 1 | value0 : Distance (0 to 255) |
US-DIST-IN |
Continuous measurement | in (inches) |
1 | 1 | value0 : Distance (0 to 1000) |
US-SI-CM |
Single measurement | cm (centimeters) |
0 | 1 | value0 : Distance (0 to 255) [42] |
US-SI-IN |
Single measurement | in (inches) |
1 | 1 | value0 : Distance (0 to 1000) [42] |
US-LISTEN |
Listen | none | 0 | 1 | value0 : Presence (0 or 1) [43] |
Commands¶
This sensor does not support commands.
Notes¶
[42] | (1, 2) The value is
read when the mode is set and does not
change - even when polling is enabled. To
read a new value, set the mode again (e.g.
echo US-SI-CM > mode ). |
[43] | A value of 1 indicates that another ultrasonic sensor has been detected. A 1 can also be triggered by a loud noise such as clapping. |
Microinfinity Digital Gyroscope And Accelerometer¶
General Info¶
Driver Name | mi-xg1300l |
Website | www.minfinity.com |
Connection Type | NXT/I2C |
Default Address | 0x01 |
Vendor ID | mnfinity [44] |
Product ID | XG1300L [44] |
Number of Modes | 4 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
ANGLE |
Angle | deg (degrees) |
2 | 1 | value0 : Z-axis angle (-18000 to 18000) |
SPEED |
Rotational speed | d/s (degrees per second) |
2 | 1 | value0 : Z-axis rotational speed |
ACCEL |
Acceleration in X, Y, Z axis | g (Standard gravity) [45] |
3 | 3 |
|
ALL |
All values | none | 0 | 5 |
|
Commands¶
Command | Description |
---|---|
RESET [49] |
Reset device |
ACCEL-2G |
Set accelerometer scaling to 2G |
ACCEL-4G |
Set accelerometer scaling to 4G |
ACCEL-8G |
Set accelerometer scaling to 8G |
Notes¶
[44] | (1, 2) CruizCore XG1300L doesn’t follow LEGO guidelines by returning vendor, product and firmware version values. As a result, this sensor can’t be automatically detected. Until we find another way to identify the sensor, the driver has to be loaded manually. Register I2C device: echo mi-xg1300l 0x01 > /sys/class/lego-port/port<N>/set_device
|
[45] | \(1 g \approx 9.81 m/s^2\) |
[46] | Two decimal places |
[47] | Two decimal places |
[48] | (1, 2, 3) Three decimal places, range as was set by last command |
[49] | Recalculate bias drift, reset accumulated angle, set accelerometer scaling factor to 2G, this has to be done with sensor not moving and is strongly recommended to be called manually before work. |
mindsensors.com Gyro, MultiSensitivity Accelerometer and Compass¶
General Info¶
Driver Name | ms-absolute-imu |
Website | www.mindsensors.com |
Connection Type | NXT/I2C |
Default Address | 0x11 [50] |
Vendor ID | mndsnsrs |
Product ID | AbsIMU |
Number of Modes | 6 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
TILT |
Tilt | deg (degrees) |
0 | 3 |
|
ACCEL [51] |
Acceleration | g (Standard gravity) [52] |
3 | 3 |
|
COMPASS [53] |
Compass | deg (degrees) |
0 | 1 | value0 : Heading (0 to 360) |
MAG [53] |
Magnetic field | none | 0 | 3 |
|
GYRO [54] |
Gyro | d/s (degrees per second) |
1 | 3 |
|
ALL [55] |
All data | none | 0 | 23 |
|
Commands¶
Command | Description |
---|---|
BEGIN-COMP-CAL |
Begin compass calibration |
END-COMP-CAL |
End compass calibration |
ACCEL-2G [56] |
Change accelerometer sensitivity to 2G and gyro sensitivity to 250 deg/sec |
ACCEL-4G [56] |
Change accelerometer sensitivity to 4G and gyro sensitivity to 500 deg/sec |
ACCEL-8G [56] |
Change accelerometer sensitivity to 8G and gyro sensitivity to 2000 deg/sec |
ACCEL-16G [56] |
Change accelerometer sensitivity to 16G and gyro sensitivity to 2000 deg/sec |
Notes¶
[50] | The address is programmable. See manufacturer documentation for more information. |
[51] | Only returns data from models with an accelerometer (AbsoluteIMU-AC / AbsoluteIMU-A). |
[52] | Standard gravity (g) is defined as \(1 g = 9.81 m/s^2\) |
[53] | (1, 2) Only returns data from models with a compass (AbsoluteIMU-C / AbsoluteIMU-AC / AbsoluteIMU-ACG). |
[54] | Only returns data from models with a gyro (AbsoluteIMU-ACG). |
[55] | Reads all data
from the sensor. Use bin_data attribute
to read values. Some values will not be scaled.
See manufacturer docs for more info. |
[56] | (1, 2, 3, 4) Wait 50 msec after sending command for sensor to reconfigure itself. |
mindsensors.com GlideWheel-AS¶
General Info¶
Driver Name | ms-angle |
Website | www.mindsensors.com |
Connection Type | NXT/I2C |
Default Address | 0x18 |
Vendor ID | mndsnsrs |
Product ID | AngSens |
Number of Modes | 4 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
ANGLE |
Angle | deg (degrees) |
0 | 1 | value0 : Angle |
ANGLE2 |
High-precision angle | deg (degrees) |
1 | 1 | value0 : Angle |
SPEED |
Rotational Speed | rpm (revolutions per minute) |
0 | 1 | value0 : Rotational Speed (-4000 to 4000) |
ALL |
All values | none | 0 | 3 |
|
Commands¶
Command | Description |
---|---|
RESET |
Reset angle values |
mindsensors.com EV3 Sensor Multiplexer¶
General Info¶
Driver Name | ms-ev3-smux |
Website | www.mindsensors.com |
Connection Type | NXT/I2C |
Default Address | 0x50, 0x51, 0x52 [59] |
Vendor ID | mndsnsrs |
Product ID | Ev3SMux |
Number of Modes | 2 |
Commands¶
This sensor does not support commands.
Notes¶
[59] | This sensor appears as three separate sensors, one for each channel on the sensor mux. |
[60] | In addition to loading three [lego-sensor] devices for the sensor mux itself, three [lego-port] devices are added as well. These [ms-ev3-smux-port] devices must be used to manually specify the type of sensor that is attached to each port. |
[61] | This mode does not do anything useful. |
mindsensors.com Light Sensor Array¶
General Info¶
Driver Name | ms-light-array |
Website | www.mindsensors.com |
Connection Type | NXT/I2C |
Default Address | 0x0A [62] |
Vendor ID | mndsnsrs |
Product ID | LSArray |
Number of Modes | 2 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
CAL |
Calibrated values | pct (percent) |
0 | 8 |
|
RAW |
Uncalibrated values | none | 0 | 8 |
|
Commands¶
Command | Description |
---|---|
CAL-WHITE |
Calibrate white |
CAL-BLACK |
Calibrate black |
SLEEP [63] |
Put sensor to sleep |
WAKE [64] |
Wake up the sensor |
60HZ |
Configures sensor for 60Hz electrical mains |
50HZ |
Configures sensor for 50Hz electrical mains |
UNIVERSAL |
Configures sensor for any (50/60Hz) electrical mains |
mindsensors.com Line Follower Sensor¶
General Info¶
Driver Name | ms-line-leader |
Website | www.mindsensors.com |
Connection Type | NXT/I2C |
Default Address | 0x01 [65] |
Vendor ID | mndsnsrs |
Product ID | LineLdr |
Number of Modes | 4 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
PID |
Line Follower | pct (percent) |
0 | 1 | value0 : Steering (-100 to 100) [66] |
PID-ALL |
Line Follower - all values | none | 0 | 3 |
|
CAL |
Calibrated values | pct (percent) |
0 | 8 |
|
RAW |
Uncalibrated values | none | 0 | 8 |
|
Commands¶
Command | Description |
---|---|
CAL-WHITE |
Calibrate white |
CAL-BLACK |
Calibrate black |
SLEEP [69] |
Put sensor to sleep |
WAKE [70] |
Wake up the sensor |
INV-COL |
Color inversion (White line on a black background) |
RST-COL |
Reset Color inversion (black line on a white background). |
SNAP [71] |
Take a snapshot. |
60HZ |
Configures sensor for 60Hz electrical mains |
50HZ |
Configures sensor for 50Hz electrical mains |
UNIVERSAL |
Configures sensor for any (50/60Hz) electrical mains |
Notes¶
[65] | The address is programmable. See manufacturer documentation for more information. |
[66] | (1, 2) “Steering” is the power value returned by the sensor to correct your course. Add this value to your left motor and subtract from right motor. |
[67] | “Average” is the weighted average of the sensor reading. The average is a weighted average of the bits set to 1 based on the position. i.e. left most bit has weight of 10, second bit has* weight of 20. |
[68] | “Result” is a byte value of the sensor reading. Each bit corresponding to the sensor where the line is seen is set to 1, or else the bit is zero. |
[69] | poll_ms must be
set to 0 in order for sensor to sleep. |
[70] | Will return an error (-ENXIO) if sensor is actually asleep. Completes successfully if sensor is already awake. |
[71] | The “SNAP” command looks at the line under the sensor and stores the width and position of the line in sensor’s memory. Subsequently, sensor will use these characteristics of line to track it. This command inverts the colors if it sees a white line on black background. (PID parameters are not affected.) |
mindsensors.com Vision Subsystem v4 for NXT or EV3¶
General Info¶
Driver Name | ms-nxtcam |
Website | www.mindsensors.com |
Connection Type | NXT/I2C |
Default Address | 0x01 [72] |
Vendor ID | mndsnsrs |
Product ID | NXTCAM |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
TRACK [73] |
Tracking | none | 0 | 6 |
|
Commands¶
Command | Description |
---|---|
TRACK-ON |
Enable tracking |
TRACK-OFF |
Disable tracking |
TRACK-OBJ |
Set to object tracking mode |
TRACK-LINE |
Set to line tracking mode |
SORT-SIZE |
Sort by size |
SORT-COL |
Sort by color |
Notes¶
[72] | The address is programmable. See manufacturer documentation for more information. |
[73] | This driver only allows
for tracking a single object. To track more
than one object and for other more advanced
uses, you can disable this driver by setting
poll_ms to 0 and using the direct
attribute to directly read and write I2C
messages. See Appendix C: I2C Devices and the manufacturers
documentation for more information. |
mindsensors.com Vision Subsystem v5 for NXT or EV3 (with fixed lens)¶
General Info¶
Driver Name | ms-nxtcam5 |
Website | www.mindsensors.com |
Connection Type | NXT/I2C |
Default Address | 0x01 [74] |
Vendor ID | mndsnsrs |
Product ID | NXTcam5 |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
TRACK [75] |
Tracking | none | 0 | 6 |
|
Commands¶
Command | Description |
---|---|
TRACK-OBJ |
Select object tracking mode |
TRACK-FACE |
Select face tracking mode |
MULTI-MOVIE |
Begin capturing continuous movie (end by any other command) |
MOVIE |
Capture short movie clip |
PICTURE |
Capture still picture |
TRACK-EYE |
Select eye tracking mode |
TRACK-QR |
Select QR code tracking mode (future) |
TRACK-LINE |
Select line tracking mode |
Notes¶
[74] | The address is programmable. See manufacturer documentation for more information. |
[75] | This driver only allows
for tracking a single object. To track more
than one object and for other more advanced
uses, you can disable this driver by setting
poll_ms to 0 and using the direct
attribute to directly read and write I2C
messages. See Appendix C: I2C Devices and the manufacturers
documentation for more information. |
mindsensors.com Multiplexer for NXT/EV3 Motors¶
General Info¶
Driver Name | ms-nxtmmx |
Website | www.mindsensors.com |
Connection Type | NXT/I2C |
Default Address | 0x03 [76] |
Vendor ID | mndsnsrs |
Product ID | NxTMMX |
Number of Modes | 2 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
STATUS |
Status | V (volts) |
3 | 1 | value0 : Battery voltage |
STATUS-OLD [78] |
Status (for older firmware versions) | V (volts) |
3 | 1 | value0 : Battery voltage |
Commands¶
This sensor does not support commands.
Notes¶
[76] | The address is programmable. See manufacturer documentation for more information. |
[77] | The NxtMMX driver also loads two
[tacho-motor] class devices. Use the tacho-motor class
devices to actually control the motors. You can identify
the motors by the address attribute. It will be
in<X>:i2c<Y>:mux<Z> where <X> is 1-4, <Y> is
3 (unless you changed the address) and <Z> is 1 or 2
(matches M1 or M2 printed on the NxtMMX). |
[78] | The I2C register for
battery voltage was changed for EV3
compatibility. If the STATUS mode does
not seem to work, try this mode instead. |
mindsensors.com 8-channel Servo Controller¶
General Info¶
Driver Name | ms-8ch-servo |
Website | www.mindsensors.com |
Connection Type | NXT/I2C |
Default Address | 0x58 [79] |
Vendor ID | mndsnsrs |
Product ID | NXTServo |
Number of Modes | 2 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
V3 |
EV3 Compatible | V (volts) |
3 | 1 | value0 : Battery voltage (0 to 9400) [81] |
OLD [82] |
Older versions | V (volts) |
3 | 1 | value0 : Battery voltage (0 to 9400) [81] |
Commands¶
This sensor does not support commands.
Notes¶
[79] | The address is programmable. See manufacturer documentation for more information. |
[80] | The ms-8ch-servo driver
loads separate servo motor devices (one for each of the 8
channels) in addition to the The lego-sensor Subsytem device.
See the servo-motor Subsystem for more information. The
servo-motor class address attribute will return
in<X>:i2c<Y>:sv<Z> where <X> is the input port
the servo controller is connected to, <Y> is the address
and <Z> is the channel as indicated on the servo
controller itself. |
[81] | (1, 2) The current voltage scaling is based on the manufacturers documentation, however it seems to be low. If you are seeing this too, please open an issue on GitHub and we will change the scaling. |
[82] | Older versions of this sensor have the battery voltage at a different address. If the default mode does not return a value, try this mode. |
mindsensors.com Sensor building kit for NXT with PCF8574 IC¶
General Info¶
Driver Name | pcf8574 |
Website | mindsensors.com |
Connection Type | Other/I2C |
Default Address | 0x38 [83] |
Notes¶
[83] | Valid addresses are 0x38..0x3F (configurable via input pins) |
[84] | Sample usage: Register I2C device: echo pcf8574 0x38 > /sys/bus/i2c/devices/i2c-<port+2>/new_device
Finding device class node and initializing: for chip in $(find /sys/class/gpio -name gpiochip*)
do
if [[ "$(cat $chip/label)" == "pcf8547" ]]
then
base=$(cat $chip/base)
# Pins are active low
for i in {0..7}
do
gpio=$(($base + $i))
echo $gpio > /sys/class/gpio/export
# gpios on this chip are active low
echo 1 > /sys/class/gpio/gpio$gpio/active_low
# initialize direction here
done
# do whatever with the gpios
fi
done
|
mindsensors.com Sensor building kit for NXT with PCF8591 IC¶
General Info¶
Driver Name | pcf8591 |
Website | mindsensors.com |
Connection Type | Other/I2C |
Default Address | 0x48 [85] |
Notes¶
[85] | Valid addresses are 0x48..0x4F (configurable via input pins) |
[86] | Sample usage: Register I2C device: echo pcf8591 0x48 > /sys/bus/i2c/devices/i2c-<port+2>/new_device
Finding device class node: for chip in $(find /sys/class/hwmon -name hwmon*)
do
if [[ "$(cat $chip/device/name)" == "pcf8591" ]]
then
# do whatever
fi
done
|
mindsensors.com Digital Pneumatic Pressure Sensor¶
General Info¶
Driver Name | ms-pps58-nx |
Website | www.mindsensors.com |
Connection Type | NXT/I2C |
Default Address | 0x0C |
Vendor ID | mndsnsrs |
Product ID | PPS58 |
Number of Modes | 7 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
RAW |
Raw sensor value | Pa |
0 | 1 | value0 : Pressure (0 to 400,000 Pa) |
ABS-PSI |
Absolute pressure (PSI) | PSI (Pounds per square inch) |
0 | 1 | value0 : Pressure (0 to 58 PSI) |
ABS-MBAR |
Absolute pressure (millibar) | mbar (millibar) |
0 | 1 | value0 : Pressure (0 to 4000 millibar) |
ABS-KPA |
Absolute pressure (kPa) | kPa (kilopascals) |
0 | 1 | value0 : Pressure (0 to 400 kPa) |
REL-PSI |
Gauge pressure (PSI) | PSI (Pounds per square inch) |
0 | 1 | value0 : Pressure (0 to 58 PSI minus the reference pressure) |
REL-MBAR |
Gauge pressure (millibar) | mbar (millibar) |
0 | 1 | value0 : Pressure (0 to 4000 millibar minus the reference pressure) |
REL-KPA |
Gauge pressure (kPa) | kPa (kilopascals) |
0 | 1 | value0 : Pressure (0 to 400 kPa minus the reference pressure) |
mindsensors.com Pixy Adapter for MINDSTORMS EV3 or NXT¶
General Info¶
Driver Name | ms-pixy-adapter |
Website | www.mindsensors.com |
Connection Type | NXT/I2C |
Default Address | 0x01 [88] |
Vendor ID | mndsnsrs |
Product ID | PixyAdpt |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
TRACK [89] |
Tracking | none | 0 | 6 |
|
Commands¶
Command | Description |
---|---|
SORT-SIZE |
Sort by size |
SORT-COL |
Sort by color |
Notes¶
[88] | The address is programmable. See manufacturer documentation for more information. |
[89] | This driver only
allows for tracking a single object. To
track more than one object and for other
more advanced uses, you can disable this
driver by setting poll_ms to 0 and
using the direct attribute to directly
read and write I2C messages. See the [Using
I2C Sensors] page and the manufacturers
documentation for more information. |
mindsensors.com Realtime Clock for NXT¶
General Info¶
Driver Name | ds1307 |
Website | mindsensors.com |
Connection Type | Other/I2C |
Default Address | 0x68 |
Notes¶
[90] | Sample usage: Register I2C device: echo ds1307 0x68 > /sys/bus/i2c/devices/i2c-<port+2>/new_device
Finding device class node: for chip in $(find /sys/class/rtc -name rtc*)
do
if [[ "$(cat $chip/name)" == "ds1307" ]]
then
# do whatever
fi
done
|
mindsensors.com Touch Sensor Multiplexer for NXT & EV3¶
General Info¶
Driver Name | ms-nxt-touch-mux |
Website | mindsensors.com |
Connection Type | NXT/Analog |
Number of Modes | 1 |
Modes¶
Mode | Description | Units | Decimals | Num. Values | Values |
---|---|---|---|---|---|
TOUCH-MUX |
Touch sensors | none | 0 | 3 |
|
Commands¶
This sensor does not support commands.
Appendix B: Motor Data¶
This page contains sensor-specific data for each type of supported motor.
Actuonix L12 EV3 100mm¶
General Info¶
Driver Name | act-l12-ev3-100 |
Website | www.actuonix.com |
Connection Type | ev3 |
Actuonix L12 EV3 50mm¶
General Info¶
Driver Name | act-l12-ev3-50 |
Website | www.actuonix.com |
Connection Type | ev3 |
LEGO Motor 9V Mini-motor, newer lighter weight¶
General Info¶
Driver Name | lego-43362 |
Website | rebrickable.com |
Connection Type | rcx |
LEGO EV3 Large Servo Motor¶
General Info¶
Driver Name | lego-ev3-l-motor |
Website | shop.lego.com |
Connection Type | ev3 |
LEGO EV3 Medium Servo Motor¶
General Info¶
Driver Name | lego-ev3-m-motor |
Website | shop.lego.com |
Connection Type | ev3 |
LEGO Technic Motor 9V Geared ¶
General Info¶
Driver Name | lego-47154 |
Website | rebrickable.com |
Connection Type | rcx |
LEGO Motor 9V Micromotor¶
General Info¶
Driver Name | lego-70823 |
Website | rebrickable.com |
Connection Type | rcx |
LEGO Motor 9V Mini-motor, older heavier weight¶
General Info¶
Driver Name | lego-71427 |
Website | rebrickable.com |
Connection Type | rcx |
LEGO Technic Motor 9V¶
General Info¶
Driver Name | lego-74569 |
Website | rebrickable.com |
Connection Type | rcx |
LEGO Power Functions Train Motor¶
General Info¶
Driver Name | lego-88002 |
Website | shop.lego.com |
Connection Type | rcx |
LEGO Power Functions L-Motor¶
General Info¶
Driver Name | lego-88003 |
Website | shop.lego.com |
Connection Type | rcx |
LEGO Power Functions Servo Motor¶
General Info¶
Driver Name | lego-88004 |
Website | shop.lego.com |
Connection Type | rcx |
LEGO Power Functions XL-Motor¶
General Info¶
Driver Name | lego-8882 |
Website | shop.lego.com |
Connection Type | rcx |
LEGO Power Functions M-Motor¶
General Info¶
Driver Name | lego-8883 |
Website | shop.lego.com |
Connection Type | rcx |
LEGO Power Functions E-Motor¶
General Info¶
Driver Name | lego-9670 |
Website | education.lego.com |
Connection Type | rcx |
LEGO NXT (Interactive Servo) Motor¶
General Info¶
Driver Name | lego-nxt-motor |
Website | shop.lego.com |
Connection Type | ev3 |
Appendix C: I2C Devices¶
The I2C standards only specify how data is sent from device to device. It does not specify the layout of the registers of a device. LEGO, however, has guidelines for 3rd party manufactures so that they can provide sensors with a (fairly) uniform register layout.
We call sensors that were designed following LEGO’s guidelines NXT/I2C sensors. This common register layout lets us autodetect the type of sensor and proves access to the sensor via the lego-sensor class.
We refer to sensors that do not conform to LEGO’s specifications as Other/I2C sensors. There are so many types of I2C chips in the wild that are already supported on Linux that we do not attempt to autodetect them. To use them, we just need to find a compatible driver and manually load it.
This page discusses both types of I2C sensors.
Addressing¶
I2C uses a 7-bit addressing scheme (there is also 10-bit addressing but it is not implemented in the ev3dev I2C driver). When sending an address over the bus, the address is shifted to the left 1 bit and the least significant bit is used to indicate read or write.
Note
The I2C address that is used in ev3dev is different from the other EV3/NXT programming languages/environments. This means the address in your sensors’ documentation is probably not the address that you need for ev3dev! In ev3dev (and Linux in general), we used the unshifted 7-bit address.
I2C addresses 0x01 through 0x07 (unshifted) are reserved for special use by the
I2C specifications. However, these addresses are used by some sensors anyway
(most notably the NXT Ultrasonic sensor). The ev3dev kernel has been patched to
allow these to work, but some userspace tools will not work with devices at
these addresses. For example, we distribute a patched version of the i2c-tools
package to work around this.
There is a table of I2C addresses at the end of the page.
Using NXT/I2C Sensors¶
See the page on the lego-sensor class for general usage. This page only covers the I2C specifics.
Polling¶
When we say “polled”, we just mean that the EV3 brick initiates a read command
to read data from the sensor. The data that is read depends on the current
mode that is selected. You can change the polling rate using the poll_ms
attribute (of the lego-sensor
device). You can also disable polling by
setting poll_ms
to 0. When polling is disabled, you can initiate a data
read by setting the mode again. By default, NXT/I2C sensors are polled every
100 milliseconds. The default value can be changed via a module parameter.
Direct Reading and Writing of the Sensor¶
Warning
Be very careful when reading from or writing to your sensors. It is theoretically possible to break them if you read or write to the wrong register.
In most cases, setting the mode of a sensor will write the proper data if
necessary, so you don’t actually need to write data using this method. However,
it is possible to write arbitrary data to I2C sensors using the direct
attribute. Use seek
to specify the register to read or write from and always
specify the number of bytes to read or write.
Example: Reading the white calibration data from the mindsensors.com Light Sensor Array. This reads 8 bytes from register 0x5A.
$ hd -s $(( 0x5A )) -n 8 direct
Example: Sending a “calibrate white” command to the mindsensor.com Light Sensor Array. This just writes the ascii character W to register 0x41.
$ echo -e -n "W" | dd bs=1 of=direct seek=$(( 0x41 ))
Manually Loading Devices¶
If you have autodetection disabled (e.g. using the other-i2c
mode of a port)
or if you have managed to change the I2C address of your sensor to something
other than the default or you are using something that is not even a LEGO
compatible sensor, you will have to manually load a device in order to be able
to use your sensor. We just have to tell the I2C adapter which driver to use
and the address of the device.
The I2C adapter device nodes are at /sys/bus/i2c/devices/i2c-N
where N is the
number of the input port plus 2. To load a device, we write to the new_device
attribute. NOTE: These nodes only exist when you have an I2C sensor plugged
into an input port or the port was manually set to an I2C mode.
Example:
# echo nxt-i2c-sensor 0x0B > /sys/bus/i2c/devices/i2c-5/new_device
Using Other/I2C Sensors¶
As we already discussed, Other/I2C sensors generally have an existing Linux driver that you can use. This means that each sensor will work a bit differently. You can load a device just like for manually loading an NXT/I2C device, except we use a different driver name. You can find the names of drivers here.
Example: Using the mindsensors.com Realtime Clock Sensor on input port 2.
$ echo ds1307 0x68 > /sys/bus/i2c/devices/i2c-4/new_device
$ dmesg | tail
...
i2c-legoev3 i2c-legoev3.4: registered on input port 2
i2c i2c-4: new_device: Instantiated device ds1307 at 0x68
rtc-ds1307 4-0068: SET TIME!
rtc-ds1307 4-0068: rtc core: registered ds1307 as rtc1
rtc-ds1307 4-0068: 56 bytes nvram
$ cd /sys/class/rtc
$ ls
rtc0 rtc1
$ cd rtc1
$ ls
date device max_user_freq since_epoch time
dev hctosys name subsystem uevent
Now, I just need to figure out what to do with TWO realtime clocks!
Direct I2C Communication (Going Driverless)¶
You actually don’t need a driver to use your I2C sensors. Drivers do make it much safer and easier, but if you really want full control, it is yours for the taking. There are symlinks for each I2C adapter to make finding them easy.
$ ls /dev/i2c-in*
/dev/i2c-in2 /dev/i2c-in3
Note
The symlinks and the underlying I2C device are only present when an
I2C sensor is plugged into a port. Also, if a driver is loaded for a
particular I2C device, you will get an error that it is in use. You should
disable probing in the nxt-i2c-sensor
module (or blacklist the driver in
/etc/modprobe.d
).
You can use the i2c-tools
package or an I2C library in your programming
language of choice to communicate with I2C devices this way. You don’t want
to do this if a device is already loaded so you will want to disable
autodetection first if the sensor is the autodetected type. Beware that many
sensors, including the NXT Ultrasonic Sensor use an address of 0x01, which is
illegal according to the I2C standards. i2c-tools
and any library that does
some error checking may prevent you from accessing the sensor. In ev3dev-stretch,
the i2c-tools
package has been patched to work around this.
Practical examples¶
Changing the Polling Rate¶
Using the NXT Ultrasonic Sensor:
$ cat poll_ms
100
$ while true; do cat value0; done
22
23
26
27
30
25
...
22
24
26
26
22
22
^C
$ echo 1000 > poll_ms
$ while true; do cat value0; done
22
22
22
22
22
22
22
25
25
25
25
25
25
25
25
...
^C
$ echo 0 > poll_ms
$ cat value0 # value0 will be last value measured before polling stopped
23
$ cat value0 # move the sensor and try again
23
$ cat mode
[NXT-US-CM] NXT-US-IN NXT-US-SI-CM NXT-US-SI-IN NXT-US-LIST
$ echo NXT-US-CM > mode # reads data
$ cat value0
29
$ cat value0 # move the sensor and try again
29
^C
means you have to press CTRL+C to make the loop stop.
Sample /etc/modprobe.d/nxt-i2c-sensor.conf¶
# Module configuration for nxt-i2c-sensor
# Uncomment this line to disable polling
#options nxt-i2c-sensor default_poll_ms=0
# Uncomment this line to disable autodetection
#options nxt-i2c-sensor allow_autodetect=N
How to find the I2C adapter node without adding 2¶
$ IN2_I2C_ADAP=$(udevadm info -q path -n /dev/i2c-in2)"/../.."
$ echo $IN2_I2C_ADAP
/devices/platform/legoev3-ports/in2/in2:nxt-i2c-host/i2c-legoev3.4/i2c-4/i2c-dev/i2c-4/../..
Using i2c-tools¶
With the mindsensors.com Realtime Clock Sensor on input port 2:
& i2cdump 4 0x68
No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-4, address 0x68, mode byte
Continue? [Y/n] y
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 11 35 00 01 01 01 00 03 50 71 48 60 f5 01 6b 0c ?5.???.?PqH`??k?
10: 78 e3 2d 4e 92 6e c7 69 25 61 6b 5b 04 34 15 05 x?-N?n?i%ak[?4??
20: cc 3e 4e 4b 41 8a 59 09 1b f3 1a 2a 7c 47 a7 90 ?>NKA?Y????*|G??
30: 20 6a 95 7a 3b da 5b de 73 31 a2 3a 6e 59 ed f8 j?z;?[?s1?:nY??
40: 11 35 00 01 01 01 00 03 50 71 48 60 f5 01 6b 0c ?5.???.?PqH`??k?
50: 78 e3 2d 4e 92 6e c7 69 25 61 6b 5b 04 34 15 05 x?-N?n?i%ak[?4??
60: cc 3e 4e 4b 41 8a 59 09 1b f3 1a 2a 7c 47 a7 90 ?>NKA?Y????*|G??
70: 20 6a 95 7a 3b da 5b de 73 31 a2 3a 6e 59 ed f8 j?z;?[?s1?:nY??
80: 11 35 00 01 01 01 00 03 50 71 48 60 f5 01 6b 0c ?5.???.?PqH`??k?
90: 78 e3 2d 4e 92 6e c7 69 25 61 6b 5b 04 34 15 05 x?-N?n?i%ak[?4??
a0: cc 3e 4e 4b 41 8a 59 09 1b f3 1a 2a 7c 47 a7 90 ?>NKA?Y????*|G??
b0: 20 6a 95 7a 3b da 5b de 73 31 a2 3a 6e 59 ed f8 j?z;?[?s1?:nY??
c0: 12 35 00 01 01 01 00 03 50 71 48 60 f5 01 6b 0c ?5.???.?PqH`??k?
d0: 78 e3 2d 4e 92 6e c7 69 25 61 6b 5b 04 34 15 05 x?-N?n?i%ak[?4??
e0: cc 3e 4e 4b 41 8a 59 09 1b f3 1a 2a 7c 47 a7 90 ?>NKA?Y????*|G??
f0: 20 6a 95 7a 3b da 5b de 73 31 a2 3a 6e 59 ed f8 j?z;?[?s1?:nY??
$ i2cget -y 4 0x68 0x01 | sed s/0x// # read minutes
35
$ i2cset -y 4 0x68 0x08 0x46 0x72 0x65 0x65 0x20 0x72 0x61 0x6d 0x20 0x73 0x70 0x61 0x63 0x65 0x21 i
$ i2cdump -y -r 0x08-0x16 4 0x68
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 46 72 65 65 20 72 61 6d Free ram
10: 20 73 70 61 63 65 21 space!
Useful Info¶
Shifted Address (write/read) |
Unshifted Address (hex (dec)) |
Notes |
---|---|---|
0x00/0x01 | 0x00 (0) | I2C spec: General call address / START byte |
0x02/0x03 | 0x01 (1) | LEGO NXT Ultrasonic and many 3rd party sensors I2C spec: CBUS address |
0x04/0x05 | 0x02 (2) | LEGO Energy Storage I2C spec: Reserved for different bus format |
0x06/0x07 | 0x03 (3) | mindsensors.com Motor Multiplexer I2C spec: Reserved for future purposes |
0x08/0x09 | 0x04 (4) | I2C spec: Hs-mode master code |
0x0A/0x0B | 0x05 (5) | I2C spec: Hs-mode master code |
0x0C/0x0D | 0x06 (6) | I2C spec: Hs-mode master code |
0x0E/0x0F | 0x07 (7) | I2C spec: Hs-mode master code |
0x10/0x11 | 0x08 (8) | Some HiTechnic sensors |
0x12/0x13 | 0x09 (9) | |
0x14/0x15 | 0x0A (10) | mindsensors.com Light Sensor Array |
0x16/0x17 | 0x0B (11) | |
0x18/0x19 | 0x0C (12) | mindsensors.com PPS58-Nx Pressure Sensor |
0x1A/0x1B | 0x0D (13) | |
0x1C/0x1D | 0x0E (14) | |
0x1E/0x1F | 0x0F (15) | |
0x20/0x21 | 0x10 (16) | |
0x22/0x23 | 0x11 (17) | mindsensors.com AbsoluteIMU Accel/Compass/Gyro |
0x24/0x25 | 0x12 (18) | |
0x26/0x27 | 0x13 (19) | |
0x28/0x29 | 0x14 (20) | |
0x2A/0x2B | 0x15 (21) | |
0x2C/0x2D | 0x16 (22) | |
0x2E/0x2F | 0x17 (23) | |
0x30/0x31 | 0x18 (24) | mindsensors.com GlideWheel-AS Angle Sensor |
0x32/0x33 | 0x19 (25) | |
0x34/0x35 | 0x1A (26) | |
0x36/0x37 | 0x1B (27) | |
0x38/0x39 | 0x1C (28) | |
0x3A/0x3B | 0x1D (29) | |
0x3C/0x3D | 0x1E (30) | |
0x3E/0x3F | 0x1F (31) | |
0x40/0x41 | 0x20 (32) | |
0x42/0x43 | 0x21 (33) | |
0x44/0x45 | 0x22 (34) | |
0x46/0x47 | 0x23 (35) | |
0x48/0x49 | 0x24 (06) | |
0x4A/0x4B | 0x25 (37) | |
0x4C/0x4D | 0x26 (38) | |
0x4E/0x4F | 0x27 (39) | |
0x50/0x51 | 0x28 (40) | |
0x52/0x53 | 0x29 (41) | |
0x54/0x55 | 0x2A (32) | |
0x56/0x57 | 0x2B (43) | |
0x58/0x59 | 0x2C (44) | |
0x5A/0x5B | 0x2D (45) | |
0x5C/0x5D | 0x2E (46) | |
0x5E/0x5F | 0x2F (47) | |
0x60/0x61 | 0x30 (48) | |
0x62/0x63 | 0x31 (49) | |
0x64/0x65 | 0x32 (50) | |
0x66/0x67 | 0x33 (51) | |
0x68/0x69 | 0x34 (52) | |
0x6A/0x6B | 0x35 (53) | |
0x6C/0x6D | 0x36 (54) | |
0x6E/0x6F | 0x37 (55) | |
0x70/0x71 | 0x38 (56) | PCF8574 IC |
0x72/0x73 | 0x39 (57) | |
0x74/0x75 | 0x3A (58) | |
0x76/0x77 | 0x3B (59) | |
0x78/0x79 | 0x3C (60) | |
0x7A/0x7B | 0x3D (61) | |
0x7C/0x7D | 0x3E (62) | |
0x7E/0x7F | 0x3F (63) | |
0x80/0x81 | 0x40 (64) | |
0x82/0x83 | 0x41 (65) | |
0x84/0x85 | 0x42 (66) | |
0x86/0x87 | 0x43 (67) | |
0x88/0x89 | 0x44 (68) | |
0x8A/0x8B | 0x45 (69) | |
0x8C/0x8D | 0x46 (70) | |
0x8E/0x8F | 0x47 (71) | |
0x90/0x91 | 0x48 (72) | PCF8591 IC |
0x92/0x93 | 0x49 (73) | |
0x94/0x95 | 0x4A (74) | |
0x96/0x97 | 0x4B (75) | |
0x98/0x99 | 0x4C (76) | LEGO Temperature Sensor |
0x9A/0x9B | 0x4D (77) | |
0x9C/0x9D | 0x4E (78) | |
0x9E/0x0F | 0x4F (79) | |
0xA0/0xA1 | 0x50 (80) | mindsensors.com EV3 Sensor Multiplexer |
0xA2/0xA3 | 0x51 (81) | mindsensors.com EV3 Sensor Multiplexer |
0xA4/0xA5 | 0x52 (82) | mindsensors.com EV3 Sensor Multiplexer |
0xA6/0xA7 | 0x53 (83) | |
0xA8/0xA9 | 0x54 (84) | |
0xAA/0xAB | 0x55 (85) | |
0xAC/0xAD | 0x56 (87) | |
0xAE/0xAF | 0x57 (87) | |
0xB0/0xB1 | 0x58 (88) | mindsensors.com 8 Channel Servo Controller |
0xB2/0xB3 | 0x59 (89) | |
0xB4/0xB5 | 0x5A (90) | |
0xB6/0xB7 | 0x5B (91) | |
0xB8/0xB9 | 0x5C (92) | |
0xBA/0xBB | 0x5D (93) | |
0xBC/0xBD | 0x5E (94) | |
0xBE/0xBF | 0x5F (95) | |
0xC0/0xC1 | 0x60 (96) | |
0xC2/0xC3 | 0x61 (97) | |
0xC4/0xC5 | 0x62 (98) | |
0xC6/0xC7 | 0x63 (99) | |
0xC8/0xC9 | 0x64 (100) | |
0xCA/0xCB | 0x65 (101) | |
0xCC/0xCD | 0x66 (102) | |
0xCE/0xCF | 0x67 (103) | |
0xD0/0xD1 | 0x68 (104) | mindsensors.com Realtime Clock |
0xD2/0xD3 | 0x69 (105) | |
0xD4/0xD5 | 0x6A (106) | |
0xD6/0xD7 | 0x6B (107) | |
0xD8/0xD9 | 0x6C (108) | |
0xDA/0xDA | 0x6D (109) | |
0xDC/0xDD | 0x6E (110) | |
0xDE/0xDF | 0x6F (111) | |
0xE0/0xE1 | 0x70 (112) | |
0xE2/0xE3 | 0x71 (113) | |
0xE4/0xE5 | 0x72 (114) | |
0xE6/0xE7 | 0x73 (115) | |
0xE8/0xE9 | 0x74 (116) | |
0xEA/0xEB | 0x75 (117) | |
0xEC/0xED | 0x76 (118) | |
0xEE/0xEF | 0x77 (119) | |
0xF0/0xF1 | 0x78 (120) | I2C spec: 10-bit slave addressing |
0xF2/0xF3 | 0x79 (121) | I2C spec: 10-bit slave addressing |
0xF4/0xF5 | 0x7A (122) | I2C spec: 10-bit slave addressing |
0xF6/0xF7 | 0x7B (123) | I2C spec: 10-bit slave addressing |
0xF8/0xF9 | 0x7C (124) | I2C spec: Reserved for future purposes |
0xFA/0xFB | 0x7D (125) | I2C spec: Reserved for future purposes |
0xFC/0xFD | 0x7E (126) | I2C spec: Reserved for future purposes |
0xFE/0xFF | 0x7F (127) | I2C spec: Reserved for future purposes |