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
This graph shows the discharge cycle that you captured earlier in project 5. When
the Solar Store is fully charged it is at the Top of Charge (TOC). Turning on the fan
then consumes the energy in the Solar Store, and this powers the fan and slowly
discharges the Solar Store, as shown by the downwards diagonal line.
You already know what the readings are for the Top of Charge (TOC) and Bottom
of Charge (BOC), and you previously timed how long it took your fan to use all the
energy from TOC to BOC (discharge time). These points are labelled on the graph.
The time left until the fan goes off (which is when the charge reaches BOC) is the
difference between the time now and the total discharge time of the system.
So, if we can pump the stored charge reading from P0 into this graph and work out
the distance from now until discharge time, that will give us an estimate of how
many seconds are left before the fan will switch off.
Using a little bit of school math, we can re-arrange the equation to put x on the left
hand side. Subtract c from both sides, and divide both sides by m, and we get:
x = (y – c) / m
Realising that this is the time we have been discharging for, and that we need the
time remaining, take away now from discharge time to get the final equations used
in the Python code:
TOC = 800 # c
BOC = 40
DISCHARGE_TIME = 300 # secs from TOC to BOC (with fan)
RATE = (BOC – TOC) / DISCHARGE_TIME # m
def remaining(v):
return DISCHARGE_TIME – (v – TOC)/RATE
The final bit of code to mention is the display of this number. Because the number
of seconds of run time remaining for a full charge could be a multi digit number of
seconds, it would be quite hard to read a number that repeatedly scrolls across the
screen.
So, this code uses a special 2-digit font that will show the number 00 – 99 on the
screen. Anything more than 99 seconds is a long time, so a checkerboard image is
displayed if the number is quite big.
The stored charge and temperature are also displayed via the serial console twice
per second, so press the open serial button in the Python editor to see the
numbers, if you want to watch the algorithm working.
Page 37