Open Aiden-Frank opened 1 year ago
I think you might need to set the mode of the port to "nxt-analog" instead of "ev3-analog".
Thank you for responding. Unfortunately I've tried that already: the output varies randomly from about 5620 to 5650, regardless of whether the sensor is plugged in.
After looking at the docs, I see the sensor adapter is an I2C device itself and not just a passthrough device. So you will need set the mode of the port to "other-i2c" and use the Python SMBus library to send I2C commands to the adapter.
Thanks so much, I'll try that when I have time this weekend.
I set the mode to that, but I got this error:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 274, in _set_attribute
attribute.write(value)
OSError: [Errno 22] Invalid argument
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/robot/Snoofer_bot_OS6/whisker_test.py", line 20, in <module>
right_whisker_port=load_port(INPUT_2,"other-i2c")
File "/home/robot/Snoofer_bot_OS6/whisker_test.py", line 16, in load_port
port.mode=mode
File "/usr/lib/python3/dist-packages/ev3dev2/port.py", line 128, in mode
self._mode = self.set_attr_string(self._mode, 'mode', value)
File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 337, in set_attr_string
return self._set_attribute(attribute, name, value)
File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 277, in _set_attribute
self._raise_friendly_access_error(ex, name, value)
File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 297, in _raise_friendly_access_error
driver_error)
File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 54, in chain_exception
raise exception from cause
ValueError: One or more arguments were out of range or invalid, value b'other-i2c'
----------
Exited with error code 1.
Edit: I tried "i2c-thru" and it didn't give an error there, will that work?
Yes, that looks like the correct mode for PiStorms.
First, thank you to everyone who has built this software. I'm trying to use a Grove Voltage Divider with a PiStorms-v2. I have it plugged in via a grove-to-mindstorms adapter, but I can't get it to understand the input. Is there a way to read the Grove sensor output?
I am trying to measure voltage across a resistor. The resistor is flexible and acts as a "whisker" that tells the robot if it's bumping into things while it's moving.
OS and version: MacOS 12.2.1
Connection Type: Wi-Fi
Software: Visual Studio Code
Device: PiStorms v2 mounted on Raspberry Pi 3b
System info (from
ev3dev-sysinfo
)This is the code I'm trying to run. Currently, it identifies the Grove as a Touch Sensor emitting a constant 1.