Enviro pHAT not displaying right rgb values

Hi all,

I unpacked and soldered my Enviro pHat today and tried the RGB sensors. I simply followed the Getting started tutorial
It seems like I a receiving the wrong rgb values. Here is the output of some tests I did while holding a yellow and a white thing above the sensor:

>>> print(light.rgb())
(89, 77, 73)
>>> print(light.rgb())
(74, 75, 93)
>>> print(light.rgb())
(76, 74, 92)
>>> print(light.rgb())
(68, 80, 91)
>>> print(light.rgb())
(63, 81, 98)
>>> print(light.rgb())
(54, 80, 104)
>>> print(light.rgb())
(39, 78, 112)
>>> print(light.rgb())
(42, 80, 111)
>>> print(light.rgb())
(64, 85, 98)
>>> print(light.rgb())
(71, 76, 92)
>>> print(light.rgb())
(64, 79, 96)
>>> print(light.rgb())
(57, 79, 101)

I tried to switch the LEDs off and on, but that doesn’t change much and it also doesn’t give me the right values.

Any idea what might be wrong?

Unfortunately yellow and white are about the hardest things for a colour sensor to sense. With colour being a spectrum, and an RGB colour sensor only “seeing” the Red, Green and Blue filtered slices of that spectrum, it doesn’t tend to give very meaningful results.

Chances are you’ll never see anything close to the “right” values since few objects reflect only Red, Green or Blue light.

It’s a tricky process, but try varying the distance you hold the object, and find something ( a section of cardboard tube perhaps ) to block out any external light and you might get better readings.

1 Like

Thanks for your answer!

It took some time to build a construction with cardboard and find a good position of the sensor, but I am now able to identify yellow. :)