商品簡介 |
我們有一個漂亮的封閉式 I2C 接口溫度和濕度感測器。 該感測器包含一個 DS18B20 溫度感測器和一個電容式濕度感測器。 內部的一個小型微控制器進行讀數,並提供一個簡單的 I2C 接口來讀取完成和校準的輸出資料。 特別好的是該感測器採用帶有安裝支架的堅固外殼,這使其優於普通的 PCB 安裝感測器。
與 SHT PCB-breakout 感測器相比,該感測器在感應可能有風、雨、殭屍等的地方做得更好,而且 i2c 接口更容易與微型計算機連接,可以 不要做 DHT 感測器的微妙計時。
只需將紅線連接到 5V 電源,將黑線連接到地,將黃線連接到 i2c 資料引腳,將白線連接到 i2c 時鐘引腳。 您無法更改 i2c 地址,因此每個 i2c 總線只有一個感測器。 使用需要兩個~10Kohm的上拉電阻,從SDA和SCL線連接到電源線,不包括上拉電阻!
文件下載 |
如何查詢I2C位址 |
STEP 1. 將欲查詢的模組連接至Arduino UNO(附圖為腳位參考,實際請比對商品標示接線)
STEP 2. 開啟Arduino IDE並新增檔案
STEP 3. 貼入教學下方的範例文件,並上傳到Arduino UNO,即會開始掃描I2C位址
STEP 4. 開啟序列埠監控視窗,即可取得I2C位址
/ ---------------------------------------------------------------- / | |
// Arduino I2C Scanner | |
// Re-writed by Arbi Abdul Jabbaar | |
// Using Arduino IDE 1.8.7 | |
// Using GY-87 module for the target | |
// Tested on 10 September 2019 | |
// This sketch tests the standard 7-bit addresses | |
// Devices with higher bit address might not be seen properly. | |
/ ---------------------------------------------------------------- / | |
#include |
|
void setup() | |
{ | |
Wire.begin(); // Wire communication begin | |
Serial.begin(9600); // The baudrate of Serial monitor is set in 9600 | |
while (!Serial); // Waiting for Serial Monitor | |
Serial.println("\nI2C Scanner"); | |
} | |
void loop() | |
{ | |
byte error, address; //variable for error and I2C address | |
int nDevices; | |
Serial.println("Scanning..."); | |
nDevices = 0; | |
for (address = 1; address < 127; address++ ) | |
{ | |
// The i2c_scanner uses the return value of | |
// the Write.endTransmisstion to see if | |
// a device did acknowledge to the address. | |
Wire.beginTransmission(address); | |
error = Wire.endTransmission(); | |
if (error == 0) | |
{ | |
Serial.print("I2C device found at address 0x"); | |
if (address < 16) | |
Serial.print("0"); | |
Serial.print(address, HEX); | |
Serial.println(" !"); | |
nDevices++; | |
} | |
else if (error == 4) | |
{ | |
Serial.print("Unknown error at address 0x"); | |
if (address < 16) | |
Serial.print("0"); | |
Serial.println(address, HEX); | |
} | |
} | |
if (nDevices == 0) | |
Serial.println("No I2C devices found\n"); | |
else | |
Serial.println("done\n"); | |
delay(5000); // wait 5 seconds for the next I2C scan | |
} |
出貨清單 |