“SKU:RB-02S161 IIC 顏色傳感器”的版本間的差異

來自ALSROBOT WiKi
跳轉(zhuǎn)至: 導(dǎo)航、 搜索
(以“ ==產(chǎn)品概述== IIC顏色傳感器使用TCS34725顏色傳感器進(jìn)行顏色識別。TCS34725是一款高性價比的RGB...”為內(nèi)容創(chuàng)建頁面)
 
?相關(guān)資料
 
(未顯示1個用戶的18個中間版本)
第1行: 第1行:
?
[[文件:02S16100.jpg|500px|縮略圖|右]]
+
[[文件:02S161000.png|500px|縮略圖|右]]
 
==產(chǎn)品概述==
 
==產(chǎn)品概述==
 
IIC顏色傳感器使用TCS34725顏色傳感器進(jìn)行顏色識別。TCS34725是一款高性價比的RGB全彩顏色識別傳感器,傳感器通過光學(xué)感應(yīng)來識別物體的表面顏色。支持紅、綠、藍(lán)(RGB)三基色,支持明光感應(yīng),可以輸出對應(yīng)的具體數(shù)值,幫助您還原顏色本真。<br/>
 
IIC顏色傳感器使用TCS34725顏色傳感器進(jìn)行顏色識別。TCS34725是一款高性價比的RGB全彩顏色識別傳感器,傳感器通過光學(xué)感應(yīng)來識別物體的表面顏色。支持紅、綠、藍(lán)(RGB)三基色,支持明光感應(yīng),可以輸出對應(yīng)的具體數(shù)值,幫助您還原顏色本真。<br/>
第6行: 第6行:
 
==產(chǎn)品參數(shù)==
 
==產(chǎn)品參數(shù)==
 
===基本參數(shù)===
 
===基本參數(shù)===
?
1.品名:IIC顏色傳感器
+
1.品名:IIC顏色傳感器<br/>
?
2.貨號:RB-02S161
+
2.貨號:RB-02S161<br/>
?
3.品牌:奧松機(jī)器人
+
3.品牌:奧松機(jī)器人<br/>
?
4.產(chǎn)地:哈爾濱
+
4.產(chǎn)地:哈爾濱<br/>
?
5.尺寸:25*40
+
5.尺寸:25*40<br/>
?
6.固定孔:M3*2
+
6.固定孔:M3*2<br/>
  
 
===電氣參數(shù)===
 
===電氣參數(shù)===
?
1.接口類型:4P防插反接口
+
1.接口類型:KF2510-4P防插反接口<br/>
?
2.信號類型:IIC通訊
+
2.信號類型:IIC通訊<br/>
?
3.指示燈:
+
3.指示燈:高亮LED<br/>
?
4.工作電壓:5V
+
4.工作電壓:5V<br/>
?
5.工作電流:100mA
+
5.工作電流:100mA<br/>
?
6.引腳定義:
+
6.引腳定義:<br/>
?
+:電源正極
+
:+:電源正極<br/>
?
-:電源負(fù)極
+
:-:電源負(fù)極<br/>
?
SDA:IIC數(shù)據(jù)端口
+
:SDA:IIC數(shù)據(jù)端口<br/>
?
SCL:IIC時鐘端口
+
:SCL:IIC時鐘端口<br/>
?
7.擴(kuò)展接口:
+
7.擴(kuò)展接口:<br/>
?
LED:兩個板載LED控制端口,懸空或高電平點(diǎn)亮,低電平熄滅
+
:LED:兩個板載LED控制端口,懸空或高電平點(diǎn)亮,低電平熄滅<br/>
?
INT:中斷引腳
+
:INT:中斷引腳<br/>
?
8.連接線:4P 傳感器連接線
+
8.連接線:4P 傳感器連接線<br/>
?
9.檢測范圍:紅、綠、藍(lán)及白光檢測
+
9.檢測范圍:紅、綠、藍(lán)及白光檢測<br/>
?
10.工作溫度:-40~85℃
+
10.工作溫度:-40 - 85℃<br/>
?
產(chǎn)品尺寸圖:
+
產(chǎn)品尺寸圖:<br/>
 
[[文件:02S16101.png|500px|縮略圖|居中]]
 
[[文件:02S16101.png|500px|縮略圖|居中]]
  
第41行: 第41行:
 
:USB 數(shù)據(jù)線
 
:USB 數(shù)據(jù)線
 
* 硬件連接
 
* 硬件連接
?
[[文件:02S16102.png|500px|縮略圖|居中]]
+
[[文件:02S161020.png|500px|縮略圖|居中]]
  
 
* 示例程序
 
* 示例程序
第89行: 第89行:
 
