How to Connect a Color Sensor to a Raspberry Pi


Share This Post

In this article, we will show you how to connect an Atlas Scientific EZO-RGB™ Embedded Color Sensor to a Raspberry Pi. There are multiple ways to connect Atlas Scientific sensors to your device of choice. In previous posts we have shown how to wire our EZO™ sensors directly into an Arduino and/or a Raspberry Pi. For this article we’ll be using our Gen 2 Electrically Isolated USB EZO™ Carrier Board connected to an Raspberry Pi 3.0 B+ , running our Atlas IoT Monitoring Software.

Necessary items

Before we begin have the following items readily available:


At full power, the onboard LEDs are VERY bright.
Do not look directly at the light without wearing eye protection.

Step 1. Installing the IoT Monitoring Software

There are two different ways to install our IoT Monitoring Software, via Image file OR Zip file. For today’s article, we are going to use the Image file method, which has the Raspberry Pi OS and Atlas IoT already installed and ready to go, once its fully mounted onto a SD card.

Let’s begin by downloading the Atlas IoT Software – Image file, by clicking HERE. Once the image file has finished downloading, extract the file. Next, we’ll need to mount the image onto a Micro SD card, using a program called Win32 Disk Imager

(This program is for PC only, if you are following along on a MAC you can use a program called Raspberry Pi Imager*

*Atlas Scientific has not tested this software, this is what is recommended by the Raspberry Pi community

Now that the Disk Imager software is installed, lets mount the IoT Image file to our SD card.
Begin by inserting the Micro SD card into your card reader of choice and connect that to your PC, then launch the program. Click on the blue folder icon, locate, and select the extracted AtlasIoT.img file. Then click on the “Write” button to begin mounting the image.

The mounting process should take ~12 mins (depending on the Micro SD card used)

Now that the AtlasIoT.img has been successfully mounted onto the Micro SD card, remove it from card reader and insert it into the Raspberry Pi.

Step 2. Connecting to the Raspberry Pi

Using the HDMI cable, connect the monitor of your choice to the Raspberry Pi. Next, connect the USB power supply and mouse to the Pi. If you haven’t already, attach the 4 standoffs (legs) to the Gen 2 Electrically Isolated USB EZO™ Carrier Board, and then attach the Micro USB cable into both, the Carrier board and Pi.

Insert the EZO™ Adapter directly into the Carrier board, just like you would do if this were an EZO™ class circuit.

Next, connect the EZO-RGB™ Embedded Color Sensor to the EZO™ Adapter. Just slide the sensor connector onto the adapter. There are color indicators on the sides of the EZO™ Adapter, make sure you line it up correctly!

*Side Note

For the Raspberry Pi to detect the EZO-RGB™ Embedded Color Sensor via USB, the sensor must be in UART mode. By default, all our EZO devices are in UART mode. You can easily tell what mode the circuit is in by looking at the LED on the back of the sensor. If the LED is blinking green, you are in UART mode. If its solid blue you are in I2C mode.

If your EZO-RGB™ Embedded Color Sensor is in I2C mode, don’t worry, it can be switched from I2C mode to UART mode easily. Refer to the EZO-RGB™ Embedded Color Sensor datasheet on how to switch to UART mode.

Now that everything is properly connected, boot up the Raspberry Pi, and monitor. The Pi will run through an initial setup and may reboot a few times in the process. This only happens during the 1st time it boots up. Once the Pi OS has finished loading, it will automatically load the Atlas IoT Monitoring Software. From here we can see the live readings from the EZO-RGB™ Embedded Color Sensor.

Step 3. Viewing Color Sensor Readings

Once The Atlas IoT Monitoring Software has loaded you should see a black screen with a small, outlined rectangle (this rectangle shows the current color of the target object). Using your attached USB mouse click on the rectangle, to open the RGB Screen of the software. The readings will now be displayed in the full-sized screen on the monitor

You should see three values displayed on the screen, R = red, G = green and B = blue (each of these values range from 0 – 255); along with a rectangle that shows you the color of the target object. If your EZO-RGB™ Embedded Color Sensor hasn’t been calibrated, the sensor will have trouble reading the colors correctly, as they may appear too dark. Let’s calibrate the color sensor to improve its accuracy. To being the calibration process, click on the gear icon, located at the bottom left of the screen.

Step 4. Calibration

Before we get into the calibration process, there is one important factor to consider when reading color: Distance

As the EZO-RGB™ Embedded Color Sensor is placed further away from the target object, its ability to detect color is diminished. At distances greater than 45cm most colors become varying shades of gray.

The EZO-RGB™ Embedded Color Sensor is designed to be calibrated to a white object at the maximum brightness the object will be viewed under. To get the best results Atlas Scientific strongly recommends that the sensor is mounted into a fixed location. Holding the sensor in your hand during calibration will decrease performance.

1. Embed the Color Sensor into its intended use location.

2. Set LED brightness to the desired level.

3. Place a white object in front of the target object and then click on the calibrate button.

4. A single color reading will be taken, and the device will be fully calibrated.

Now, you can take accurate color readings. Within the RGB color screen you will see the R, G, B value of the target object. When at the home screen, the Hex color # of the target object will be shown.

EZO-RGB™ Embedded Color Sensor

Subscribe To Our Newsletter

Get product updates and learn from the best!

More To Explore


Analog Vs. Digital Sensors: Understanding The Key Differences

One of the key differences between analog and digital sensors is their output resolution. For example, analog sensors provide infinite resolution since they provide a continuous range of values, while digital sensors have a finite resolution determined by the number of bits used to represent the signal. Another difference is the susceptibility to noise. Analog


Hydroponics Pros And Cons Explained

Pros of hydroponics include efficient water use, faster growth rates, and the ability to grow crops in limited spaces. However, cons may involve higher initial setup costs, the need for technical expertise, and a reliance on artificial lighting and climate control. Also, many argue that hydroponically grown produce may lack certain flavors or nutrients compared

Want to learn more about our products?

Scroll to Top

To track your order please enter your Order ID in the box below and press the "Track" button. This was given to you on your receipt and in the confirmation email you should have received.