# Adafruit AS7262 6-channel Visible Light Sensor

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/052/637/medium800/light_3779_top_demo_01_ORIG.2018_03jpg.jpg?1522268085)

_The colors of the rainbow, so pretty in the sky_  
_Are also in this sensor, controlled by you and I!_

Detect trees of green, and red roses too with the new **Adafruit AS7262 6-Channel Visible Light / Color Sensor Breakout**. This sensor from AMS has 6 integrated visible light sensing channels for red, orange, yellow, green, blue, and violet. These channels can be read via the I2C bus as either raw 16-bit values or calibrated floating-point values. There is also an on-board temperature sensor that can be used to read the temperature of the chip, and a powerful LED flash to reflect light off objects for better color detection.

![](https://cdn-learn.adafruit.com/assets/assets/000/052/638/medium800/light_3779_iso_ORIG_2018_03.jpg?1522268114)

The 6 channels on the AS7262 are realized by silicon interference filters at 450nm, 500nm, 550nm, 570nm, 600nm, and 650nm. This breakout uses the I2C interface on the chip by default, but a UART interface that accepts AT commands is also selectable.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/052/640/medium800/light_3779_quarter_ORIG_2018_03.jpg?1522268135)

We've placed the sensor on a PCB for you and included an SPI flash chip pre-programmed with the device firmware, a 3.3V regulator, I2C level shifting, and the recommended LED with 5700K color temperature. Both the I2C and UART interfaces are broken out, making this breakout an excellent all-in-one solution for all your color-sensing needs. The pinout for the UART interface is plug-and-play compatible with the Adafruit FTDI Friend.

We've also prepared software libraries to get you up and running in Arduino or CircuitPython with just a few lines of code!

