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 {
13
13
};
14
14
stateBH1750Type stateBH1750 = stateBH1750Type::toBeInitialized;
15
15
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
18
19
19
20
private:
20
21
// ------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ void ClockWork::loopAutoBrightLogic() {
39
39
// Using legacy LDR for ambient light measurement
40
40
// Electrical circuit = voltage divider: 3.3V--LDR-->ADC<--220
41
41
// Ohm--GND
42
- uint16 adcValue = analogRead (
42
+ uint16_t adcValue = analogRead (
43
43
A0); // Read out ADC, pin TOUT = 0.0V - 1.0V = adcValue 0-1023
44
44
// Track lowest ADC value for offest correction at 0 LUX
45
45
if (adcValue < adcValue0Lux)
@@ -60,7 +60,8 @@ void ClockWork::loopAutoBrightLogic() {
60
60
// aBS=16 then ledGain should reach 100.0% at 500.0 LUX.
61
61
ledGain = (lux * (float )(G.autoBrightSlope + 1 )) / 80.0 ;
62
62
// 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 ;
64
65
if (ledGain > 100.0 )
65
66
ledGain = 100.0 ;
66
67
}
@@ -73,7 +74,11 @@ void ClockWork::loopAutoBrightLogic() {
73
74
// Initialize the I2C bus using SCL and SDA pins
74
75
// (BH1750 library doesn't do this automatically)
75
76
void ClockWork::initBH1750Logic () {
77
+ #ifdef ESP8266
76
78
Wire.begin (D4, D3);
79
+ #elif defined(ESP32)
80
+ Wire.begin (21 , 22 );
81
+ #endif
77
82
// begin returns a boolean that can be used to detect setup problems.
78
83
if (lightMeter.begin (BH1750::CONTINUOUS_HIGH_RES_MODE)) {
79
84
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 =
48
48
adafruit/RTClib@^1.11.2
49
49
knolleary/PubSubClient@^2.8.0
50
50
https://github.com/tzapu/WiFiManager# v2.0.17
51
+ claws/BH1750@^1.3.0
51
52
extra_scripts = pre:extra_scripts.py
You can’t perform that action at this time.
0 commit comments