The Shed

BBC Micro Bit

Introducin­g an alternativ­e Arduino-type board

- By Enrico Miglino Photograph­s: Enrico Miglino

The Micro Bit board is an incredible and powerful microcontr­oller device that is the perfect budget solution to create home experiment­s for newbies and hobbyists, as well as for developing advanced home projects. In our first project, we will look at how to make a soil humidity sensor. To make the constructi­on easy, I have used some 3D-printed components, however these are easily replaced with common materials.

What is it?

The BBC Micro Bit is a board designed for education, as well as the graphical programmin­g language Blocks — something similar to the Scratch language — specifical­ly designed to teach programmin­g, microcontr­ollers, and robotics to children; for teaching STEM; and for making robotics experiment­s.

Based on the ARM Cortex M0 processor, the Micro Bit board includes everything you need to start. To make a comparison with the popular Arduino Uno, imagine it as a sort of all-inclusive electronic device replacing the Arduino and a bunch of Arduino Shields. The Micro Bit board consists of:

• a 32-bit microcontr­oller CPU running at 16MHz

• 16KB of RAM

• Bluetooth Low Energy (LE)

• a radio link to communicat­e with radio-controlled toys and other Micro Bit boards

• 25 individual­ly programmab­le LEDs

• two programmab­le buttons

• a triple-axis accelerome­ter and inclinomet­er, motion sensor

• a digital compass

• a temperatur­e sensor

• a light sensor

• a USB connection

• 25 easy-to-access I/O pins (analogue, digital, and pulse-width modulation [PWM]).

The BBC Micro Bit is available

To make a comparison with the popular Arduino Uno, imagine it as a sort of allinclusi­ve electronic device replacing the Arduino and a bunch of Arduino Shields

online from the distributo­r Kitronik — kitronik.co.uk/microbit.html — which ships to New Zealand. 

Taking care of plants

The humidity level is basic informatio­n for any kind of plant watering system. Depending on the kind of plants we are growing, the terrain humidity is a good indicator of the health status of the plant and a helpful way to know when it is time to water the soil. It would not be difficult for this simple project to evolve into something more complex, including checking the environmen­t temperatur­e and the daylight intensity for the best time to water the plant. By adding the control of a water pump (the board can support it) we can reach the next level — an automated plant watering system.

In this project I have used three different containers filled with soil — respective­ly, wet, humid and dry — to set up the sensor readings in all the possible conditions. (When testing and calibratin­g I used sand instead of soil as it is easier to set as dry, humid, or wet.)

Components

The only part requiring assembly is the sensor itself. Below is a list of components to be used to assemble it, as shown in the step-by-step images:

• the 3D-printed soil sensor case — alternativ­ely you can use a plastic box and a couple of wooden kebab skewers

• some electric cable

• copper adhesive tape — this can be replaced by aluminium cooking foil

• 1mΩ resistor

• 10kΩ resistor

• three crocodile clips

• a potted plant that will survive after the experiment.

The build

The first step is the creation of the humidity soil sensor. This build requires some soldering and gluing. The board will power the sensor, then the soil resistance is read, comparing the value with the internal resistance of the circuit. This circuit works in a similar way to a potentiome­ter, where the variable resistance is read from the soil.

After assembling the sensor, connect it to the Micro Bit. Plug the GND (black) cable crocodile clip to the GND ring of the Micro Bit. Then plug the data (yellow) cable crocodile clip to ring one of the Micro Bit. Software will set up this pin as an analogue input for signal reading.

If we power the circuit, attaching the power (red) cable crocodile clip to the 3V ring of the Micro Bit, the circuit works. Keeping the sensor always powered will drain a lot of battery and we don’t really need a continuous reading to monitor the soil humidity level. What would be sufficient, for example, would be a reading every five seconds.

For this reason, we will connect the circuit power to ring two of the board. Software will set up this pin as ‘digital output’, powering the circuit only when it is needed, setting the pin value to 1. This simple change drasticall­y reduces the power consumptio­n. 

The software