![](https://cdn-learn.adafruit.com/assets/assets/000/052/639/medium800/light_3779_kit_ORIG_2018_03.jpg?1522268125)

# Adafruit AS7262 6-channel Visible Light Sensor

## Pinouts

![](https://cdn-learn.adafruit.com/assets/assets/000/052/641/medium800/light_pniout.jpg?1522268332)

This sensor has 4 mounting holes and 2 header breakout strips.

## Power Pins:

- **Vin** &nbsp;- this is the power pin. Since the sensor uses 3.3V, we have included an onboard voltage regulator that will take 3-5VDC and safely convert it down.&nbsp;To power the board, give it the same power as the logic level of your microcontroller - e.g. for a 5V micro like Arduino, use 5V
- **3Vo** &nbsp;- this is the 3.3V output from the voltage regulator,&nbsp;you can grab up to 100mA from this if you like
- **GND** &nbsp;- common ground for power and logic

## &nbsp;

## Logic pins:

- **SCL&nbsp;** - this is the I2C clock pin, connect to your microcontrollers I2C clock line. There is a 10K pullup on this pin and it is level shifted so you can use 3 - 5VDC. If UART mode is selected, this pin acts as RX.
- **SDA&nbsp;** - this is&nbsp;the I2C data pin, connect to your microcontrollers I2C data line. There is a 10K pullup on this pin and it is level shifted so you can use 3 - 5VDC. If UART mode is selected, this pin acts as TX.
- **RST** &nbsp;- this is the reset pin. When it is pulled to ground the sensor resets itself. This pin is level shifted so you can use 3-5VDC logic.

Solder closed the&nbsp; **UART SELECT** jumper to switch the sensor into UART mode.

## UART Logic pins:

- **TX&nbsp;** - this is the UART transmit pin, connect to your microcontrollers UART RX line. There is a 10K pullup on this pin and it is level shifted so you can use 3 - 5VDC. If I2C mode is selected, this pin acts as SCL.
- **RX&nbsp;** - this is&nbsp;the UART receive pin, connect to your microcontrollers UART TX line. There is a 10K pullup on this pin and it is level shifted so you can use 3 - 5VDC. If I2C mode is selected, this pin acts as SDA.

# Adafruit AS7262 6-channel Visible Light Sensor

## Arduino Wiring & Test

You can easily wire this breakout to any microcontroller, we'll be using an Adafruit Metro M0 Express (Arduino compatible) with the Arduino IDE. But, you can use any other kind of microcontroller as well as long as it has I2C clock and I2C data lines.

![](https://cdn-learn.adafruit.com/assets/assets/000/052/581/medium800/light_AS7262_bb.png?1522172438)

# I2C Wiring

- Connect&nbsp; **Vin** &nbsp;to the power supply, 3-5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
- Connect&nbsp; **GND&nbsp;** to common power/data ground
- Connect the&nbsp; **SCL** &nbsp;pin to the I2C clock&nbsp; **SCL** &nbsp;pin on your Arduino.&nbsp;  
On an UNO & '328 based Arduino, this is also known as&nbsp; **A5** , on a Mega it is also known as&nbsp; **digital 21** &nbsp;and on a Leonardo/Micro,&nbsp; **digital 3**
- Connect the&nbsp; **SDA** &nbsp;pin to the I2C data&nbsp; **SDA&nbsp;** pin on your Arduino.&nbsp;  
On an UNO & '328 based Arduino, this is also known as&nbsp; **A4** , on a Mega it is also known as&nbsp; **digital 20** &nbsp;and on a Leonardo/Micro,&nbsp; **digital 2**

This sensor uses I2C address&nbsp; **0x49**.

# Download Adafruit\_AS726x library

To begin reading sensor data, you will need to download Adafruit\_AS726x from the Arduino library manager.

Open up the Arduino library manager:

![](https://cdn-learn.adafruit.com/assets/assets/000/084/447/medium800/light_1library_manager_menu.png?1574044837)

Search for the&nbsp; **Adafruit AS726X&nbsp;** library and install it

![](https://cdn-learn.adafruit.com/assets/assets/000/084/449/medium800/light_as726x.png?1574044939)

We also have a great tutorial on Arduino library installation at:  
[http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use](http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use)

# Load&nbsp;Test Example

Open up&nbsp; **File-\>Examples-\>Adafruit\_AS726x-\>AS7262\_test** &nbsp;and upload to your Arduino wired up to the sensor. This example connects to the sensor and starts taking readings.

Once uploaded to your&nbsp;Arduino, open up the serial console at 9600 baud speed to see the readings. Your sensor will read the temperature and it's 6 visible light channels. Your serial monitor will look something like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/052/589/medium800/light_Screenshot_%2880%29.png?1522174340)

# TFT Demo

You can create a nice bar graph of the sensors 6 color channels using a 0.90 inch TFT from Adafruit.

### Adafruit 0.96" 160x80 Color TFT Display w/ MicroSD Card Breakout

[Adafruit 0.96" 160x80 Color TFT Display w/ MicroSD Card Breakout](https://www.adafruit.com/product/3533)
Say hello to our **0.96" 160x80 Color TFT Display w/ MicroSD Card Breakout** – we think it's **T** - **F** - **T** errific! It's the size of your thumbnail, with glorious 160x80 pixel color. This very very small display is only...

In Stock
[Buy Now](https://www.adafruit.com/product/3533)
[Related Guides to the Product](https://learn.adafruit.com/products/3533/guides)
![TFT breakout wired up on breadboard, showing colorful image](https://cdn-shop.adafruit.com/640x480/3533-07.jpg)

Wire the TFT up as shown:

![](https://cdn-learn.adafruit.com/assets/assets/000/052/625/medium800/light_AS7262_bb_lcd.png?1522185106)

Upload the following code to your board through the Arduino IDE (the code is also available under&nbsp; **File-\>Examples-\>Adafruit\_AS726x-\>color\_graph** )

https://github.com/adafruit/Adafruit_AS726x/blob/master/examples/color_graph/color_graph.ino

# Adafruit AS7262 6-channel Visible Light Sensor

## Python & CircuitPython

It's easy to use the AS7262 with Python or CircuitPython and the&nbsp;[Adafruit CircuitPython AS726x](https://github.com/adafruit/Adafruit_CircuitPython_AS726)&nbsp;module.&nbsp; This module allows you to easily write Python code that reads color data and temperature from the sensor.

You can use this sensor with any CircuitPython microcontroller board or with a computer that has GPIO and Python&nbsp;[thanks to Adafruit\_Blinka, our CircuitPython-for-Python compatibility library](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).

# CircuitPython Microcontroller Wiring - I2C
You can easily wire this breakout to a microcontroller running CircuitPython. We will be using a Metro M0 Express.

- Connect&nbsp; **Vin** &nbsp;to the power supply, 3-5V is fine
- Connect&nbsp; **GND&nbsp;** to common power/data ground
- Connect the&nbsp; **SCL** &nbsp;pin to the I2C clock&nbsp; **SCL** &nbsp;pin on your Feather or Metro M0 (on&nbsp;a Gemma M0 this would be&nbsp; **Pad #2/ A1** )
- Connect the&nbsp; **SDA** &nbsp;pin to the I2C data&nbsp; **SDA&nbsp;** pin on your Feather or Metro M0 (on a Gemma M0 this would be&nbsp; **Pad #0/A2** )

![light_AS7262_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/052/596/medium640/light_AS7262_bb.png?1533704298)

# CircuitPython Microcontroller Wiring - UART

Here's the wiring to use for UART:

- **Feather 3V** to **board VIN**
- **Feather GND** to **board GND**
- **Feather RX** to **board RX** \*
- **Feather TX** to **board TX** \*

![light_feather_fritz.png](https://cdn-learn.adafruit.com/assets/assets/000/090/666/medium640/light_feather_fritz.png?1587776116)

\* Yep, TX to TX and RX to RX, that appears to be the way the AS726x has named things.

Warning: 

# Python Computer Wiring - I2C
Since there's&nbsp;_dozens_&nbsp;of Linux computers/boards you can use we will show wiring for Raspberry Pi. For other platforms,&nbsp;[please visit the guide for CircuitPython on Linux to see whether your platform is supported](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).&nbsp;

Here's the Raspberry Pi wired with I2C:

- **Pi 3V3** to **sensor VIN**
- **Pi GND** to&nbsp; **sensor GND**
- **Pi SDA** to&nbsp; **sensor SDA**
- **Pi SCL** to&nbsp; **sensor SCL**

![light_raspi_as7262_i2c_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/058/748/medium640/light_raspi_as7262_i2c_bb.png?1533756374)

This sensor uses I2C address&nbsp; **0x49**.

# CircuitPython Installation of AS726x Library
You'll need to install the&nbsp;[Adafruit\_CircuitPython\_AS726x library](https://github.com/adafruit/Adafruit_CircuitPython_AS726x)&nbsp;library on your CircuitPython board.&nbsp;&nbsp;

First make sure you are running the&nbsp;[latest version of Adafruit CircuitPython](../../../../welcome-to-circuitpython/installing-circuitpython)&nbsp;for your board.

Next you'll need to install the necessary libraries&nbsp;to use the hardware--carefully follow the steps to find and install these libraries from&nbsp;[Adafruit's CircuitPython library bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle).&nbsp; Our introduction guide has&nbsp;[a great page on how to install the library bundle](../../../../welcome-to-circuitpython/circuitpython-libraries)&nbsp;for both express and non-express boards.

Remember for non-express boards you'll need to manually install the necessary libraries from the bundle:

- **adafruit\_as726x.mpy**
- **adafruit\_bus\_device**
- **adafruit\_register**

You can also download the&nbsp; **adafruit\_as726x.mpy** &nbsp;from&nbsp;[it's release page on Github.](https://github.com/adafruit/Adafruit_CircuitPython_AS726x/releases)

Before continuing make sure your board's lib folder or root filesystem has the&nbsp; **adafruit\_as726x.mpy,&nbsp; adafruit\_register** ,&nbsp;and **&nbsp;adafruit\_bus\_device**** &nbsp; **files and folders** &nbsp;**copied over.

Next&nbsp;[connect to the board's serial REPL&nbsp;](../../../../welcome-to-circuitpython/the-repl)so you are at the CircuitPython&nbsp; **\>\>\>** &nbsp;prompt.

# Python Installation of AS726x Library
You'll need to install the Adafruit\_Blinka library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3.&nbsp;[Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux)!

Once that's done, from your command line run the following command:

- `sudo pip3 install adafruit-circuitpython-as726x`

If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

# CircuitPython & Python Usage

To demonstrate usage we will initialize the sensor and read it's onboard temperature sensor from the board's Python REPL.

Run the following code to import the necessary modules and initialize the I2C connection with the sensor:

### I2C Initialization

For I2C, use the following to create your sensor object:

```python
import board
from adafruit_as726x import AS726x_I2C

i2c = board.I2C()
sensor = Adafruit_AS726x_I2C(i2c)
```

### UART Initialization - CircuitPython

For UART usage on a board (like a Feather) running CircuitPython, use the following to create your sensor object:

```python
import board
from adafruit_as726x import AS726x_UART

uart = board.UART()
sensor = Adafruit_AS726x_UART(uart)
```

### Usage

Now you can read the temperature property from the sensor:

```python
print('Temperature: {0}C'.format(sensor.temperature))
```

As long as you get a reasonable temperature (usually around 28 degrees C) you know your sensor is wired up correctly and working!

Below is a complete example that reads all color channels and prints them out as a graph in the REPL. Save this as **code.py** &nbsp;on your board and open the REPL to see the output.

https://github.com/adafruit/Adafruit_CircuitPython_AS726x/blob/main/examples/as726x_simpletest.py

Running the above code should something like this in your REPL:

![](https://cdn-learn.adafruit.com/assets/assets/000/052/624/medium800/light_Screenshot_%2882%29.png?1522184459)

# Adafruit AS7262 6-channel Visible Light Sensor

## Python Docs

# Adafruit AS7262 6-channel Visible Light Sensor

## Downloads

# Documents

- [AS726x Datasheet](https://cdn-learn.adafruit.com/assets/assets/000/052/623/original/AS7262_DS000486_2-00_%281%29.pdf?1522179774)
- [AS726x Arduino Driver](https://github.com/adafruit/Adafruit_AS726x)
- [AS726x CircuitPython Driver](https://github.com/adafruit/Adafruit_CircuitPython_AS726x)
- [Fritzing object in the Adafruit Fritzing Library](https://github.com/adafruit/Fritzing-Library)
- [AS7262 Breakout PCB files (EAGLE format)](https://github.com/adafruit/Adafruit-AS7262-Breakout-PCB)

&nbsp;

# Schematic

click to enlarge

![](https://cdn-learn.adafruit.com/assets/assets/000/052/620/medium800/light_schematic.png?1522179191)

# Dimensions

in inches. Click to enlarge

![](https://cdn-learn.adafruit.com/assets/assets/000/052/622/medium800/light_dimensions.png?1522179690)


## Featured Products

### Adafruit 0.96" 160x80 Color TFT Display w/ MicroSD Card Breakout

[Adafruit 0.96" 160x80 Color TFT Display w/ MicroSD Card Breakout](https://www.adafruit.com/product/3533)
Say hello to our **0.96" 160x80 Color TFT Display w/ MicroSD Card Breakout** – we think it's **T** - **F** - **T** errific! It's the size of your thumbnail, with glorious 160x80 pixel color. This very very small display is only...

In Stock
[Buy Now](https://www.adafruit.com/product/3533)
[Related Guides to the Product](https://learn.adafruit.com/products/3533/guides)

## Related Guides

- [Adafruit Mini TFT - 0.96" 160x80](https://learn.adafruit.com/adafruit-mini-tft-0-dot-96-inch-180x60-breakout.md)
- [NeoPixel Infinity Cube](https://learn.adafruit.com/neopixel-infinity-cube.md)
- [LED Neon Signs with NeoPixels](https://learn.adafruit.com/led-neon-signs-with-neopixels.md)
- [Walkmellotron: Cassette Player Mods](https://learn.adafruit.com/walkmellotron.md)
- [CircuitPython Elgato WiFi Light Controller](https://learn.adafruit.com/circuitpython-elgato-wifi-light-controller.md)
- [Reading QR Codes with the Tiny Code Reader](https://learn.adafruit.com/reading-qr-codes-with-the-tiny-code-reader.md)
- [SNES Mouse to USB HID with CircuitPython](https://learn.adafruit.com/snes-mouse-to-usb-hid-with-circuitpython.md)
- [Color Sensing Music Player](https://learn.adafruit.com/color-sensing-music-player.md)
- [Tiny Wiki for CircuitPython](https://learn.adafruit.com/tiny-wiki-for-circuitpython.md)
- [PyLeap Button Controlled NeoPixels for Circuit Playground Bluefruit](https://learn.adafruit.com/pyleap-buttons-neopixels.md)
- [Pixelfed Photo Viewer on Fruit Jam](https://learn.adafruit.com/pixelfed-photo-viewer-on-fruit-jam.md)
- [Adafruit 4-Channel ADC Breakouts](https://learn.adafruit.com/adafruit-4-channel-adc-breakouts.md)
- [Adafruit I2C QT Rotary Encoder](https://learn.adafruit.com/adafruit-i2c-qt-rotary-encoder.md)
- [Circuit Playground Express Head-Tilt Ears](https://learn.adafruit.com/circuit-playground-express-head-tilt-ears.md)
- [NeXT Computer Keyboard to USB HID with CircuitPython](https://learn.adafruit.com/next-computer-keyboard-to-usb-hid-with-circuitpython.md)