[[文件:02S16103.png|500px|縮略圖|居中]]
 
[[文件:02S16103.png|500px|縮略圖|居中]]
  
?
===example2_Arduino===
+
===example_Raspberry Pi===
 +
* 使用軟件
 +
:編程軟件:Python 2.7.13
 +
:操作系統(tǒng):Linux raspberrypi 4.14.50
 +
:前提:PC 端已通過 SSH 軟件登陸到 RaspberryPi 控制器
 
* 主要硬件
 
* 主要硬件
?
 
+
:Raspberry Pi 控制器
 +
:Raspberry Pi GPIO 擴(kuò)展板
 +
:16G SD 卡
 +
:5V 2.5A 電源適配器
 +
:公母頭連接線
 +
:面包板
 +
:TCS34725 顏色傳感器
 +
 
* 硬件連接
 
* 硬件連接
 +
[[文件:02S16130.png|600px|縮略圖|居中]]
  
 
* 示例程序
 
* 示例程序
 +
1.使用 FileZilla 軟件,將文件夾(TCS34725-RPi)拷貝到樹莓派中<br/>
 +
[[文件:02S16132.png|500px|縮略圖|居中]]
 +
2.進(jìn)入文件夾 TCS34725-RPi 使用命令<br/>
 +
cd TCS34725-RPi<br/>
 +
3.安裝需要用到的庫文件,安裝完成后會提示 Finished <br/>
 +
sudo python setup.py install<br/>
 +
4.打開樹莓派的 IIC<br/>
 +
sudo raspi-config<br/>
 +
選擇第五項(xiàng)<br/>
 +
[[文件:02S16133.png|600px|縮略圖|居中]]
 +
選擇I2C<br/>
 +
[[文件:02S16134.png|600px|縮略圖|居中]]
 +
使用 TAB 鍵選擇 YES,單擊回車<br/>
 +
[[文件:02S16135.png|600px|縮略圖|居中]]
 +
再次單擊回車<br/>
 +
[[文件:02S16136.png|600px|縮略圖|居中]]
 +
使用 TAB 鍵選擇 Finish,然后單擊回車,完成開啟 IIC 的配置<br/>
 +
[[文件:02S16137.png|600px|縮略圖|居中]]
 +
執(zhí)行程序:進(jìn)入程序目錄,可以使用 ls 查看代碼是否在當(dāng)前目錄下,使用下列命令執(zhí)行例程<br/>
 +
sudo python simpletest.py  <br/>
 +
[[文件:02S16138.png|600px|縮略圖|居中]]
  
?
* 程序效果
+
<pre style='color:blue'>
 +
# Simple demo of reading color data with the TCS34725 sensor.
 +
# Will read the color from the sensor and print it out along with lux and
 +
# color temperature.
 +
# Author: Tony DiCola
 +
# License: Public Domain
 +
import time
  
?
===example_Raspberry Pi===
+
# Import the TCS34725 module.
 +
import TCS34725
  
 +
 +
# Create a TCS34725 instance with default integration time (2.4ms) and gain (4x).
 +
import smbus
 +
tcs = TCS34725.TCS34725()
 +
 +
# You can also override the I2C device address and/or bus with parameters:
 +
#tcs = TCS34725.TCS34725(address=0x30, busnum=2)
 +
 +
# Or you can change the integration time and/or gain:
 +
#tcs = TCS34725.TCS34725(integration_time=TCS34725.TCS34725_INTEGRATIONTIME_700MS,
 +
#                                gain=TCS34725.TCS34725_GAIN_60X)
 +
# Possible integration time values:
 +
#  - TCS34725_INTEGRATIONTIME_2_4MS  (2.4ms, default)
 +
#  - TCS34725_INTEGRATIONTIME_24MS
 +
#  - TCS34725_INTEGRATIONTIME_50MS
 +
#  - TCS34725_INTEGRATIONTIME_101MS
 +
#  - TCS34725_INTEGRATIONTIME_154MS
 +
#  - TCS34725_INTEGRATIONTIME_700MS
 +
# Possible gain values:
 +
#  - TCS34725_GAIN_1X
 +
#  - TCS34725_GAIN_4X
 +
#  - TCS34725_GAIN_16X
 +
#  - TCS34725_GAIN_60X
 +
 +
# Disable interrupts (can enable them by passing true, see the set_interrupt_limits function too).
 +
tcs.set_interrupt(False)
 +
 +
# Read the R, G, B, C color data.
 +
r, g, b, c = tcs.get_raw_data()
 +
 +
# Calculate color temperature using utility functions.  You might also want to
 +
# check out the colormath library for much more complete/accurate color functions.
 +
color_temp = TCS34725.calculate_color_temperature(r, g, b)
 +
 +
