Closed logwet closed 7 years ago
The ColorSensor
class is for the LEGO EV3 Color sensor only. Use the generic Sensor
class instead.
http://python-ev3dev.readthedocs.io/en/stable/sensors.html#sensor
Try something like this...
cl = Sensor(address='in2', driver='ht-nxt-color-v2')
" Try something like this...
cl = Sensor(address='in2', driver='ht-nxt-color-v2') "
Did it work? I have the same problem. I did that but I got the same error message: Exception: Device is not connected.
It might need to be:
cl = Sensor(address='in2', driver_name='ht-nxt-color-v2')
Or if you have an older version of the sensor, leave off the -v2
.
That is correct, it should be driver_name
. Also, the address could be wrong. Can you go to your command line on EV3, and see if there is sensor in /sys/class/lego-sensor
? If there is not, then you do not have it connected (or there is another problem); if there is, try to see its address with cat /sys/class/lego-sensor/sensor*/address
.
Thanks for answearing. I noticed the driver_name mistake but it is still not working. The Brickman recognizes the sensor because when I go to sensors in the ev3 panel I see the sensor ht-nxt-color-v2. I also see the address which is 'In1:i2c1'.
I guess that the lines you tell me to use should give me the same result, or not? Anyway, /sys/class/lego-sensor/sensor*/address that line is suppossed to be written on mobaxterm (I created the SSH connection with that program), right?
I wanna thank you guys in advance.
How about this?
cl = Sensor(address='in2:i2c1', driver_name='ht-nxt-color-v2')
I have already done it and I keep getting the same error.
Just a thought: why do you use sudo? Can you try without it?
Do you mean executing the program from de EV3? I did that and the screen goes empty for a second. Then it returns to the screen of program selection.
I mean you had this in your example:
robot@ev3dev:~$ sudo python3 first.py
...
Why do you have sudo here? Can you just try
robot@ev3dev:~$ python3 first.py
...
?
Also, I just noticed I got the input port wrong from what you reported seeing in Brickman. The values in python should match exactly what you see in Brickman.
cl = Sensor(address='in1:i2c1', driver_name='ht-nxt-color-v2')
Thanks guys, it seems that I had put some blank spaces before and after the equals that are inside the parenthesis. I could read the sensor in mode 'RAW'. However, I have to say that the measured values are not the ones that the docs (http://docs.ev3dev.org/projects/lego-linux-drivers/en/ev3dev-jessie/sensor_data.html#hitechnic-nxt-color-sensor-v2) indicate.
I don't have one of these sensors for testing, so the values could very well be wrong. If you have any insights, please open an issue at https://github.com/ev3dev/ev3dev/issues, or even better, edit https://github.com/ev3dev/lego-linux-drivers/blob/ev3dev-stretch/sensors/nxt_i2c_sensor_defs.c and send a pull request.
Related ev3dev/ev3dev#920
Hi guys, I'm a bit late to the party but @Kvothe1997 I have found just
cl = Sensor(address='in2')
To work with the hiTechnic v2s. No idea why I can't define the driver but this works perfectly. I can also use all 6 modes :)
Looks like this is resolved so closing....if not please re-open
uname -r
HEREI was attempting to read values from a HiTechnic v2 NXT color sensor (which is listed as supported on the ev3dev wiki) in my project. Here is the code from the script:
When run with
sudo python3 first.py
I recieve the following errors:This is very weird because the sensor is definetly connected (it is powered), I can access and read values from it through Brickman, and the driver is also listed as
ht-nxt-color-v2
I urgently need this particular sensor working for my project because I'm participating in RoboCup Junior Aus.