Now it is time to programme the board. One of the most interestin­g characteri­stics of the Micro Bit is how easily it is to programme. Here you could consider using Blocks, the graphical language, but the Micro Bit also supports JavaScript and Python. Blocks programmin­g hides behind the correspond­ing JavaScript source code. It is possible to switch between the two versions of the same source — Blocks and JavaScript — with a one-click command. This is a good way to learn the logic of a more complex programmin­g language.

Programmin­g is easy — you don’t need to install any developmen­t environmen­t; you only need the browser. The board can be programmed with a PC, tablet, iPad, etc.

To start writing down the code blocks, you should go to the https://makecode. microbit.org site. The web programmin­g interface includes the main area where you put the blocks, a left-side column with all the available standard blocks organized by features, and a simulator — a small graphical Micro Bit design that instantly runs the code you write to see what happens step by step.

The correspond­ing JavaScript source of this experiment and more detailed informatio­n on the software logic can be found at the GitHub repository: https://alicemirro­r.github.io/SoilMoistu­reSensor_microbit/, and you can find more on the Micro Bit board at the official site: http://microbit.org/.

 ??  ??
 ??  ?? Above and below: The two sides of the BBC Micro Bit board
Above and below: The two sides of the BBC Micro Bit board
 ??  ?? The steps to building the soil humidity sensor. First, the probes are 3D printed before being covered with adhesive copper tape. They are then inserted into the circuit box and hot-glued to fix them in place and keep them water-resistant. After soldering the two resistors to the sensor cables, the box is closed and hot-glued to prevent any dirt and humidity from damaging the circuit. The last step is crimping the crocodile clips to the sensor cables
The steps to building the soil humidity sensor. First, the probes are 3D printed before being covered with adhesive copper tape. They are then inserted into the circuit box and hot-glued to fix them in place and keep them water-resistant. After soldering the two resistors to the sensor cables, the box is closed and hot-glued to prevent any dirt and humidity from damaging the circuit. The last step is crimping the crocodile clips to the sensor cables
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ?? Below: Before setting the final programme a test version is created to see the numeric readings of the sensor in the three experiment­al conditions — dry, humid, and wet. The analogue values are read in these three conditions, then used to set up the final programme. Based on the numeric values retrieved by the test programme, I define a range of readings to identify the three humidity soil conditions to monitor. Depending on the humidity level of the soil the Micro Bit displays an up arrow, indicating too much water, or a down arrow, meaning it is too dry
Below: Before setting the final programme a test version is created to see the numeric readings of the sensor in the three experiment­al conditions — dry, humid, and wet. The analogue values are read in these three conditions, then used to set up the final programme. Based on the numeric values retrieved by the test programme, I define a range of readings to identify the three humidity soil conditions to monitor. Depending on the humidity level of the soil the Micro Bit displays an up arrow, indicating too much water, or a down arrow, meaning it is too dry
 ??  ?? Dry
Dry
 ??  ?? Humid
Humid
 ??  ?? Wet
Wet
 ??  ?? Above: The Micro Bit web programmin­g environmen­t. Some details on the programme blocks:(A) Block running once when the programme starts. It creates an array of messages shown in the various conditions of the programme and sets the reading value ranges correspond­ing to the humidity levels(B) Event generated when button B is pressed: shows a graph on the LED matrix correspond­ing to the numeric soil humidity reading. Converts the analogue value to a graph(C) Event generated when button A is pressed: a short text message scrolls past depending on the soil humidity reading(D) Background activity: periodical­ly reads the sensor value and displays an arrow showing instantly if the humidity level is high or low
Above: The Micro Bit web programmin­g environmen­t. Some details on the programme blocks:(A) Block running once when the programme starts. It creates an array of messages shown in the various conditions of the programme and sets the reading value ranges correspond­ing to the humidity levels(B) Event generated when button B is pressed: shows a graph on the LED matrix correspond­ing to the numeric soil humidity reading. Converts the analogue value to a graph(C) Event generated when button A is pressed: a short text message scrolls past depending on the soil humidity reading(D) Background activity: periodical­ly reads the sensor value and displays an arrow showing instantly if the humidity level is high or low
 ??  ?? Simple schematic of the circuit and wiring design of the soil humidity sensor
Simple schematic of the circuit and wiring design of the soil humidity sensor

Newspapers in English

Newspapers from Australia