-
I'm working on getting this working, and I'm guessing that I'm just doing something stupid as I can't get it to work. I have it plugged into Port.S3 and I can see it and the ports it creates in the device browser (as well as the devices plugged into it - gyro, color and touch, in that order). For the color sensor for instance, I see that it has been assigned a port of "ev3-ports:in3:i2c81:mux2". I've tried everything I can think of to try and use that string (or parts of it) to assign as a port to create my color sensor... For instance:
I'm sure it's simple, but I'm not figuring it out... Any help would be appreciated. Danny |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
Pybricks only supports sensors directly connected to the ports on the EV3. To use the multiplexer, you will have to read and write files in You could probably reuse code from Pybricks v1 for this:
The |
Beta Was this translation helpful? Give feedback.
-
So, this is now working - partially. I didn't notice at first, but the device browser always thinks any UART device is a color sensor when connected through the mux, regardless of what's attached. As a result, I haven't been able to get anything working through the mux other than touch sensors (analog device) or the color sensor. But the good news is that both of them work very well. What I ended up doing was specifying the port as an int (which I found in the device browser after plugging in the device). Under sensors, I browse to it and see what name it was given - something like sensor27 - where that number is what I used as my port value. I'll also note that I amended all the names of the classes within ev3devices.py with "Mux" so that they wouldn't interfere with the existing ones. So, with all that said, I would create a device like this:
As far as usage goes, it's the same as a normal device after that. To make the above work, I did have to make a change to the ev3devio.py file in a couple places. Within the
Finally, within the
to this:
|
Beta Was this translation helpful? Give feedback.
-
So, I have this working now. I figured I'd post my code so that if anyone else ever needs this they're not reinventing the wheel. Or maybe Mindsensors will decide to incorporate this into their mindsensorPYB.py file for "official" support some day... I've performed basic testing on all 5 EV3 device types (touch, color, gyro, ultrasonic, and infrared) and have verified basic functionality. It only works with these 5 devices and won't work with NXT, or other devices at this time (at least that I know of). I parallel tested each sensor with one connected to the EV3 port and got essentially the same results on every sensor in every situation I tested. The testing wasn't extensive by any means, but I do have confidence that basic functionality is there and that the readings are essentially the same as what I get without the mux. I'll also note that I tested this under both pybricks-micropython and pybricks-micropython3 and found no issues with v3 which is a nice bonus. WARNINGS: Usage:
Two python files are needed and are in the attached zip file. Place them in your project, and you should be all set. |
Beta Was this translation helpful? Give feedback.
So, I have this working now. I figured I'd post my code so that if anyone else ever needs this they're not reinventing the wheel. Or maybe Mindsensors will decide to incorporate this into their mindsensorPYB.py file for "official" support some day...
I've performed basic testing on all 5 EV3 device types (touch, color, gyro, ultrasonic, and infrared) and have verified basic functionality. It only works with these 5 devices and won't work with NXT, or other devices at this time (at least that I know of). I parallel tested each sensor with one connected to the EV3 port and got essentially the same results on every sensor in every situation I tested. The testing wasn't extensive by any means…