XK05 - software


Software considerations

micro:bit firmware

Did you know that your BBC micro:bit has software loaded onto it that controls how it 'behaves'?  Called 'firmware' this allows the programs we write in MakeCode or microPython to use the hardware on the micro:bit.

It is being updated all the time: the first version that the Micro:bit Foundation released in 2015 was 0234 and they were up 0253 by the end of 2019.  A lot has changed over the 4 years that micro:bits have been produced and the up-to-date firmware is a lot more stable and sophisticated.

Many modern peripherals / functionality (including but not limited to the XK05) will not run on the earliest versions of the micro:bit firmware (especially <0241).  You may need to update your firmware to connect your micro:bit to the Cloud.

It is very easy (and quite interesting if you've not done it before).  Find out how to update your firmware in this article from the micro:bit team. 

Note: roughly 25% of micro:bits will need to be updated, so yours may not.  If you'd prefer to wait and see, you will find out when flashing code onto your micro:bit (see right at the end of this page).

CW01 firmware

The CW01 is a core, and it also has pre-installed firmware loaded onto it. 

If you got your CW01 from an XK05 kit then you DO have the right firmware loaded, and you can skip to the next section.

If you are using a CW01 that did not come in an XK05 kit then it will not have the right firmware loaded onto it. It is pretty easy to update the firmware on your CW01 - you can find out how in the trouble-shooting guide.

And sorry: we could find any cool pictures of firmware ;)

Microsoft MakeCode

We've optimised the XK05 so that it is easy to program in MakeCode.  If you've used MakeCode before then you will be able to write the code you need.

For first time users of MakeCode we recommend you read the getting started guide by the experts who built it then jump back here to add the IoT element. 

To get started coding you will need to do the following:

Loading extensions

With MakeCode open and a new project started, next thing is to load up the CW01 extension.

  • Click on the Advanced tab then on Extensions
  • Type xinabox/pxt-cw01 into the box then click search
  • Select the CW01 tile as shown:

The extension will take a a few seconds to load, then you will see a new CW01 tab in the menu.

Final Preparation

You are now only four blocks away from connecting your micro:bit to the Cloud. But first:

Have you chosen an IoT platform provider? * You need 'credentials' when you  write your code - information from the IoT platform. There's info on the XK05 support materials page about selecting an IoT platform.
Are you in a Wi-Fi zone and do you have the credentials? You need to use a Wi-Fi zone that requires just an SSID and password to access and you will need to have these details at hand. Mobile phone Wi-Fi hotspots can be used. 

* Note - if you are following the curated journey for first time users, brought to you by XinaBox and ALSO AllThingsTalk, you do not need to register with an IoT provider - this step is done for you. 

Writing Code

There are separate blocks to use depending on which IoT platform you have chosen:

  1. ALSO AllThingsTalk
  2. Microsoft Azure
  3. Ubidots
  4. Any other MQTT based IoT platform

Whichever one you choose your code will look very similar to this:

In your On Start block you connect first to your Wi-Fi network and then to your IoT platform.

The four credentials you enter here are crucial and need to be spot on. Always double-check them.

 Next you are either going to send data to the IoT platform or receive data from it:

Sending data to ATT, Azure or Ubidots is very similar and the blocks will help you enter the right details depending on which platform you are using.

Receiving data is also similar. Values are always returned as a String.

There is more info in the how-to guide, which also explains all you need to know about data types and parsing strings to values.

NB: when you flash code that uses the CW01 onto your micro:bit then run it, you should see the checkerboard pattern on the micro:bit LEDs, as shown. If you do NOT see this pattern then you need to update your firmware, as described earlier in this document.

For more information about XinaBox and micro:bit: