![]() |
I2C Color Sensor not working
My team recently purchased a Modern Robotics Color Sensor, so we are trying to test it out before implementing it on our robot. However whenever we try to use the read method on the color sensor, it return true, meaning the transfer was aborted. However we tried communicating with it and we can, because we are able to turn on and off the led on the sensor. Can someone please explain?
The problem is at line 150. https://github.com/CougarRobotics198...new/Robot.java |
Re: I2C Color Sensor not working
Are you using the color sensor found at: http://www.modernroboticsinc.com/color-sensor
If so, it looks like product page indicates that the address of the sensor is 0x3C. Could it be that you just need to change: Code:
ColorSensor = new I2C(I2C.Port.kOnboard, 0x1E);Code:
ColorSensor = new I2C(I2C.Port.kOnboard, 0x3C); |
Re: I2C Color Sensor not working
Quote:
I recommend you try both and see which way it is. |
Re: I2C Color Sensor not working
Quote:
|
Re: I2C Color Sensor not working
So what we've experienced is that our addressing appears to be correct. We are able to turn the LED on and off.
What's not working is the I2C read. Code below: byteAr = new byte[1]; boolean success = !ColorSensor.read(0x04, 1, byteAr); The read is always returning true, which means the read has failed. If we ignore that and try to use the value in byteAr we get an index out of bounds exception. Not sure where to go from here since it does not appear to be address related. FWIW, we were able to connect the sensor to a Raspberry Pi and read from the various address locations. RoboRio no success. Any ideas? |
Re: I2C Color Sensor not working
bump? Anyone?
|
Re: I2C Color Sensor not working
That is strange that the write operation would work while the read operation would not.
Is it possible that the voltage levels would make a difference? I'm not an electronics person, but I think I have noticed that some I2C devices are 3.3V and some are 5V and some will dynamically adjust. The roboRIO is labeled for 3.3V on the I2C power and from the website (http://www.modernroboticsinc.com/color-sensor) it looks like the sensor is expecting 5V on the power line (the website doesn't say that it won't work on 3.3V, but I didn't see anything saying that it would either). Does the Raspberry PI that the sensor worked on have a 3.3V I2C bus like the roboRIO or a 5V I2C bus? Not sure how this might impact things or if it could explain why you can send data to the sensor but not get anything back, but maybe it is something to consider or to ask the manufacturer of the sensor. I have seen ads for items designed to convert between 3.3V and 5V I2C lines (https://www.adafruit.com/products/757). Have never tried using one though. Good Luck. |
| All times are GMT -5. The time now is 09:19. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi