Skip to content

Commit 8f14221

Browse files
committed
Correct sunlight calibration
1 parent 6516595 commit 8f14221

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

weatherbit.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -585,14 +585,16 @@ namespace weatherbit {
585585

586586
/**
587587
* Reads the Sunlight level from the same ADC as the soil moisture
588-
* Returns a value between 0 and 1023. 0 being dark and 1023 being blazing sunshine.
589-
* Assuming a solar cell 50mmx38mm driving into a 32 ohm load
590-
* Power = L^2 * 3^2 / (1024^2 * 0.05 * 0.038 * 32) = L^2 / 7084 W/m^2
588+
* Returns a (floating point) power value in W/m^2.
591589
*/
592590
//% weight=11 blockGap=8 blockId="weatherbit_sunlight" block="sunlight"
593591
export function sunlight(): number {
594592
let light = pins.analogReadPin(AnalogPin.P0)
595-
return light * light / 7084 // units of W/m^2
593+
/* The analogue value read is between 0 and 1023 for voltages 0 to 3.3V.
594+
* Assuming a solar cell 50mmx38mm driving into a 32 ohm load
595+
* Power = L^2 * 3.3^2 / (1023^2 * 0.05 * 0.038 * 32) = L^2 / 5843 W/m^2
596+
*/
597+
return light * light / 5843 // units of W/m^2
596598
}
597599

598600
/**

0 commit comments

Comments
 (0)