# Calculate lux with another utility function.
 +
lux = TCS34725.calculate_lux(r, g, b)
 +
 +
# Print out the values.
 +
print('Color: red={0} green={1} blue={2} clear={3}'.format(r, g, b, c))
 +
 +
# Print out color temperature.
 +
if color_temp is None:
 +
    print('Too dark to determine color temperature!')
 +
else:
 +
    print('Color Temperature: {0} K'.format(color_temp))
 +
 +
# Print out the lux.
 +
print('Luminosity: {0} lux'.format(lux))
 +
 +
# Enable interrupts and put the chip back to low power sleep/disabled.
 +
tcs.set_interrupt(True)
 +
tcs.disable()
 +
</pre>
 +
 +
* 程序效果
 +
[[文件:02S16131.png|700px|縮略圖|居中]]
  
 
==相關(guān)資料==
 
==相關(guān)資料==
 
[[文件:erweima.png|230px|無框|右]]
 
[[文件:erweima.png|230px|無框|右]]
?
* IIC 顏色傳感器傳感器 datasheet & 示例程序
+
* IIC 顏色傳感器 datasheet & 示例程序
?
下載鏈接: <br/>
+
下載鏈接:https://pan.baidu.com/s/1KWD6B_k36E9nnPsG5onHbA 提取碼:9fxe
?
* 相關(guān)資料
+
* 產(chǎn)品購買鏈接:http://lifestyle201.com/goods-871.html
?
[ datasheet] <br/>
+

2021年12月1日 (三) 09:58的最后版本

02S161000.png

目錄

產(chǎn)品概述

IIC顏色傳感器使用TCS34725顏色傳感器進(jìn)行顏色識別。TCS34725是一款高性價比的RGB全彩顏色識別傳感器,傳感器通過光學(xué)感應(yīng)來識別物體的表面顏色。支持紅、綠、藍(lán)(RGB)三基色,支持明光感應(yīng),可以輸出對應(yīng)的具體數(shù)值,幫助您還原顏色本真。
為了提高精度,防止周邊環(huán)境干擾,我們在傳感器上添加了一個鏡頭罩,有效減少外界雜光干擾傳感器,讓顏色管理更加準(zhǔn)確。板載自帶2個高亮LED,可以讓傳感器在低環(huán)境光的情況下依然能夠正常使用,實(shí)現(xiàn)“補(bǔ)光”的功能。模塊采用I2C通信,擁有4P防插反接口,更加便利。

產(chǎn)品參數(shù)

基本參數(shù)

1.品名:IIC顏色傳感器
2.貨號:RB-02S161
3.品牌:奧松機(jī)器人
4.產(chǎn)地:哈爾濱
5.尺寸:25*40
6.固定孔:M3*2

電氣參數(shù)

1.接口類型:KF2510-4P防插反接口
2.信號類型:IIC通訊
3.指示燈:高亮LED
4.工作電壓:5V
5.工作電流:100mA
6.引腳定義:

+:電源正極
-:電源負(fù)極
SDA:IIC數(shù)據(jù)端口
SCL:IIC時鐘端口

7.擴(kuò)展接口:

LED:兩個板載LED控制端口,懸空或高電平點(diǎn)亮,低電平熄滅
INT:中斷引腳

8.連接線:4P 傳感器連接線
9.檢測范圍:紅、綠、藍(lán)及白光檢測
10.工作溫度:-40 - 85℃
產(chǎn)品尺寸圖:

02S16101.png

使用方法

example1_Arduino

  • 主要硬件
Arduino UNO 控制器
傳感器擴(kuò)展板 V5.0
IIC 顏色傳感器
USB 數(shù)據(jù)線
  • 硬件連接
02S161020.png
  • 示例程序
/* Example code for the ALS_TCS34725 breakout library */

/* Connect SCL    to analog 5
   Connect SDA    to analog 4
   Connect VDD    to 5V DC
   Connect GROUND to common ground */

#include <Wire.h>
#include "ALS_TCS34725.h"

ALS_TCS34725 tcs = ALS_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);

void setup(void) {
  Serial.begin(9600);
  
  if (tcs.begin()) {
    Serial.println("Found sensor");
  } else {
    Serial.println("No TCS34725 found");
    while (1);
  }
  }

void loop(void) {
  uint16_t r, g, b, c, colorTemp, lux;
  
  tcs.getRawData(&r, &g, &b, &c);
  colorTemp = tcs.calculateColorTemperature(r, g, b);
  lux = tcs.calculateLux(r, g, b);
  
  Serial.print("Color Temp: "); Serial.print(colorTemp, DEC); Serial.print(" K - ");
  Serial.print("Lux: "); Serial.print(lux, DEC); Serial.print(" - ");
  Serial.print("R: "); Serial.print(r, DEC); Serial.print(" ");
  Serial.print("G: "); Serial.print(g, DEC); Serial.print(" ");
  Serial.print("B: "); Serial.print(b, DEC); Serial.print(" ");
  Serial.print("C: "); Serial.print(c, DEC); Serial.print(" ");
  Serial.println(" ");
}
  • 程序效果

打開 Arduino IDE 自帶的串口監(jiān)視器,將顏色傳感器放于不同顏色的表面,可以看到串口監(jiān)視器中打印不同的數(shù)值

02S16103.png

example_Raspberry Pi

  • 使用軟件
編程軟件:Python 2.7.13
操作系統(tǒng):Linux raspberrypi 4.14.50
前提:PC 端已通過 SSH 軟件登陸到 RaspberryPi 控制器
  • 主要硬件
Raspberry Pi 控制器
Raspberry Pi GPIO 擴(kuò)展板
16G SD 卡
5V 2.5A 電源適配器
公母頭連接線
面包板
TCS34725 顏色傳感器
  • 硬件連接
02S16130.png
  • 示例程序

1.使用 FileZilla 軟件,將文件夾(TCS34725-RPi)拷貝到樹莓派中

02S16132.png

2.進(jìn)入文件夾 TCS34725-RPi 使用命令
cd TCS34725-RPi
3.安裝需要用到的庫文件,安裝完成后會提示 Finished
sudo python setup.py install
4.打開樹莓派的 IIC
sudo raspi-config
選擇第五項(xiàng)

02S16133.png

選擇I2C

02S16134.png

使用 TAB 鍵選擇 YES,單擊回車

02S16135.png

再次單擊回車

02S16136.png

使用 TAB 鍵選擇 Finish,然后單擊回車,完成開啟 IIC 的配置

02S16137.png

執(zhí)行程序:進(jìn)入程序目錄,可以使用 ls 查看代碼是否在當(dāng)前目錄下,使用下列命令執(zhí)行例程
sudo python simpletest.py

02S16138.png
# Simple demo of reading color data with the TCS34725 sensor.
# Will read the color from the sensor and print it out along with lux and
# color temperature.
# Author: Tony DiCola
# License: Public Domain
import time

# Import the TCS34725 module.
import TCS34725


# Create a TCS34725 instance with default integration time (2.4ms) and gain (4x).
import smbus
tcs = TCS34725.TCS34725()

# You can also override the I2C device address and/or bus with parameters:
#tcs = TCS34725.TCS34725(address=0x30, busnum=2)

# Or you can change the integration time and/or gain:
#tcs = TCS34725.TCS34725(integration_time=TCS34725.TCS34725_INTEGRATIONTIME_700MS,
#                                 gain=TCS34725.TCS34725_GAIN_60X)
# Possible integration time values:
#  - TCS34725_INTEGRATIONTIME_2_4MS  (2.4ms, default)
#  - TCS34725_INTEGRATIONTIME_24MS
#  - TCS34725_INTEGRATIONTIME_50MS
#  - TCS34725_INTEGRATIONTIME_101MS
#  - TCS34725_INTEGRATIONTIME_154MS
#  - TCS34725_INTEGRATIONTIME_700MS
# Possible gain values:
#  - TCS34725_GAIN_1X
#  - TCS34725_GAIN_4X
#  - TCS34725_GAIN_16X
#  - TCS34725_GAIN_60X

# Disable interrupts (can enable them by passing true, see the set_interrupt_limits function too).
tcs.set_interrupt(False)

# Read the R, G, B, C color data.
r, g, b, c = tcs.get_raw_data()

# Calculate color temperature using utility functions.  You might also want to
# check out the colormath library for much more complete/accurate color functions.
color_temp = TCS34725.calculate_color_temperature(r, g, b)

# Calculate lux with another utility function.
lux = TCS34725.calculate_lux(r, g, b)

# Print out the values.
print('Color: red={0} green={1} blue={2} clear={3}'.format(r, g, b, c))

# Print out color temperature.
if color_temp is None:
    print('Too dark to determine color temperature!')
else:
    print('Color Temperature: {0} K'.format(color_temp))

# Print out the lux.
print('Luminosity: {0} lux'.format(lux))

# Enable interrupts and put the chip back to low power sleep/disabled.
tcs.set_interrupt(True)
tcs.disable()
  • 程序效果
02S16131.png

相關(guān)資料

Erweima.png
  • IIC 顏色傳感器 datasheet & 示例程序

下載鏈接:https://pan.baidu.com/s/1KWD6B_k36E9nnPsG5onHbA 提取碼:9fxe