ev3dev/ev3dev-lang-python

hitechnic IRSeekerV2

bergowitch opened this issue · 2 comments

Hello,
I try to get the hitechnic IRSeekerV2 on the EV3 with ev3dev in python to work, but I don´t know how...
I don´t find any hint.
Thanks
Stefan

Unfortunately, we don't have a pre-made class which wraps up this sensor's functionality in a nice package. That being said, it is still reasonably easy to use. You will need to use our Sensor class and use its value method to read sensor values.

The documentation for the sensor driver itself is here, for your reference: http://docs.ev3dev.org/projects/lego-linux-drivers/en/ev3dev-stretch/sensor_data.html#hitechnic-nxt-irseeker-v2

And the documentation for our own Sensor class is here: https://ev3dev-lang.readthedocs.io/projects/python-ev3dev/en/ev3dev-stretch/sensors.html#base-sensor

To use the sensor, it should look like this:

from ev3dev2.sensor import Sensor

seeker = Sensor(driver_name='ht-nxt-ir-seek-v2')
seeker.mode = 'DC'
# direction is 0 for no signal, or 1-9 for left-right direction
direction = seeker.value(0)

You can see that I create a Sensor object and use the driver name from the first documentation page I linked to. I then set the mode to DC, which the documentation says gives us direction. If you also want the signal strength measurements, you will need to change the mode to DC-ALL. If the above doesn't work, you might need to use the AC mode instead: I don't know which type of source is being used.

Thank you very much!
I got the hitechnic compass sensor working the same way!
I'm very glad!