Good to hear Flek.
With the RAW/WARM/COOL I was suggesting this to make it easier to implement. The Adafruit library has a function that returns the detected LED temperature. Perhaps using this code to determine the temperature and then adjust the values from the sensor?
I didn’t study your colour conversion code, is this based on any colour theory? or did you work out a way to make adjust the reported colours to fit what was printed? I also didn’t look at the timing to wait for the trigger to finish, it would be good to optimise this.
I played around with using 60x gain and this worked well for my purposes, perhaps run your tests again with the higher gain (60x), now that the sensor is shielded from direct LED light (with putty) and with the low reflective ‘Black pipe’ outer shield. Would be interested to see if your results improve.
OK, let’s stay with decoupled architecture “2” and see how it goes. With the TWI Switch this means that the smallest mBot can be rigged up to do parallel colour sensing (and use this for line following), U-Sonic distance and still have 2x ports for other functions. Makes it a much more competitive bot for beginners. (If the TWI Switch is ‘piggy-backed’ onto an existing module that doesn’t use TWI/I2C then there is no loss of any ports. e.g. If using the Me RJ25 then you can connect 2 mini servos and make use of the unused TWI/I2C pins to connect to the TWI Switch, 3x modules on the one port !)
On the last picture you are right, I had a mistake and I have now updated the post with correct screenshot.
We are getting there. I have tested the TWI Switch code and seems to work as expected with the updated Colour Sensor code. I can finally get a MakeBlock robot to detect colours, absolutely needed for the robot competitions my primary students are competing in.
I look forward to seeing your updated Colour Sensor extension to see if you can improve on the accuracy of the colour detection. It will always be problematic due to the physical nature of the sensor, how people attach the sensor and how much external light from the surrounding environment pollutes the sensor. You are doing a good job and hopefully with this thread people and limit any errors in their setup, Thanks, .
Connecting a Colour ( Color ) Sensor + TWI Switch ( Multiplexer ) for MakeBlock / mBot
Here is one simple suggestion on how to hook up 2x Colour Sensors on the same port for anyone reading this thread:
Parts:
2x TCS34725 Colour Sensors
1x TCA9548A TWI Switch
6x Pairs of Female to Female Dupont hook up wires
1x Me RJ25 Adapter
You will need to solder header pins to the Me RJ25 to get access to spare TWI/I2C, VCC & GND pins. You will also need to get VCC and GND for the two colour sensors from the Me RJ25, (or alternatively create a small power rail, take the spare VCC and GND from Me RJ25, attach to the power rail, then you have power for all your colour sensors).
Make sure you put a little bit of ‘Blue Tack’ or opaque putty between the sensor and the LED to stop the LED light directly shining on the sensor. Be careful not to put anything on the sensor!!!
Use some reticulation black poly pipe (13mm/ 0.5 inch) stuck to the board to provide a shroud to limit external light and keep both sensors close to same illumination from LED.
And on the robot with me line sensor between: