BBC Mi­cro Bit

In­tro­duc­ing an al­ter­na­tive Ar­duino-type board

The Shed - - Contents - By En­rico Miglino Pho­to­graphs: En­rico Miglino

The Mi­cro Bit board is an in­cred­i­ble and pow­er­ful mi­cro­con­troller de­vice that is the per­fect bud­get so­lu­tion to cre­ate home ex­per­i­ments for new­bies and hob­by­ists, as well as for de­vel­op­ing ad­vanced home projects. In our first project, we will look at how to make a soil hu­mid­ity sen­sor. To make the con­struc­tion easy, I have used some 3D-printed com­po­nents, how­ever th­ese are eas­ily re­placed with com­mon ma­te­ri­als.

What is it?

The BBC Mi­cro Bit is a board de­signed for ed­u­ca­tion, as well as the graph­i­cal pro­gram­ming lan­guage Blocks — some­thing sim­i­lar to the Scratch lan­guage — specif­i­cally de­signed to teach pro­gram­ming, mi­cro­con­trollers, and ro­bot­ics to chil­dren; for teach­ing STEM; and for mak­ing ro­bot­ics ex­per­i­ments.

Based on the ARM Cor­tex M0 pro­ces­sor, the Mi­cro Bit board in­cludes ev­ery­thing you need to start. To make a com­par­i­son with the pop­u­lar Ar­duino Uno, imag­ine it as a sort of all-in­clu­sive elec­tronic de­vice re­plac­ing the Ar­duino and a bunch of Ar­duino Shields. The Mi­cro Bit board con­sists of:

• a 32-bit mi­cro­con­troller CPU run­ning at 16MHz

• 16KB of RAM

• Blue­tooth Low En­ergy (LE)

• a ra­dio link to com­mu­ni­cate with ra­dio-con­trolled toys and other Mi­cro Bit boards

• 25 in­di­vid­u­ally pro­gram­mable LEDs

• two pro­gram­mable but­tons

• a triple-axis ac­celerom­e­ter and in­cli­nome­ter, mo­tion sen­sor

• a dig­i­tal com­pass

• a tem­per­a­ture sen­sor

• a light sen­sor

• a USB con­nec­tion

• 25 easy-to-access I/O pins (ana­logue, dig­i­tal, and pulse-width mod­u­la­tion [PWM]).

The BBC Mi­cro Bit is avail­able

To make a com­par­i­son with the pop­u­lar Ar­duino Uno, imag­ine it as a sort of allinclu­sive elec­tronic de­vice re­plac­ing the Ar­duino and a bunch of Ar­duino Shields

on­line from the dis­trib­u­tor Kitronik — kitronik.co.uk/mi­cro­bit.html — which ships to New Zealand. 

Tak­ing care of plants

The hu­mid­ity level is ba­sic in­for­ma­tion for any kind of plant wa­ter­ing sys­tem. Depend­ing on the kind of plants we are grow­ing, the ter­rain hu­mid­ity is a good in­di­ca­tor of the health sta­tus of the plant and a help­ful way to know when it is time to wa­ter the soil. It would not be dif­fi­cult for this sim­ple project to evolve into some­thing more com­plex, in­clud­ing checking the en­vi­ron­ment tem­per­a­ture and the day­light in­ten­sity for the best time to wa­ter the plant. By adding the con­trol of a wa­ter pump (the board can sup­port it) we can reach the next level — an au­to­mated plant wa­ter­ing sys­tem.

In this project I have used three dif­fer­ent con­tain­ers filled with soil — re­spec­tively, wet, hu­mid and dry — to set up the sen­sor read­ings in all the pos­si­ble con­di­tions. (When testing and cal­i­brat­ing I used sand in­stead of soil as it is eas­ier to set as dry, hu­mid, or wet.)

Com­po­nents

The only part re­quir­ing assem­bly is the sen­sor it­self. Be­low is a list of com­po­nents to be used to assem­ble it, as shown in the step-by-step im­ages:

• the 3D-printed soil sen­sor case — al­ter­na­tively you can use a plas­tic box and a cou­ple of wooden ke­bab skew­ers

• some electric cable

• cop­per ad­he­sive tape — this can be re­placed by alu­minium cook­ing foil

• 1mΩ re­sis­tor

• 10kΩ re­sis­tor

• three croc­o­dile clips

• a pot­ted plant that will sur­vive after the ex­per­i­ment.

The build

The first step is the cre­ation of the hu­mid­ity soil sen­sor. This build re­quires some sol­der­ing and glu­ing. The board will power the sen­sor, then the soil re­sis­tance is read, com­par­ing the value with the in­ter­nal re­sis­tance of the cir­cuit. This cir­cuit works in a sim­i­lar way to a po­ten­tiome­ter, where the vari­able re­sis­tance is read from the soil.

After as­sem­bling the sen­sor, con­nect it to the Mi­cro Bit. Plug the GND (black) cable croc­o­dile clip to the GND ring of the Mi­cro Bit. Then plug the data (yel­low) cable croc­o­dile clip to ring one of the Mi­cro Bit. Soft­ware will set up this pin as an ana­logue in­put for sig­nal reading.

If we power the cir­cuit, at­tach­ing the power (red) cable croc­o­dile clip to the 3V ring of the Mi­cro Bit, the cir­cuit works. Keep­ing the sen­sor al­ways pow­ered will drain a lot of bat­tery and we don’t re­ally need a con­tin­u­ous reading to mon­i­tor the soil hu­mid­ity level. What would be suf­fi­cient, for ex­am­ple, would be a reading ev­ery five sec­onds.

For this rea­son, we will con­nect the cir­cuit power to ring two of the board. Soft­ware will set up this pin as ‘dig­i­tal out­put’, pow­er­ing the cir­cuit only when it is needed, set­ting the pin value to 1. This sim­ple change dras­ti­cally re­duces the power con­sump­tion. 

The soft­ware

Now it is time to pro­gramme the board. One of the most in­ter­est­ing char­ac­ter­is­tics of the Mi­cro Bit is how eas­ily it is to pro­gramme. Here you could con­sider us­ing Blocks, the graph­i­cal lan­guage, but the Mi­cro Bit also sup­ports JavaScript and Python. Blocks pro­gram­ming hides be­hind the cor­re­spond­ing JavaScript source code. It is pos­si­ble to switch be­tween the two ver­sions of the same source — Blocks and JavaScript — with a one-click com­mand. This is a good way to learn the logic of a more com­plex pro­gram­ming lan­guage.

Pro­gram­ming is easy — you don’t need to in­stall any de­vel­op­ment en­vi­ron­ment; you only need the browser. The board can be programmed with a PC, tablet, iPad, etc.

To start writ­ing down the code blocks, you should go to the https://make­code. mi­cro­bit.org site. The web pro­gram­ming in­ter­face in­cludes the main area where you put the blocks, a left-side col­umn with all the avail­able stan­dard blocks or­ga­nized by fea­tures, and a sim­u­la­tor — a small graph­i­cal Mi­cro Bit de­sign that in­stantly runs the code you write to see what happens step by step.

The cor­re­spond­ing JavaScript source of this ex­per­i­ment and more de­tailed in­for­ma­tion on the soft­ware logic can be found at the GitHub re­pos­i­tory: https://al­icemir­ror.github.io/SoilMois­tureSen­sor_mi­cro­bit/, and you can find more on the Mi­cro Bit board at the of­fi­cial site: http://mi­cro­bit.org/.

Above and be­low: The two sides of the BBC Mi­cro Bit board

The steps to build­ing the soil hu­mid­ity sen­sor. First, the probes are 3D printed be­fore be­ing cov­ered with ad­he­sive cop­per tape. They are then in­serted into the cir­cuit box and hot-glued to fix them in place and keep them wa­ter-re­sis­tant. After sol­der­ing the two re­sis­tors to the sen­sor ca­bles, the box is closed and hot-glued to pre­vent any dirt and hu­mid­ity from dam­ag­ing the cir­cuit. The last step is crimp­ing the croc­o­dile clips to the sen­sor ca­bles

Be­low: Be­fore set­ting the fi­nal pro­gramme a test ver­sion is cre­ated to see the nu­meric read­ings of the sen­sor in the three ex­per­i­men­tal con­di­tions — dry, hu­mid, and wet. The ana­logue val­ues are read in th­ese three con­di­tions, then used to set up the fi­nal pro­gramme. Based on the nu­meric val­ues re­trieved by the test pro­gramme, I de­fine a range of read­ings to iden­tify the three hu­mid­ity soil con­di­tions to mon­i­tor. Depend­ing on the hu­mid­ity level of the soil the Mi­cro Bit dis­plays an up ar­row, in­di­cat­ing too much wa­ter, or a down ar­row, mean­ing it is too dry

Dry

Hu­mid

Wet

Above: The Mi­cro Bit web pro­gram­ming en­vi­ron­ment. Some de­tails on the pro­gramme blocks:(A) Block run­ning once when the pro­gramme starts. It cre­ates an ar­ray of mes­sages shown in the var­i­ous con­di­tions of the pro­gramme and sets the reading value ranges cor­re­spond­ing to the hu­mid­ity lev­els(B) Event gen­er­ated when but­ton B is pressed: shows a graph on the LED ma­trix cor­re­spond­ing to the nu­meric soil hu­mid­ity reading. Con­verts the ana­logue value to a graph(C) Event gen­er­ated when but­ton A is pressed: a short text mes­sage scrolls past depend­ing on the soil hu­mid­ity reading(D) Back­ground ac­tiv­ity: pe­ri­od­i­cally reads the sen­sor value and dis­plays an ar­row show­ing in­stantly if the hu­mid­ity level is high or low

Sim­ple schematic of the cir­cuit and wiring de­sign of the soil hu­mid­ity sen­sor

Newspapers in English

Newspapers from Australia

© PressReader. All rights reserved.