Linh kiện

Cảm biến ánh sáng môi trường OPT3001

OPT3001 của TI đo ánh sáng theo lux theo cách mắt người nhìn thấy, từ 0.01 đến 83865 lux, tự đổi thang, qua I2C ở 0x44.

Tên khác: module OPT3001, CJMCU-3001, ClosedCube OPT3001, lux kế. Bộ lọc của nó chặn hồng ngoại, nên nó khớp với mắt ở nơi một quang diode thường đọc cao dưới ánh đèn dây tóc. Một màn hình nhờ nó mà giảm sáng; một nhà kính nhờ nó mà ghi số liệu.

Pins

Pin Công dụng
VCC, GND Nguồn cấp, 3 đến 5 V trên bo mạch.
SCL, SDA I2C. Bo mạch có sẵn điện trở kéo lên.
INT Ngắt ngưỡng hoặc sẵn sàng chuyển đổi, tác động mức thấp.

Thuộc tính

address, 0x44 đến 0x47. lux là ánh sáng; thanh trượt thay đổi nó.

Đọc nó trên Arduino

Với thư viện của ClosedCube, mà Mokxi đóng gói thành ClosedCube_OPT3001.h:

#include <ClosedCube_OPT3001.h>
ClosedCube_OPT3001 opt3001;

void setup() {
  Serial.begin(9600);
  opt3001.begin(0x44);
  OPT3001_Config config;
  config.rawData = 0;
  config.RangeNumber = 0b1100;
  config.ModeOfConversionOperation = 0b11;
  opt3001.writeConfig(config);
}

void loop() {
  Serial.println(opt3001.readResult().lux);
  delay(500);
}

Cách nó giao tiếp

Sixteen-bit registers: 0x00 the result, an exponent and a twelve-bit mantissa, lux = 0.01 x 2^E x R; 0x01 the configuration (range, 100 or 800 ms, the mode and the flags); 0x02 and 0x03 the limits; 0x7E 0x5449 and 0x7F 0x3001. It powers up shut down; continuous mode converts every 100 or 800 ms and sets the conversion ready flag, which reading the configuration clears.

Những gì nó không mô phỏng

Số lần lỗi và đáp ứng phổ: thanh trượt chính là giá trị đọc được.

Common mistakes

Reading the result before a conversion has finished: it reads zero until the first one, 100 or 800 ms after the mode is set.