#include #define BH1750_ADDRESS 0x23 uint16_t lu1; int rs; void setup() { Serial.begin(115200); Wire.begin(2,0); //PinNo=SDA,SCL D4=SDA,D3=SCL に設定 ESP-12E Wire.beginTransmission(BH1750_ADDRESS); Wire.write(0x42); Wire.endTransmission(); Wire.beginTransmission(BH1750_ADDRESS); Wire.write(0x65); Wire.endTransmission(); } void loop() { uint8_t data[4],i=0; Wire.beginTransmission(BH1750_ADDRESS); Wire.write(0x10); Wire.endTransmission(); delay(120); Wire.requestFrom(BH1750_ADDRESS,2); while(Wire.available()){ data[i] = Wire.read(); i++; } lu1=(data[0] << 8) | data[1]; Serial.print(" 値=0x"); Serial.print(lu1,HEX); Serial.print(" 10進値/1.2="); Serial.print(lu1/1.2); Serial.println("(lx)"); delay(5000); }