Chapter 9

Using WiFi to connect to the Internet

In Chapter 6 we saw that being able to hook up our experiments to the Internet has the potential to greatly enhance our data science toolkit.  In Chapter 7 and Chapter 8 we looked to see if the functionality on board the micro:bit could connect us to the cloud, to give us access to the services available there.  Although both BLE and the micro:bit radio provide some really useful wireless functionality, we are still no closer to connecting properly to the IoT than we were several chapters ago.  It is time to look beyond the native functionality of the micro:bit.

Connecting to the IoT is relatively simple these days, and most commonly done using Wi-Fi.  In this chapter we will add Wi-Fi to our micro:bit weather station and connect it to the cloud.

Section 9.8 – Connecting to the IBM cloud:

First and foremost – check / update the firmware on your BBC micro:bit.  Its quick and easy, and best described by the lovely people at the Micro:bit Foundation in this article: how to check and update firmware on a micro:bit.

This is necessary to ensure the micro:bit can connect to an IoT platform.  There are a number of other reasons to update the firmware – other software and hardware that requires updated firmware to work properly.  It is always good practise to ensure you are running the most recent version of the firmware.

In Chapter 9 we write some code to share data with the IoT platform (IBM).

The full code listing is shown below (remember to change your details accordingly):

Updating Firmware on the CW01

The CW01 is the xChip we use in this chapter to provide Wi-Fi capabilities, and you may need to update the firmware on yours:
  • IF you got your CW01 as part of the XK05 kit then you are fine – it comes pre-flashed with the right firmware.
  • BUT – if you bought it loose or it came in another, non-micro:bit kit, then you will need to update it.
To update the CW01 you need an interface – an IP01 or IP02.  If you bought a kit that includes the CW01 (not the XK05 kit, but any other kit) then it will have come with an IP01 or IP02.  If you bought the CW01 by itself you may need to purchase an IP01 / IP02 (unless you already have one).
With a CW01 and an IP01 / IP02, do the following to update the firmware:
  1. Download the XinaBox Uploader application.  This is used to flash a range of pre-compiled code bases onto the CW01.
  2. Start Uploader.
  3. Connect you CW01 to your IP01/02 and plug it into a USB port on your computer.
  4. Uploader should auto-detect the CW01… if not try removing the CW01 and plugging it in again.  Perservere.
  5. From the list of software options select AT Instruction Set.
  6. Click Flash.  Wait a bit.  Sometimes the app will ‘hang’ on the provisioning stage – at this point the correct firmware HAS flashed onto your CW01, so you can remove it and continue with the chapter.

To check if you have correctly flashed the CW01:  Connect the CW01 + IP01/02 to your computer then open up a terminal app (I use Arduino IDE).  Send the String “AT” to the CW01 and it should respond with “OK”.

You are welcome to get in touch if you have any questions on this 🙂