BFree-core). Download the pre-compiled .elf
version of BFree-core, from the folder Metro M0
Express BFree Firmware at the Weather Station
repo. Then use your serial wire debugger/
programmer to flash BFree-core to the Metro M0
board, following the instructions at github.com/
TUDSSL/BFree-core/blob/main/QUICKSTART.
md. We recommend using the debugger, not the
Metro M0 bootloader, because BFree-core is still
in development, and you’ll want the debugger to
recover from a broken CircuitPython state (if it
ever happens).
3. TEST YOUR BFREE SHIELD
Attach the BFree shield on top of the Metro M0
(Figure
A
).The pins of the shield correspond
one-to-one with the headers of the Metro.
Next, connect the Metro’s USB port to your PC.
The Metro should show up as a mountable device
in your operating system as usual.
Now we’ll verify that BFree works as intended,
using the Test Code program from the Weather
Station repo:
import time
# Setting the counter to 0 will only
# happen the very rst boot
counter = 0
# The battery-free program should
# continue counting somewhere in the
# while loop
while True:
counter += 1
print('Counter =', counter)
time.sleep(1)
This simple CircuitPython program increments
a variable counter indefinitely. In a typical solar-
powered system, the battery will deplete when
there’s no sun. At this point, the counter will be
reset to the initial value of zero. However, in the
BFree-based solar-powered system, the counter
will continue increasing from where it left off,
once the system recharges after a power outage.
To see this effect in action, upload the Test Code
to the Metro M0 board, replacing the original
main.py program pre-installed on the Metro with
this new one. Do not disconnect the Metro from
the USB port, and don’t forget to keep the BFree
shield connected on top of the Metro M0.
Now monitor the serial port, letting the code
run for several seconds. (If you’re not sure how,
check out learn.adafruit.com/welcome-to-
circuitpython/kattni-connecting-to-the-serial-
console.)
Unplug the Metro M0 from the USB port
(cutting off power) and plug it back in again. When
the Metro is plugged back in, the counter should
continue where it left off instead of resetting back
to zero. Its sustaining the computation state
despite power failures!
Figure
B
shows the serial connection
monitored by Minicom (type sudo apt install
minicom to install it) with 1-second timestamps.
You’ll see that the counter does not reset to zero
when the system is unplugged, and that there’s
a gap between Counter = 43 and Counter =
55. This is because the Metro M0 with its BFree
shield is already continuing the CircuitPython
program execution (incrementing the counter)
before the USB serial port is even completely
initialized.
Vito Kortbeek and Przemysław Pawełczak
A
B
85
make.co
M82_82-89_BatteryFreeComp_F1.indd 85M82_82-89_BatteryFreeComp_F1.indd 85 7/11/22 4:34 PM7/11/22 4:34 PM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset