Instructions
Table Of Contents
- Introduction
- Parts
- Using Alligator Clips
- Solar Board Reference
- Project 1 – Sun Finder
- Project 2 – Garden Light
- Project 3 – Self Charging Cooling Fan
- The BBC micro:bit
- Getting Code to Run on the micro:bit
- Project 4 – Adding an Energy Meter
- Project 5 – Energy Logger
- Connecting Up
- Code for the Energy Logger (MakeCode)
- How it works
- Connecting to Your PC
- Pairing Your micro:bit With MakeCode
- Showing the Device Console Graph
- Capturing Data From a Charge and Discharge Cycle
- Downloading Data
- Getting Data into a Spreadsheet Program
- Analysing the Data
- Graphing the Data
- Results
- Understanding the Data
- Understanding Duty Cycle
- How the Solar Store Works
- Project 6 – Intelligent Cooling Fan
- Troubleshooting
- About the Author
- Learning
- Monk Makes Kits
if fan_needed():
fan_on()
elif fan_not_needed():
fan_off()
print(stored, temp)
sleep(1000)
Adding Time Estimation
In project 5, you also calculated how long it takes your system to charge up to top of
charge, and discharge down to bottom of charge. These times significantly affect
the duty cycle of the system and will limit how long and how often you can use the
fan, based on your specific lighting conditions.
The MicroPython code below adds a time estimator based on these numbers, and
this will display a number on the screen indicating how many seconds of fan-time
are possible with the current charge.
The new/modified lines are marked in bold. This is program p6-estimator.py.
from microbit import *
TOC = 818 # c
BOC = 220
CHARGED = TOC/2
DISCHARGED = BOC
DISCHARGE_TIME = 250
RATE = (BOC - TOC) / DISCHARGE_TIME # m
HOT = 23
COLD = 20
override = False
temp = 0
def remaining(v):
return DISCHARGE_TIME - (v - TOC)/RATE
FONT = ( # WhaleySans font, 2x5 digits only
("99","99","99","99","99"),
("09","09","09","09","09"),
("99","09","99","90","99"),
("99","09","99","09","99"),
("90","90","99","09","09"),
("99","90","99","09","99"),
("99","90","99","99","99"),
Page 34