Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| hardware:wsks:notes-install [2021/01/07 21:55] – [Montage du capteur DHT11] yoann | hardware:wsks:notes-install [2021/02/01 21:51] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 166: | Ligne 166: | ||
| SCL -> D1 | SCL -> D1 | ||
| SDA -> D2 | SDA -> D2 | ||
| + | |||
| + | ===== Montage capteur de luminosité ===== | ||
| + | |||
| + | ^ Devkit | ||
| + | | 3V | VCC | | ||
| + | | D1 | SCL | | ||
| + | | D2 | SDA | | ||
| + | | G | GND | | ||
| + | |||
| + | |||
| + | <code c test_BH1750FVI.ino> | ||
| + | #include < | ||
| + | |||
| + | const int Light_ADDR = 0b0100011; | ||
| + | |||
| + | int tempLight = 0; | ||
| + | |||
| + | void readLight(); | ||
| + | |||
| + | void setup() { | ||
| + | | ||
| + | |||
| + | Wire.begin(); | ||
| + | |||
| + | // | ||
| + | Wire.beginTransmission(Light_ADDR); | ||
| + | Wire.write(0b00000001); | ||
| + | Wire.endTransmission(); | ||
| + | |||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | readLight(); | ||
| + | delay(5000); | ||
| + | } | ||
| + | |||
| + | void readLight(){ | ||
| + | // reset | ||
| + | Wire.beginTransmission(Light_ADDR); | ||
| + | Wire.write(0b00000111); | ||
| + | Wire.endTransmission(); | ||
| + | |||
| + | Wire.beginTransmission(Light_ADDR); | ||
| + | Wire.write(0b00100000); | ||
| + | Wire.endTransmission(); | ||
| + | // typical read delay 120ms | ||
| + | delay(120); | ||
| + | Wire.requestFrom(Light_ADDR, | ||
| + | for (tempLight = 0; Wire.available() >= 1; ) { | ||
| + | char c = Wire.read(); | ||
| + | tempLight = (tempLight << 8) + (c & 0xFF); | ||
| + | } | ||
| + | tempLight = tempLight / 1.2; | ||
| + | Serial.print(" | ||
| + | Serial.println(tempLight); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Montage de l' | ||
| + | |||
| + | ^ DevKit | ||
| + | | 3V | Vcc | | ||
| + | | G | GND | | ||
| + | | D1 | SCL | | ||
| + | | D2 | SDA | | ||
| + | |||
| ===== Références ===== | ===== Références ===== | ||