EV3 Keyboard Shortcuts. Mindsensors sensors and controllers for LEGO Mindstorms are compatible with NXT 1.0, NXT 2.0 and EV3 bricks. If you purchased a sensor before August 2013 If you have an old sensor, (purchased before EV3 came to market, i.e. Aug 2013 or before), you may need to upgrade it's firmware.
This writeup is intended for use with the EV3. For the NXT version, see Sensors.
The experimental objective of this lab is to design various Mindstorms programs that use rotation, light, touch, and ultrasonic sensors.
These exercises will build a foundation of experience with sensors programming that can be used with the semester-long design project.
![Urltrasonic Urltrasonic](/uploads/1/3/4/6/134670633/283268064.jpg)
Mindstorms Program
Before we can learn to use sensors, we must become familiar with the EV3. Remember that the Mindstorms program is a compiler: a program used to make other programs. Just as a compiler is used when creating and debugging a C++ program, Mindstorms similarly compiles programs for the EV3. The Mindstorms interface is graphic; a text compiler like those used for C++ is not. However, the principle is very much the same. Actions are taken based upon circumstances set by the programmer.
The EV3 houses all the programming instructions that control the movement of your robot. Once you have created your program in Mindstorms, it is uploaded to the EV3. The EV3 then dictates the robot's motion. If your robot does not do what you intended, you must rewrite the program in Mindstorms and upload the corrected version to the EV3.
- Lab PC
- Mindstorms Software
- USB Cable
- EV3 Unit
Rotation Sensor
For this portion of the lab, you will learn how to use the rotation sensor in the motor to determine the distanced your robot moved.
- Click on the orange tab and select the Loop block. Connect it to the Start block.
- Click on the yellow tab and select the motor rotation block. Insert it into the loop block.
- Click on the green tab and select the display block. Insert it into the loop block.
- Click on the image button on the display block. Change it to Pixels.
- On the top right corner of the display block, click on MINDSTORMS and change it to Wired.
- Click on the measurement button on the motor rotation block and change the measurement to rotations.
- Wire the Motor Rotation block to the Display block by clicking and dragging the mouse from the tab on the motor rotation block to connect to the text input on the display block.
With the program now completed, upload it to your EV3 and run the program. Turn the motor that is connected to port A and look at the display. You should see numbers on the display that correspond to the number of times you've turned the motor.
Example for Rotation Sensor
Suppose you wrote a program that had your robot's motors move forward for 3 seconds.
Let's say you want to add the code that we previously made so that you can read the number of rotations that your robot made while it's moving. In order to do that, you'll need to create a new sequence beam.
- Start by clicking on orange tab and selecting the start block. Insert it anywhere on the screen.
- Create the program previously made on the start block
Example #2 for Rotation Sensor
Suppose we wanted to create a program that displayed the number of rotations, but instead of having it loop forever, it would stop measuring the number of rotations once you've rotated it three times.
- Create the program shown below
- Click on the infinite button in the loop block and change it to rotations.
- Set the threshold value to 3 and make sure that the comparison type is greater than.
When you run this program, you should be able to see the number of rotations on the EV3's display. If you make more than 3 rotations on the motor, the program should end.
Ultrasonic Sensor
For this portion of the lab, you will learn how to use the ultrasonic sensor in order to determine the distance between the robot and an object.
The code for obtaining a distance reading and displaying it on the EV3's screen is almost exactly the same as the code for the rotation sensor. The only difference is that instead of the rotation sensor block, you must use the ultrasonic sensor block
Example for Ultrasonic Sensor
Suppose we wanted to write a program in which our EV3 would show a happy face if the Ultrasonic Sensor detected a distance greater than 40 in, and show a sad face if the Ultrasonic Sensor detected a distance less than 40 in.
- To start off this program, we'll first need the switch block, which can found by clicking on the orange tab
- On the switch block, click on the button and configure it to compare the distance in inches
- In the configuration panel, change the compare type to greater than, and set the threshold value to 40 in.
- Place a display block into each of the two cases beams in the switch block
- Configure each display block so that it shows the correct image. Remember that the EV3 should display happy face when the distance sensed by the Ultrasonic Sensor is greater than 40 in and show a sad face when the distance is less than 40 in.
- Place the entire switch block into a loop block.
Example #2 for Ultrasonic Sensor
Now suppose we wanted to add an additional case to the program where the EV3 would display a caution sign when the Ultrasonic Sensor senses a distance less than 40 in but greater than 30 in, and display a sad face when the distance sensed is less than 30. In this situation, one switch case won't be enough, as the program will only check to see if the value obtained is greater than or less than one specific number. To overcome this problem, we'll need an additional switch case inside of the switch case we already have.
In this program, when the distanced sensed is greater than 40, it will display a happy face, just like before. When the distance sensed is less than 40, it will check to see if it's greater than or less than 30, and show the appropriate image based on that.
Task
Create a program in which your robot maintains a distance of 8 and 20 in from the wall. In other words, your robot should move away from the wall if the ultrasonic sensor senses a distance less than 8 in and moves towards the wall if the ultrasonic sensor senses a distance greater than 20 in.
Touch Sensor
For this portion of the lab, you will learn how to use the touch sensor to control the actions of your robot based whether the touch sensor has been pressed or bumped.
Using The Ultrasonic Sensor Ev3
Example for Touch Sensor
Suppose you wanted to create a program in which your robot would move when the touch sensor is pressed, and would stop when the touch sensor was released.
- Insert a switch block and have it set to the touch sensor
- Insert a move block into each of the sequence beams. Configure one motor block to move continuously and set the other motor block to stop
- Place the switch block into a loop block
Light Sensor
For this portion of the lab, you will learn how to use the light sensor in order to determine the light intensity of the sensor's reflected light. You will also learn how to use the light sensor to follow a line.
The program for obtaining the light intensity and displaying it on the EV3's screen is the same as that of the rotation sensor and the ultrasonic sensor, except you need to use the light sensor block.
Line Following Code Using One Light Sensor
The code for following a line using one light sensor is shown below.
This block of code alternates between the left and right motor of the robot, depending on whether the light sensor sees the line. For example, let us assume that motor A is the left motor and motor C is the right motor. Thus, when the light sensor sees the line, the right motor (motor C) stops while the left motor (motor A) starts turning. This causes the robot to turn away from the line while moving forward. Also, when the light sensor doesn't see the line, the left motor stops while the right motor starts turning. This causes the robot to turn towards the line while moving forwards.
Line Following Code Using Two Light Sensors
The code for following a line using two light sensors is shown below.
This block of code alternates between turning the left and right motor of the robot, depending on which light sensor sees the line. First, let us assume that motor A is the left motor and motor C is the right motor. Also, we'll assume that light sensor 1 is the left light sensor and light sensor 2 is the right light sensor. Thus, when the left light sensor sees the line, but the right line sensor doesn't, the left motor stops while the right motor starts moving. If the right light sensor sees the line, but the left light sensor doesn't see the line, the right motor stops while the left motor starts moving. If neither light sensor see the line, then both motors start turning.
For positioning, the robot should be placed such that the light sensors are in between the line.
Tasks
Course 1
Create a program in which your robot travels from point A to point C in a clockwise manner, then rotates 180 degrees and finally returns to point A.
Course 2
Create a program in which your robot travels from point A to point H in a clockwise manner, rotates 180 degrees, and travels to point C.
A zip file including the following programs needs to be submitted to the EG Website. If you don't know how to make a zip file, read the page How to Compress Your Files in the Instructional Presentations section of this manual.
Lab Report
There is no lab report for this lab.
Team PowerPoint Presentation
There is no presentation for this lab.
|
Retrieved from 'http://manual.eg.poly.edu/index.php?title=Sensors_(EV3)&oldid=5756'
The EV3 has four input ports for connecting sensors and other devices (likesensor multiplexers or motor controllers). If you are trying to use somethingthat 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 ev3devkernel. The Part Number column links to the vendor website. The Namecolumn links to the sensor’s entry in Appendix A.
Part Number | Name | Driver | Type | Auto-detect | |
---|---|---|---|---|---|
Generic EV3 Analog Sensor | ev3-analog-XX | EV3/Analog | Y | ||
Generic NXT Analog Sensor | nxt-analog | NXT/Analog | Y | ||
Charmed Labs | |||||
Pixy LEGO | Pixy (CMUcam5) for LEGO | pixy-lego | NXT/I2C | Y | |
Dexter Industries | |||||
dFlex | Flexible Sensor for Mindstorms NXT | di-dflex | NXT/Analog | N [5] | |
Fatcatlab | |||||
9DOF Sensor | 9DOF Sensor | fcl-9dof | EV3/UART | Y | |
ADC Adapter | ADC Adapter | fcl-adc | EV3/UART | Y | |
Altitude Sensor | Altitude Sensor | fcl-altitude | EV3/UART | Y | |
Gesture Sensor | Gesture Sensor | fcl-gesture | EV3/UART | Y | |
Humidity Sensor | Humidity Sensor | fcl-humidity | EV3/UART | Y | |
IR Receiver | IR Receiver | fcl-ir | EV3/UART | Y | |
Light Sensor | Light Sensor | fcl-light | EV3/UART | Y | |
HiTechnic | |||||
NXT Color Sensor | ht-nxt-color | NXT/I2C | Y | ||
NAA1030 | NXT Angle Sensor | ht-nxt-angle | NXT/I2C | Y | |
NAC1040 | NXT Acceleration / Tilt Sensor | ht-nxt-accel | NXT/I2C | Y | |
NBR1036 | NXT Barometric Sensor | ht-nxt-barometric | NXT/I2C | Y | |
NCO1038 | NXT Color Sensor V2 | ht-nxt-color-v2 | NXT/I2C | Y | |
NEO1048 | NXT EOPD | ht-nxt-eopd | NXT/Analog | N [2] | |
NFS1074 | NXT Force Sensor | ht-nxt-force | NXT/Analog | N [2] | |
NGY1044 | NXT Gyro Sensor | ht-nxt-gyro | NXT/Analog | N [2] | |
NIL1046 | NXT IRLink Sensor | ht-nxt-ir-link | NXT/I2C | Y | |
NIR1032 | NXT IRReceiver Sensor | ht-nxt-ir-receiver | NXT/I2C | Y | |
NIS1070 | NXT PIR Sensor | ht-nxt-pir | NXT/I2C | Y | |
NMC1034 | NXT Compass Sensor | ht-nxt-compass | NXT/I2C | Y | |
NMS1035 | NXT Magnetic Sensor | ht-nxt-mag | NXT/Analog | N [2] | |
NSK1042 | NXT IRSeeker V2 | ht-nxt-ir-seek-v2 | NXT/I2C | Y | |
NSX2020 | NXT Sensor Multiplexer | ht-nxt-smux | NXT/I2C | Y | |
SPR2010 | NXT SuperPro Prototype Board | ht-super-pro | NXT/I2C | Y | |
LEGO | |||||
45504 | EV3 Ultrasonic Sensor | lego-ev3-us | EV3/UART | Y | |
45505 | EV3 Gyro Sensor | lego-ev3-gyro | EV3/UART | Y | |
45506 | EV3 Color Sensor | lego-ev3-color | EV3/UART | Y | |
45507 | EV3 Touch Sensor | lego-ev3-touch | EV3/Analog | Y | |
45509 | EV3 Infrared Sensor | lego-ev3-ir | EV3/UART | Y | |
9581 | WeDo USB Hub | wedo-hub | USB | Y | |
9583 | WeDo Motion Sensor | wedo-motion | Wedo/Analog | Y | |
9584 | WeDo Tilt Sensor | wedo-tilt | Wedo/Analog | Y | |
9668 | Energy Display | lego-power-storage | NXT/I2C | Y | |
9749 | NXT Temperature Sensor | lego-nxt-temp | NXT/I2C | Y | |
9843 | NXT Touch Sensor | lego-nxt-touch | NXT/Analog | Y [1] | |
9844 | NXT Light Sensor | lego-nxt-light | NXT/Analog | Y | |
9845 | NXT Sound Sensor | lego-nxt-sound | NXT/Analog | N [2] | |
9846 | NXT Ultrasonic Sensor | lego-nxt-us | NXT/I2C | Y | |
Microinfinity | |||||
CruizCore XG 1300L | Digital Gyroscope And Accelerometer | mi-xg1300l | NXT/I2C | N [4] | |
mindsensors.com | |||||
AbsoluteIMU(-A/C/G) | Gyro, MultiSensitivity Accelerometer and Compass | ms-absolute-imu | NXT/I2C | Y | |
AngleSensor | GlideWheel-AS | ms-angle | NXT/I2C | Y | |
EV3SensorMUX | EV3 Sensor Multiplexer | ms-ev3-smux | NXT/I2C | Y | |
IRThermometer | IR Temperature Sensor for EV3 or NXT | ms-ir-thermometer | NXT/I2C | Y | |
LightSensorArray | Light Sensor Array | ms-light-array | NXT/I2C | Y | |
LineLeader | Line Follower Sensor | ms-line-leader | NXT/I2C | Y | |
NXTCam-v4 | Vision Subsystem v4 for NXT or EV3 | ms-nxtcam | NXT/I2C | Y | |
NXTCam-v5 | Vision Subsystem v5 for NXT or EV3 (with fixed lens) | ms-nxtcam5 | NXT/I2C | Y | |
NXTMMX-v2 | Multiplexer for NXT/EV3 Motors | ms-nxtmmx | NXT/I2C | Y | |
NxtServo | 8-channel Servo Controller | ms-8ch-servo | NXT/I2C | Y | |
PCF8574-Nx | Sensor building kit for NXT with PCF8574 IC | pcf8574 | Other/I2C | N [3] | |
PCF8591-Nx | Sensor building kit for NXT with PCF8591 IC | pcf8591 | Other/I2C | N [3] | |
PPS58-Nx | Digital Pneumatic Pressure Sensor | ms-pps58-nx | NXT/I2C | Y | |
PixyAdapter | Pixy Adapter for MINDSTORMS EV3 or NXT | ms-pixy-adapter | NXT/I2C | Y | |
RTC-Nx-v3 | Realtime Clock for NXT | ds1307 | Other/I2C | N [3] | |
TouchMux | Touch Sensor Multiplexer for NXT & EV3 | ms-nxt-touch-mux | NXT/Analog | N [2] |
[1] | Only touch sensors that shipped with the NXT 2.0set can be automatically detected. Older touch sensors that shipped withthe original NXT sets are missing an electrical connection (pin 2 is notinternally connected to pin 3) and cannot be automatically detected. |
[2] | (1, 2, 3, 4, 5, 6) The automatic detection algorithm detects this sensoras an NXT/Analog type sensor but it cannot determinethe exact sensor type. The generic analog driver (nxt-analog ) will beloaded by default for this sensor. See the The lego-port Subsystem forinformation on how to manually load the correct driver. |
[3] | (1, 2, 3) The automatic detection algorithm detects this sensoras 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 forinformation on how to manually load the correct driver. |
[4] | The automatic detection algorithm detects this sensoras an I2C sensor and the port is automatically put into I2C mode. However,this sensor only partially follows the LEGO MINDSTORMS convention for I2Csensors, so the driver must be loaded manually. See the sensor’s page formore information. |
[5] | The Dexter Industries dFlex sensor cannot be automaticallydetected (because pin 2 is not connected to pin 3). In order to use thissensor, you must manually set the port to nxt-analog mode and then setthe 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 withthe EV3, chances are it will work with ev3dev.
If you have a sensor that is not supported yet, let us know about it byopening 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-trivialsensors, see the contributing page for information on how to write a driveror 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 cannotbe automatically detected. See notes below in the table of supported sensors.
For sensors that cannot be automatically detected, you can manually controlthe 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 shouldbe automatically detected.
On BrickPi, BrickPi+ and BrickPi3, sensors cannot be automatically detected atall. You must manually configure the input ports for all sensors.
On PiStorms, detection of EV3/UART, EV3/Analog and NXT/I2C sensors issemi-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 tothe set_device
attribute of the port for these sensors.MINDSTORMS Compatible Sensors¶
Most of the supported sensors are designed to work with LEGO MINDSTORMS. Thesesensors use the LEGO sensor class. You can find thesein sysfs at
/sys/class/lego-sensor/
. The sensors have modes that selectwhat type of data is read from the sensor. Generally, you will select a modeand then read the data value from the sensor. Follow the link above for moredetails.Other Sensors and Advanced Usage¶
Many sensors that were not specifically designed for LEGO MINDSTORMS can be usedwith ev3dev too. You can read more about the “Other” sensor types below. Also,some MINDSTORMS compatible sensor may have advanced features that are notaccessible 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 communicateswith the EV3 brick. There are three basic kinds of communication that the inputports can use to get information from the sensor, Analog Sensors, I2C Sensorsand 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 avoltage (0-5VDC) that is read by the EV3.
EV3/Analog Sensors¶
These are sensors that were designed specifically for the EV3 and will not workon the NXT because the pinout is different. They contain an ID resistor so thatthe EV3 can tell different types of sensors apart. The actual analog value ismeasured on pin6.
NXT/Analog Sensors¶
These sensors are designed for the NXT, but also work on the EV3. The EV3 cannotdifferentiate between most of these sensors though, so you have to tell itwhich 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 - atleast not with the converter cable described in the NXT Hardware Developerskit. This is due to a difference in the input port pins between the EV3 andthe 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 toEV3/Analog sensors (require 5V power and have ID resistor). Currently, we onlysupport WeDo sensors attached to a WeDo hub, but if someone would like to designa cable and modify the
wedo-sensor
and lego-ports
drivers, we couldeasily 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 analogand (non-standard) digital communications. The NXT Color Sensor is not usableat this point in time. We can detect it with the auto-detect, but we don’thave a driver for it yet.
I2C Sensors¶
I2C sensors are sensors that communicate with the intelligent brick via theI2C 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 andproduct IDs at specific I2C registers.
Other/I2C Sensors¶
These can be any off-the-shelf I2C device or 3rd party sensors that are designedfor 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 canbe 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 (theydon’t work with the NXT). These sensors are a bit “smarter” in that in additionto sending the data of what they measure, they also send information about theircapabilities. This means that any new EV3/UART sensors should “just work” withoutus 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 connectother devices that use 3.3V or 5V I/O. But, don’t connect anything with highervoltage!
The lego-sensor Subsytem¶
The
lego-sensor
class provides a uniform interface for using most of thesensors available for the EV3. The various underlying device drivers willcreate a lego-sensor
device for interacting with the sensors.![Ev3 Ev3](/uploads/1/3/4/6/134670633/296902649.png)
Sensors are primarily controlled by setting the
mode
and monitored byreading the value<N>
attributes. Values can be converted to floatingpoint if needed by value<N>
/ 10.0 ^ decimals
.Identifying sensors¶
Since the name of the
sensor<N>
device node does not correspond to theport 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 amatching driver_name
. Then it will not matter which port a sensor isplugged 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 individualsensor documentation to determine how to interpret the data. |
bin_data_format | read-only | Returns the format of the values in bin_data for the currentmode. Possible values are:
|
command | write-only | Sends a command to the sensor. See the individual sensor documentationfor possible commands. |
commands | read-only | Returns a space separated list of the valid commands for thesensor. |
direct | read/write | Allows direct communication with the sensor for using advancedfeatures that are not otherwise available through the lego-sensorclass. 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 orwrite the number of bytes required. |
decimals | read-only | Returns the number of decimal places for the values in thevalue<N> attributes of the current mode. |
driver_name | read-only | Returns the name of the sensor device/driver. See the list ofsupported sensors for a complete list of drivers. |
fw_version | read-only | Returns the firmware version of the sensor if available. Currentlyonly NXT/I2C sensors support this. |
mode | read/write | Returns the current mode. Writing one of the values returned bymodes sets the sensor to that mode. See the individual sensordocumentation for a description of the modes available for each typeof 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 avalid value for the current mode. |
poll_ms | read/write | Returns the polling period of the sensor in milliseconds. Writingsets the polling period. Setting to 0 disables polling. Returns-EOPNOTSUPP if changing polling is not supported. Note: Settingpoll_ms too high can cause the input port autodetection to fail.If this happens, use the mode attribute of the port to force theport 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. Checknum_values to see how many values there are. Values withN >= num_values will return an error. The values are fixed pointnumbers, so check decimals to see if you need to divide to getthe actual value. |
text_value | read-only | Returns a space delimited string representing sensor-specific textvalues. Returns -EOPNOTSUPP if a sensor does not support textvalues. |
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 nottrigger any uevents.Sensor Modules¶
The sensor drivers are implemented in the following modules:
EV3/Analog¶
Download Ultrasonic Sensor Ev3
The
ev3-analog-sensor
module provides all of the drivers for EV3/Analogsensors.Ev3 Ultrasonic Sensor Block Download
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 ontop of a tty. It listens for the information data that is sent from EV3/UARTsensors. When it receives valid data, it negotiates with the sensor, tellingthe sensor to enter data sending mode.This line discipline has been assigned the number 29. To attach this linediscipline to a tty, run
ldattach29/dev/tty<N>
where <N>
is the nameof the tty you want to connect to.Note
This driver works with any tty, which means the sensor does notnecessarily have to be plugged into one of the input ports on the EV3.
EV3/UART sensors do not require individual driver implementations like othertypes of sensors. Instead, all of the needed info to sent from the sensor ina 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 LEGOEV3 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 idof the sensor.The
ev3-uart-sensor
module provides all of the drivers for EV3/UARTsensors. This module is only used on devices that can’t use the linediscipline.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/Analogsensors. These drivers scale the analog voltage read from the sensor to auseful 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 valueof 0 will disable polling by default. Changes only affect sensorsplugged in after the change was made. Default is 100 msec. Values mustnot 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/
.