This is the description of the TCP/IP protocol for the Color Bricklet. General information and technical specifications for the Color Bricklet are summarized in its hardware description.
A general description of the TCP/IP protocol structure can be found here.
Function ID: | 1 |
---|---|
Request: | empty payload |
Response: |
|
Returns the measured color of the sensor. The values have a range of 0 to 65535.
The red (r), green (g), blue (b) and clear (c) colors are measured with four different photodiodes that are responsive at different wavelengths:
If you want to get the color periodically, it is recommended to use the callback CALLBACK_COLOR and set the period with set_color_callback_period.
Function ID: | 10 |
---|---|
Request: | empty payload |
Response: | no response |
Turns the LED on.
Function ID: | 11 |
---|---|
Request: | empty payload |
Response: | no response |
Turns the LED off.
Function ID: | 12 |
---|---|
Request: | empty payload |
Response: |
|
Returns the state of the LED. Possible values are:
Function ID: | 13 |
---|---|
Request: |
|
Response: | no response |
Sets the configuration of the sensor. Gain and integration time can be configured in this way.
For configuring the gain:
For configuring the integration time:
Increasing the gain enables the sensor to detect a color from a higher distance.
The integration time provides a trade-off between conversion time and accuracy. With a longer integration time the values read will be more accurate but it will take longer time to get the conversion results.
The default values are 60x gain and 154ms integration time.
Function ID: | 14 |
---|---|
Request: | empty payload |
Response: |
|
Returns the configuration as set by set_config.
Function ID: | 15 |
---|---|
Request: | empty payload |
Response: |
|
Returns the illuminance affected by the gain and integration time as set by set_config. To get the illuminance in Lux apply this formula:
lux = illuminance * 700 / gain / integration_time
To get a correct illuminance measurement make sure that the color values themself are not saturated. The color value (R, G or B) is saturated if it is equal to the maximum value of 65535. In that case you have to reduce the gain, see set_config.
Function ID: | 16 |
---|---|
Request: | empty payload |
Response: |
|
Returns the color temperature in Kelvin.
To get a correct color temperature measurement make sure that the color values themself are not saturated. The color value (R, G or B) is saturated if it is equal to the maximum value of 65535. In that case you have to reduce the gain, see set_config.
Function ID: | 255 |
---|---|
Request: | empty payload |
Response: |
|
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
The position can be 'a', 'b', 'c' or 'd'.
The device identifier numbers can be found here.
Function ID: | 2 |
---|---|
Request: |
|
Response: | no response |
Sets the period in ms with which the CALLBACK_COLOR callback is triggered periodically. A value of 0 turns the callback off.
CALLBACK_COLOR is only triggered if the color has changed since the last triggering.
The default value is 0.
Function ID: | 3 |
---|---|
Request: | empty payload |
Response: |
|
Returns the period as set by set_color_callback_period.
Function ID: | 4 |
---|---|
Request: |
|
Response: | no response |
Sets the thresholds for the CALLBACK_COLOR_REACHED callback.
The following options are possible:
Option | Description |
---|---|
'x' | Callback is turned off |
'o' | Callback is triggered when the temperature is outside the min and max values |
'i' | Callback is triggered when the temperature is inside the min and max values |
'<' | Callback is triggered when the temperature is smaller than the min value (max is ignored) |
'>' | Callback is triggered when the temperature is greater than the min value (max is ignored) |
The default value is ('x', 0, 0, 0, 0, 0, 0, 0, 0).
Function ID: | 5 |
---|---|
Request: | empty payload |
Response: |
|
Returns the threshold as set by set_color_callback_threshold.
Function ID: | 6 |
---|---|
Request: |
|
Response: | no response |
Sets the period in ms with which the threshold callback
is triggered, if the threshold
keeps being reached.
The default value is 100.
Function ID: | 7 |
---|---|
Request: | empty payload |
Response: |
|
Returns the debounce period as set by set_debounce_period.
Function ID: | 17 |
---|---|
Request: |
|
Response: | no response |
Sets the period in ms with which the CALLBACK_ILLUMINANCE callback is triggered periodically. A value of 0 turns the callback off.
CALLBACK_ILLUMINANCE is only triggered if the illuminance has changed since the last triggering.
The default value is 0.
Function ID: | 18 |
---|---|
Request: | empty payload |
Response: |
|
Returns the period as set by set_illuminance_callback_period.
Function ID: | 19 |
---|---|
Request: |
|
Response: | no response |
Sets the period in ms with which the CALLBACK_COLOR_TEMPERATURE callback is triggered periodically. A value of 0 turns the callback off.
CALLBACK_COLOR_TEMPERATURE is only triggered if the color temperature has changed since the last triggering.
The default value is 0.
Function ID: | 20 |
---|---|
Request: | empty payload |
Response: |
|
Returns the period as set by set_color_temperature_callback_period.
Function ID: | 8 |
---|---|
Response: |
|
This callback is triggered periodically with the period that is set by set_color_callback_period. The response value is the color of the sensor as RGBC.
CALLBACK_COLOR is only triggered if the color has changed since the last triggering.
Function ID: | 9 |
---|---|
Response: |
|
This callback is triggered when the threshold as set by set_color_callback_threshold is reached. The response value is the color of the sensor as RGBC.
If the threshold keeps being reached, the callback is triggered periodically with the period as set by set_debounce_period.
Function ID: | 21 |
---|---|
Response: |
|
This callback is triggered periodically with the period that is set by set_illuminance_callback_period. The response value is the illuminance. See get_illuminance for how to interpret this value.
CALLBACK_ILLUMINANCE is only triggered if the illuminance has changed since the last triggering.
Function ID: | 22 |
---|---|
Response: |
|
This callback is triggered periodically with the period that is set by set_color_temperature_callback_period. The response value is the color temperature in Kelvin.
CALLBACK_COLOR_TEMPERATURE is only triggered if the color temperature has changed since the last triggering.