Google Chat: zj734465502@gmail.com
+86-0755-88291180
sales01@spotpear.com
dragon_manager@163.com
services01@spotpear.com
manager01@spotpear.com
WhatsApp:13246739196
With AS7341 visible spectrum sensing IC as the core. this product can sense the visible light component values of different bands in the environment. It is also quite impressive in sensitivity and accuracy. At the same time, its volume is very small. To make a miniature spectrum analyzer, it will be a very good choice.
Pin number | PIN | Description |
1 | VCC | 3.3V/5V Power input |
2 | GND | Ground |
3 | SDA | I2C data line |
4 | SCL | I2C clock line |
5 | INT | Interrupt output pin |
6 | GPIO | input/output GPIO port |
This product uses AS7341-DLGM as the core, which is an 11-channel IC for spectrum recognition and color matching applications. The spectral response is defined at a wavelength of about 350nm to 1000nm. 6 channels can be processed in parallel by independent adcs, while the other channels can be accessed through a multiplexer. AS7341 integrates the filter into the silicon of standard CMOS through a nano-optical deposition interference filter. The technology and its package provide a built-in aperture to control the light entering the sensor array. Its control and spectral data access are realized through the serial I²C interface.
This product uses I2C communication with one data line and one clock line. There are three types of signals in the I2C bus in the process of transmitting data: START signal, STOP signal, and Response signal.
START signal: When SCL is high level, SDA jumps from high to low to start transmitting data.
STOP signal: When SCL is high level, SDA jumps from low level to high level, ending the data transmission.
Response signal: After receiving the 8bit data, the data receiving IC sends a specific low-level pulse to the data sending IC to indicate that the data has been received.
First, the host(ie, Raspberry Pi) will send a start signal, and then combine its I2C 7-bit address and write operation bits into 8-bit data and send it to the slave (ie TSL2581 sensor module), the slave will respond with a response signal after receiving it. The host sends the command register address to the slave, and then the slave receives this response signal. At this time, the master sends the value of the command register and the slave responds with a response signal. Until the host sends a STOP signal, the I2C write data operation ends
First, the host will send a START signal, and then combine its I2C 7-bit address and write operation bit into 8-bit data and send it to the slave. After receiving it, the slave will respond with a response signal, and the host will send the command register address at this time. After the slave receives the sending response signal, the host will send a START signal again, and combines its 7-bit address and read operation bit into 8-bit data and sends it to the slave. The slave sends a response after receiving the signal, then sends the value in its register to the host. And the host gives a response signal until the host sends a stop signal, and this communication ends.
The I2C device address of AS7341 is 0X39 which you can check on page 21 of the AS7341 data sheet.
This example is tested on Arduino UNO. If you use other models of Arduino, please pay attention to whether the related pins are connected correctly.
There are several different test projects on the Arduino/Waveshare_AS7341/example directory, here we give some describes and precautions.
//AS7341_EnableLED(true);// LED ON or OFF
//AS7341_ControlLed(10);//Adjust the brightness of the LED lamp
If you need to use LED fill light, just comment these two lines of code
This module does not directly connect the GPIO port by default. Therefore, during your testing, you can briefly touch the GPIO port with the 3.3v or 5V pin of the development board and then disconnect it to obtain a falling edge signal. And in your actual use, you can connect the GPIO port to the trigger source directly.
while(!AS7341_MeasureComplete()); // Jump out of this loop when GPIO receives a valid signal.
AS7341_SetInterruptPersistence(0); // Set the sensitivity of spectrum interruption
AS7341_SetSpectralThresholdChannel(4); //Set the channel to detect interrupts
This demo has been verified on NUCLEO-F103RB (chip model STM32RBT6) and OpenH743I-C (chip model STM32H743IIT6). If you need to migrate to other boards, please pay attention to the relevant configuration and Hardware connection.
AS7341 Spectral Color Sensor | XNUCLEO-F103RB |
VCC | 3.3V/5V Power input |
GND | Ground |
SDA | SDA/D14/PB9 |
SCL | SCL/D15/PB8 |
INT | D8/PA9 |
GPIO | / |
Hardware connection with OpenH743I-C
AS7341 Spectral Color Sensor | OpenH743I-C |
VCC | 3.3V/5V Power input |
GND | Ground |
SDA | PD13(I2C4 SDA) |
SCL | PD12(I2C4 SCL) |
INT | PD11 |
GPIO | / |
After downloading the demo, unzip this .7z file on your PC. The STM32 demo is located in ~/ STM32/… . You can see the two folders NUCLEO-F103RB and OpenH743I-C.
This example uses Raspberry Pi 3 Model B, provides BCM2835, WiringPi, file IO, RPI (Python) library demos.
AS7341 Spectral Color Sensor | Raspberry Pi (BCM) |
VCC | 3.3V/5V Power input |
GND | Ground |
SDA | SDA(2) |
SCL | SCL(3) |
INT | 4 |
GPIO | / |
sudo raspi-config Choose Interfacing Options -> I2C -> Yes to enable I2C interface
And then reboot the system:
sudo reboot
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.gz tar zxvf bcm2835-1.68.tar.gz cd bcm2835-1.68/ sudo ./configure && sudo make && sudo make check && sudo make install
For more details, please refer to http://www.airspayce.com/mikem/bcm2835/
sudo apt-get install wiringpi #For Pi 4, you need to update it: wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v #You will get 2.52 information if you install it correctly
Open the terminal of the Raspberry Pi, execute command to download demo codes:
sudo apt-get install p7zip-full wget https://www.waveshare.com/w/upload/b/b3/AS7341_Spectral_Color_Sensor_code.7z 7z x AS7341_Spectral_Color_Sensor_code.7z -r -o./AS7341_Spectral_Color_Sensor_code sudo chmod 777 -R AS7341_Spectral_Color_Sensor_code
cd AS7341_Spectral_Color_Sensor_code/AS7341_Spectral_Color_Sensor_code/RaspberryPi/c make clean make
Enter the following command to execute the demo:
sudo ./main data
cd cd AS7341_Spectral_Color_Sensor_code/AS7341_Spectral_Color_Sensor_code/RaspberryPi/python/examples
Enter the following command to execute the demo:
sudo python data.py
The functions of all test demos and the points that need attention have been introduced in the Arduino tutorial. When executing sudo ./main syns or python syns.py, you need to pull up the GPIO port and then pull it down to generate a falling edge signal. You can connect the GPIO pin to the high-level pin for a short time and then released to generate a falling edge signal.