The micro:bit is the BBC’s modern day attempt to repeat the success of the original ‘BBC Micro‘ – a series of microcomputers and peripherals that were developed in the early 80’s as part of the BBC Computer Literacy Project, and could be found in the majority of British schools at the time. A lot has changed in 25 years, and the current device reflects this – it is 18 times faster, 70 times smaller, and costs only £12.99 – almost 20x cheaper than the original. Furthermore, every year 7 student in the UK is being provided with their own micro:bit for free, which is backed up by a comprehensive set of learning resources.

The device itself is a credit card-sized programmable computer. It features an accelerometer, compass, bluetooth capability, 2 programmable buttons, an array of 25 LEDs that can be used to display basic graphics or messages, and a series of digital/analogue input/output pins for connecting peripherals. There is also a micro USB port for providing power and uploading software, as well as a battery connector, enabling the device to be used portably.

microbit2

The low cost, wireless capability, and portability of the micro:bit makes it well suited for internet of things (IoT) projects. With respect to the Enhance project, we are interested in whether it could be used to measure and/or provide feedback relating to behaviours and energy use. One idea is to use it to detect when a window is opened/closed and log the temperature of the room, as well as the temperature of the person opening/closing the window. In this case the on-board accelerometer and compass should be sufficient for detecting movement of the window, however, the micro:bit does not have a built in temperature sensor. To address this, we decided to try and hook the micro:bit up to an MLX90614 infra red thermometer – a low cost sensor, which is able to collect fast, high precision, non-contact temperature measurements.

The MLX90614 uses I2C to communicate with a host device. Luckily the micro:bit also has I2C capability! The two connections that are required to communicate using I2C are SCL (serial clock line) and SDA (serial data line), which can be found on micro:bit pins 19 and 20 respectively. The four pins on the MLX90614 should therefore be connected as follows:Screen Shot 2016-08-24 at 15.36.48

We couldn’t find any existing code for interfacing the micro:bit with the MLX90614, so (with a little help from this great I2C tutorial) we wrote a library with some basic functions for getting temperature measurements from the sensor. The library and example code can be downloaded from GitHub. The video below shows the tempSample example, where pressing button A on the micro:bit instructs it to get the temperature from the IR sensor and display it on the LED screen. We look forward to experimenting with some more imaginative uses for the sensor. Watch this space!….

 

 

Temperature sensing with the BBC micro:bit and MLX90614
Tagged on:         
avatar