Example Code for Arduino-UART Data Reading
Last revision 2025/12/19
Read color temperature, illuminance, and xy color coordinates data from the sensor using UART communication. Users can learn how to connect the sensor to Arduino via UART and use the DFRobot_ColorTemperature library to retrieve data.
Hardware Preparation
- DFRduino UNO Controller x1
- SEN0611 Gravity: Color Temperature Illuminance Sensor x1
Software Preparation
- Arduino IDE Click to Download Arduino IDE
- Download and install DFRobot_ColorTemperature library. How to Install Library?
Wiring Diagram

Other Preparation Work
- Connect the module to the UNO controller according to the above wiring diagram, of course, you can also use the expansion board, which can be more convenient and faster to complete the project prototype.
- Switch the selector switch on the sensor to the UART side.
- Download and install DFRobot_ColorTemperature library. How to Install Library?
- Note: Power off when switching the switch
Sample Code
#include "DFRobot_ColorTemperature.h"
#include <SoftwareSerial.h>
SoftwareSerial mySerial(/*rx =*/4, /*tx =*/5);
DFRobot_ColorTemperature CT(/*s =*/&mySerial);
void setup()
{
mySerial.begin(9600);
Serial.begin(115200);
while(CT.begin() != 0){
Serial.println(" Sensor initialize failed!!");
delay(1000);
}
Serial.println(" Sensor initialize success!!");
}
void loop()
{
Serial.println("-------------------------------");
Serial.print("LUX: ");
Serial.println(CT.readLUX());
Serial.print("CCT: ");
Serial.println(CT.readCCT());
Serial.print("X: ");
Serial.println(CT.readX());
Serial.print("Y: ");
Serial.println(CT.readY());
Serial.println("-------------------------------");
delay(500);
}
Result
Open the serial monitor of Arduino IDE, adjust the baud rate to 115200, and observe the serial print result to obtain the final color temperature, illuminance, and X, Y color coordinates data.
Additional Information
- Ensure the sensor is connected correctly and the UART mode is selected.
- Power off before switching the communication mode switch.
Was this article helpful?
