Returns the name of the port that the sensor is connected to, e.g. ev3:in1
.
I2C sensors also include the I2C address (decimal), e.g. ev3:in1:i2c8
.
Sends a command to the sensor.
Returns a list of the valid commands for the sensor. Returns -EOPNOTSUPP if no commands are supported.
Returns the number of decimal places for the values in the value<N>
attributes of the current mode.
Returns the name of the sensor device/driver. See the list of [supported sensors] for a complete list of drivers.
Returns the current mode. Writing one of the values returned by modes
sets the sensor to that mode.
Returns the current mode. Writing one of the values returned by modes
sets the sensor to that mode.
Returns a list of the valid modes for the sensor.
Returns the number of value<N>
attributes that will return a valid value
for the current mode.
Returns the units of the measured value for the current mode. May return empty string
Generated using TypeDoc
The 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 thevalue<N>
attributes. Values can be converted to floating point if needed byvalue<N>
/ 10.0 ^decimals
.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 theaddress
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 matchingdriver_name
. Then it will not matter which port a sensor is plugged in to - your program will still work.