Atelier Louis

Calibrating the Pimoroni BH1745 RGB colour sensor

door Peter van der Werf - naar overzicht
 
 
The project aim is to measure the change in daylight color. In photography specific moments of the day has names as the golden hour or blue hour, when the color of the daylight gives an intense effect in the photo.

To measure these moments with my Raspberry PI, I bought the Pimoroni BH1745 colour sensor. The BH1745 sensor is capable of detecting light in 3 color channels and a clear channel (RGBC - red, green, blue and clear).

The sensor comes with a tutorial on Github with a basic readout of the sensor: raw values, scaled values against the clear channel and clamped values. The problem with these basic readouts is that light intensity is not an linear scale. In photography light intensity is expressed as stops: one stop is a factor of two change in light intensity.

 
 
Below are different methodes of calculating the color results of the Pimoroni BH1745 sensor. With each method the result is shown of one day of daylight recordings (one recording-stripe per minute, 24 hours x 60 minutes = 1440 stripes).
 
Pimoroni scaled values = min(255, round(raw_value / raw_clear_value * 255))
if devide by zero than scaled value = 0

Scaled by stops and clear channel = min(255, round(log(raw_value,2) / log(raw_clear_value,2) * 255))
if devide by zero than scaled value = 0

Scaled by stops and max value = min(255, round(log(raw_value,2) / log(max_raw_value,2) * 255))
Based on 159738 measurements of daylight:
ChannelMax raw valueNumber of stops
Red14417717.1
Green6553516
Blue11796316.8
Clear26769018
Pimoroni clamped values = min(255, round(raw_value / max_channel_value * 255))
Max channel value is the highest value of all RGB channels

clamped by stops and max channel value = min(255, round(log(raw_value,2) / log(max_channel_value,2) * 255))