File tree 3 files changed +18
-5
lines changed
3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 22
22
],
23
23
"public" : true ,
24
24
"targetVersions" : {
25
- "target" : " 4.0.11 " ,
25
+ "target" : " 4.0.16 " ,
26
26
"targetId" : " microbit"
27
27
},
28
28
"supportedTargets" : [
Original file line number Diff line number Diff line change @@ -50,5 +50,6 @@ loops.everyInterval(1000, () => {
50
50
//basic.showArrow(weatherbit.directionArrowName(dir))
51
51
//serial.writeValue("rain", weatherbit.rain())
52
52
//serial.writeValue("rainRate", weatherbit.rainRate())
53
- serial . writeValue ( "wind" , weatherbit . windSpeed ( ) )
54
- } )
53
+ serial . writeValue ( "Sunlight" , weatherbit . sunlight ( ) )
54
+ basic . showNumber ( weatherbit . sunlight ( ) )
55
+ } )
Original file line number Diff line number Diff line change @@ -581,11 +581,23 @@ namespace weatherbit {
581
581
582
582
583
583
// Functions for interfacing with the soil moisture and soil temperature (aquaponics)
584
-
584
+ // but we have stolen the soil moisture ADC to read the power from a solar cell into a resistive load.
585
+
586
+ /**
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
591
+ */
592
+ //% weight=11 blockGap=8 blockId="weatherbit_sunlight" block="sunlight"
593
+ export function sunlight ( ) : number {
594
+ let light = pins . analogReadPin ( AnalogPin . P0 )
595
+ return light * light / 7084 // units of W/m^2
596
+ }
585
597
586
598
/**
587
599
* Reads the Moisture Level from the Soil Moisture Sensor.
588
- * Returns a value between 0 and 1023. 0 being dry and 1023 being wet.
600
+ * Returns a value between 0 and 1023. 0 being dry and 1023 being wet.
589
601
*/
590
602
//% weight=11 blockGap=8 blockId="weatherbit_soilMoisture" block="soil moisture"
591
603
export function soilMoisture ( ) : number {
You can’t perform that action at this time.
0 commit comments