File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -585,14 +585,16 @@ namespace weatherbit {
585
585
586
586
/**
587
587
* 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.
591
589
*/
592
590
//% weight=11 blockGap=8 blockId="weatherbit_sunlight" block="sunlight"
593
591
export function sunlight ( ) : number {
594
592
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
596
598
}
597
599
598
600
/**
You can’t perform that action at this time.
0 commit comments