File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,9 @@ class ClockWork {
1313 };
1414 stateBH1750Type stateBH1750 = stateBH1750Type::toBeInitialized;
1515 float lux = 0.0 ;
16- uint16 adcValue0Lux = 10 ; // Hier wird der niedrigste LDR-ADC Wert getrackt,
17- // für eine dynamische offset korrektur bei 0 LUX
16+ uint16_t adcValue0Lux =
17+ 10 ; // Hier wird der niedrigste LDR-ADC Wert getrackt,
18+ // für eine dynamische offset korrektur bei 0 LUX
1819
1920private:
2021 // ------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ void ClockWork::loopAutoBrightLogic() {
3939 // Using legacy LDR for ambient light measurement
4040 // Electrical circuit = voltage divider: 3.3V--LDR-->ADC<--220
4141 // Ohm--GND
42- uint16 adcValue = analogRead (
42+ uint16_t adcValue = analogRead (
4343 A0); // Read out ADC, pin TOUT = 0.0V - 1.0V = adcValue 0-1023
4444 // Track lowest ADC value for offest correction at 0 LUX
4545 if (adcValue < adcValue0Lux)
@@ -60,7 +60,8 @@ void ClockWork::loopAutoBrightLogic() {
6060 // aBS=16 then ledGain should reach 100.0% at 500.0 LUX.
6161 ledGain = (lux * (float )(G.autoBrightSlope + 1 )) / 80.0 ;
6262 // Add autoBrightOffset 0-255
63- ledGain += ((uint16)100 * (uint16)G.autoBrightOffset ) / (uint16)255 ;
63+ ledGain +=
64+ ((uint16_t )100 * (uint16_t )G.autoBrightOffset ) / (uint16_t )255 ;
6465 if (ledGain > 100.0 )
6566 ledGain = 100.0 ;
6667 }
@@ -73,7 +74,11 @@ void ClockWork::loopAutoBrightLogic() {
7374// Initialize the I2C bus using SCL and SDA pins
7475// (BH1750 library doesn't do this automatically)
7576void ClockWork::initBH1750Logic () {
77+ #ifdef ESP8266
7678 Wire.begin (D4, D3);
79+ #elif defined(ESP32)
80+ Wire.begin (21 , 22 );
81+ #endif
7782 // begin returns a boolean that can be used to detect setup problems.
7883 if (lightMeter.begin (BH1750::CONTINUOUS_HIGH_RES_MODE)) {
7984 Serial.println (" BH1750 initialized. Using this sensor for ambient "
Original file line number Diff line number Diff line change @@ -48,4 +48,5 @@ lib_deps =
4848 adafruit/RTClib@^1.11.2
4949 knolleary/PubSubClient@^2.8.0
5050 https://github.com/tzapu/WiFiManager# v2.0.17
51+ claws/BH1750@^1.3.0
5152extra_scripts = pre:extra_scripts.py
You can’t perform that action at this time.
0 commit comments