Saturday, December 8, 2018

Bitty Event Monitor V1.0 now available

BittyWeb now has a new application called Bitty Event Monitor.

Monitor anything you like using your micro:bit and report significant events to this BittyWeb application and it will indicate whatever is going on with the colour and text that you choose. Suitable for a huge range of classroom and maker projects, you could monitor temperature bands, atmospheric pressure ranges or motion. If you can measure it on a micro:bit using the right code, you can report different states to Bitty Event Monitor for it to indicate visually on your screen.

Watch this video of Bitty Event Monitor working with a micro:bit running some simple temperature monitoring code:




Code for the temperature monitor is available here:

http://www.bittysoftware.com/tutorials/event_monitoring_temperature.html

Sign up to use BittyWeb today and get everyone in class involved!

https://www.bittysoftware.com/bittyweb/signup.php


Tuesday, December 4, 2018

Bitty Polyhedra V1.0 now available in BittyWeb

BittyWeb has a new application. It's called Bitty Polyhedra and it's designed to help teach and learn about 3D geometric shapes known as polyhedra. Start by loading our hex file onto your micro:bit or follow the Bitty Software tutorial to make your own. Then, in BittyWeb go into the Bitty Polyhedra application, scan for your micro:bit, select and connect to it.

From there you can explore shapes in the shape library, rotating 3D images of the selected shape on screen using your micro:bit as a controller, tilting or rotating to control the shape on screen.

Test your knowledge by taking a quiz!

Lots of fun and educational too.

Sign up for a BittyWeb account at https://www.bittysoftware.com/bittyweb/signup.php

Sunday, November 4, 2018

Changes to Bitty Controller, Bitty Blue and micro:bit blue

This week sees some important changes made to Bitty Blue, Bitty Controller and micro:bit blue. The d-pad controller in micro:bit blue has been removed and similarly, the on/off switch control has been removed from Bitty Blue. The on/off controller is now available in Bitty Controller, where logically, it belongs. Bitty Blue and micro:bit blue are both free of charge but Bitty Controller is a paid for application, albeit with a very low price. This change has been made to rationalise the functionality in each application and eliminate duplication. Commercial pressures also play a part and it is hoped that users of Bitty Software applications will not object to helping to fund the running of Bitty Software so that applications for micro:bit can continue to be offered.

Saturday, October 20, 2018

Announcing BittyWeb 1.0

It's been a year in the making so it is with great excitement that I am able to announce that BittyWeb 1.0 is now available for general use!

BittyWeb puts micro:bit educational applications in the hands of every member of class, exactly where it should be. It's web based so all you need is a suitable web browser and a computer, tablet or smartphone that has Bluetooth 4.0 or later.

There are three applications in version 1.0. Bitty Data Logger, for visualising and analysing data from micro:bit sensors and other things connected to its pins. Bitty Controller let you remote control machines and is ideal for eletronics and robotics projects. Bitty Polyhedra is not quite complete but as you'll see, it provides a fun way to let young students explore the world of 3D geometry using their micro:bit to allow three dimensional viewing of important shapes. More applications are planned too.

To use BittyWeb, your organisation needs an account and to subscribe to use the system for a given period of time, with a selected maximum number of concurrent users. Typically this would be the size of one or two classes.

Go to https://www.bittysoftware.com/bittyweb/ and sign up today!

By the way, the orientation video for V1.0 should whet your appetite!

And here's the applications promo video!

Wednesday, September 5, 2018

Coming soon - BittyWeb

Bitty Software will soon be launching a new system which will make it possible for educators to use applications like Bitty Data Logger in a completely new way and involve the entire class.

The current Bitty Software mobile applications for the BBC micro:bit have proved popular with teachers and STEM ambassadors, allowing invisible physical  phenomena to be visualised and analysed, robots to be programmed and remote controlled and coding exercises to be undertaken. But the nature of mobile applications and the policy many schools have on the use of smartphones in class has meant that the applications were only really available to the adults in the room, typically teachers. That's all set to change with BittyWeb.

BittyWeb makes the Bitty Software applications available on PCs running Windows 10 or Linux, and on Macs, Chromebooks and Android devices, in all cases from within a web browser. Yes, all you need is the Google Chrome web browser running on a PC, laptop, tablet or smartphone which has support for Bluetooth 4.0 or later and you're all set to run some of the most immersive and inclusive science, technology and coding classes ever!

To use BittyWeb, organisations will need to register for an account and subscribe to use the system for a certain duration (e.g. 12 weeks) and with support for a given maximum number of concurrent users (e.g. 30 for a whole class). Registering will result in an organisational account being created and a user account for the member of staff who will act as the system administrator for their organisation. That user can then log in and create as many standard user accounts as they are likely to need, typically one for each member of class. Standard user accounts are completely anonymous, by the way.

Version 1.0 of BittyWeb will include the Bitty Data Logger and Bitty Controller applications. Further BittyWeb applications are planned though and we're always open to ideas.

BittyWeb is currently in beta testing and if you'd like access (free of charge of course), please email bittysoftwareuk AT gmail DOT com to discuss.

Here's to the BBC micro:bit in the classroom!





Thursday, July 12, 2018

C02 monitoring with the BBC micro:bit and Bitty Data Logger

Visualising the Invisible!

I was recently contacted by a professional educator, based in Alberta, Canada called Jennifer Ferguson. Jennifer (@FergeeksonGirl ‏ on Twitter) works for a charitable, education and outreach organization called Let’s Talk Science (@LetsTalkScience) and has been using Bitty Data Logger.

The reason Jennifer made contact was to talk about her current project, Living Space, an education initiative developed with the Canadian Space Agency and to ask for some assistance. 

Living Space is concerned with monitoring key environmental conditions, including carbon dioxide (C02) levels. Jennifer wanted to be able to connect a Carbon Dioxide sensor to a micro:bit and to communicate its readings to Bitty Data Logger over Bluetooth so that the data could be visualised, logged and shared.

C02 Monitoring

C02 monitoring is widely used in all sorts of applications, many of them really important, some of them surprising. Examples include heating, ventilation and air conditioning (HVAC) systems, large scale city environmental monitoring, and aspects of food production, including monitoring of plant cultivation environments and improved food storage. It’s used in laboratory incubators for monitoring cell cultures and in healthcare for things like breath analysis applications where the sensor has to deliver results very rapidly, at around 20 measurements per second. Breath analysis data allows for monitoring conditions such as asthma. And of course, a C02 sensor being a sensor, it’s something you’d expect to find in larger scale connected systems which we might file under the umbrella term “Internet of Things (IoT)”.

Jennifer was working with an impressive sensor, the CozIR®-A  made by Scottish company GSS (Gas Sensing Solutions). Some models, such as this one can take temperature and humidity readings as well as C02 measurements.



Let’s start by getting to know the CozIR®-A sensor.

Connecting a micro:bit to the CozIR Sensor

The CozIR®-A sensor has a number of pins on its underside. The important ones are GND,  3.3V power and serial receive (RX) and transmit (TX) pins. Yes, the interface is a UART interface, which allows serial communication, one bit at a time using two of the pins, one for transmitting bits and one for receiving. To connect the CozIR®-A to a micro:bit, you make connections like this:

CozIR®-AMicro:bit
GNDGND
3V33V
TXRX
RXTX

Note how TX on the CozIR®-A is connected to RX on the micro:bit and RX to TX. This makes sense if you think about it. Data transmitted from the sensor has to be received by the micro:bit. Data transmitted by the micro:bit has to be received by the sensor.

Here’s what a micro:bit connected to a GSS CozIR®-A sensor looks like:




As you can see from the photos, I powered my micro:bit and sensor from a couple of AAA batteries. Jennifer tells me that readings start to get inaccurate when the battery gets low though, so you may prefer to power from a USB cable or other power supply.

Communicating with the CozIR®-A Sensor

The GSS CozIR®-A sensor uses a simple protocol for sending and receiving data and commands over the UART connection with a microcontroller like our micro:bit. All commands and data consist of ASCII characters only and they’re all, always terminated with carriage return, line feed characters i.e. \r\n or ASCII characters 0x0D and 0x0A.

The software guide that comes with the GSS CozIR®-A sensor is very good, and it doesn’t take long to understand the protocol and pick out those commands and responses that are required for your purposes.

There are three operating modes defined. Mode 0, Command Mode stops the sensor from making measurements. It will respond to commands when it receives them but otherwise is more or less dormant. Mode 1, Streaming Mode has the sensor making and reporting measurements every 500ms by default. Mode 2, Polling Mode makes measurements in the background but does not report them unless it receives an appropriate command from the connected micro:controller.

To request a particular mode #, the command K #\r\n must be sent. So for polling mode, the command is K 2\r\n. Note the space character between “K” and “2”.

For the best, most accurate readings, the sensor needs to be calibrated. The protocol supports calibrating the sensor in a number of ways, including in a known gas concentration, which is the recommended approach or, for those of us without a supply of a suitable reference gas, in fresh air.

Requesting fresh air calibration is achieved by sending the command G\r\n to the sensor.

Micro:bit and the CozIR®-A Sensor

Jennifer had already put together a MakeCode application which could acquire sensor readings from the CozIR®-A and display them on the micro:bit’s LED display. Her application made use of a handy package of custom blocks written by Simon Monk of Monk Makes that took care of the nitty gritty details of talking to the sensor, making her application very easy to read. Here’s the original code which she sent to me:


The application starts by configuring the micro:bit serial communications system to use pins 0 and 1 from the edge connector instead of using the USB connector for serial data. It then sits in an infinite loop, calling one of three custom block functions to obtain a C02, temperature or humidity reading, depending on the value of a variable called mode. The mode variable can be changed by pressing button A so that you can switch from C02 to temperature to humidity readings at the click of a button. Values returned by the custom block are simply displayed on the micro:bit LED grid.

The CozIR®-A Custom Blocks and Serial Communications

The CozIR®-A custom blocks which the Let Talk Science application uses, works like this: 

There are a number of functions which the application using the block will call, such as the function C02(). Functions like this one send a command to the sensor (in this case Z \r\n) by writing to the serial interface, wait for 200ms and then return the value of a variable which should now contain the latest measurement of the requested type.

    export function Co2(): number {
        serial.writeString("Z\r\n")
        basic.pause(200)
        return co2
    }

How the variable gets assigned the latest measurement, is explained by looking at the code behind another part of the CozIR custom blocks. Responses to all commands are received from within an event handler, serial.onDataReceived which is called whenever there’s data waiting to be read from the serial port as will be the case when a command has been processed. The response data gets read into a string variable, examined to see what type of response it is and then values extracted and assigned to the appropriate variable. For example, C02 readings always start with a Z then a space and then the value in parts per million (ppm). So this code checks for a response that starts with “Z” and then extracts the associated value:

response = serial.readUntil(serial.delimiters(Delimiters.NewLine))

value_str = response.substr(3, 5)
let value = parseInt(value_str)
// basic.showString(response.charAt(1))
if (response.charAt(1) == 'Z') {
    let co2_uncompensated = value
    co2 = co2_uncompensated + (altitude * 556) / 10000
}

As you can see above, it’s the variable c02 that gets returned by the Co2() function.

The Micro:bit Event System

The BBC micro:bit lets software components talk to each other using event objects. An event is just data which indicates that something in particular has happened and has an associated value or sub-type. Software components can both generate events and indicate that they’re interested in being notified about particular types of event happening elsewhere in the system, when they occur. For example, I might write some code that wants to know when either of the micro:bit’s buttons is pressed. The  software component in the micro:bit firmware that is responsible for handling the buttons, known as a driver, generates events whenever buttons get pressed. All my code has to do to receive these events is to register its interest in this type of event using a micro:bit function, and specify what I want to happen when such an event takes place. In the MakeCode programming system, we’re given ready-made blocks for this purpose such as the onButtonPressed block.


Including the onButtonPressed block in my code, simply means “please tell me if a button gets pressed and execute this code when this happens”.

Events are said to travel along a message bus which you can think of as being like a pipe that events flow along, with some software components injecting event messages into the pipe and others syphoning off copies and processing them.

Technically, events are 32-bit numbers with the first 16 acting as an event identifier (ID) which tells us what type of event it represents and the second 16 acting as a sub-type or an associated value which can be as large as 65535.

Communicating with Bitty Data Logger

Bitty Data Logger uses the micro:bit event system. One of the nice things about the event system is that software components that generate or process events do not have to be inside the micro:bit! They can be connected to the micro:bit over Bluetooth using something called the Event Service. All MakeCode applications which use the Bluetooth package, automatically have the event service built into them, meaning that events can be used for bidirectional communication between the micro:bit and the other device, connected over Bluetooth.

Various event types are used by Bitty Data Logger. These are the ones which were useful in communicating CozIR®-A sensor data:

Event ID90209030
Event NamePin SelectionData
Direction of Communicationbitty data logger to micro:bitmicro:bit to bitty data logger
PurposeLet’s bitty data logger tell the micro:bit which pins on its edge connector to read data from before transmitting it over Bluetooth.Each 9030 event has a value which combines a pin number with a value. This is how up to three different types/sources of data from an external device, connected to the micro:bit, can be communicated to bitty data logger.
Data FormatBits 0, 1 and 2 are used to select pins 0, 1 and 2 for sampling. For example: 00000010 means pin 1 should be read. 00000111 means pins 0, 1 and 2 should all be sampled. Bits 0-9 contain value. Bits 15-14 contain a pin no. So a single event value, indicates both the pin that the data comes from and the data sampled from that pin.

In MakeCode, to be notified whenever the 9020 Pin Selection event is sent over Bluetooth from Bitty Data Logger, and to set some flags indicating which of pins 0, 1 and 2 have been selected in the app, this is all we need to do:


To formulate a 9030 data event and send it to the smartphone application over Bluetooth, I usually place the code in a MakeCode function block which I can call from elsewhere, like this:


It’s that easy!

Changing the Let’s Talk Science code to work with Bitty Data Logger

To adapt Jennifer’s code to work with Bitty Data Logger, I decided to cheat a little. I decided to pretend that C02 readings were associated with pin 0, temperature readings with pin 1 and humidity readings with pin 2. Of course, all of these readings are being returned over the micro:bit’s pin 1 which is receiving serial data from the sensor’s TX pin but let’s not quibble. Pretending that the three sensor data types come from different pins, allows us to transmit and classify the three types of data separately so that Bitty Data Logger can capture and chart the data in the usual way.

Reading data from the sensor is performed in a Forever block and only happens if we’ve accepted a Bluetooth connection, indicated by a variable which gets set when a connection is established or lost, in these event handlers from the MakeCode Bluetooth package:


We then request one or more of the three sensor data types, depending on the pins that were set in the Pin Selection event.


Demonstration



Conclusion

The GSS Carbon Dioxide sensor is great for all sorts of science projects and has great relevance to a range of real world issues. As always, Bitty Data Logger allows phenomena to be visualised and analysed, which is a big help in furthering a deeper understanding.

Give it a try! Bitty Data Logger is in the Apple App Store and Google Play.

http://www.bittysoftware.com/apps/bitty_data_logger.html 

Full Solution

Link

https://makecode.microbit.org/_5hEKs3FgR7he

Editor



About GSS

We design and manufacture the fastest response, lowest power, and most robust CO2 sensors around. It’s our core solid-state technology that really sets us apart. We make special mid infrared LEDs in-house, and use this solid-state technology at the core of our sensors to help you achieve ambitious power, speed and endurance goals.  That means, no warm up time; instant on/off; very low energy (as low as 3mW); no moving parts; and a long lifetime – over 15 years in some applications.  

As for applications, our sensors have just about done it all – land, sea and space! They’ve been blasted into space, submerged beneath the seas - and most things in between! As engineers and scientists, we’ve amassed years of experience in solid-state CO2 sensor development. We did it first, and that’s all we do, so we know CO2 sensors inside out. That means there’s every chance we’ve already delivered a solution for your application. And if you’re looking to do something a bit special, we can work with you to adapt an existing product, or develop a brand new solution for your project. Just send us your brief and let’s get started!

Contact:

info@gassensing.co.uk 
Tel: +44 1236 781900  “

Sunday, June 24, 2018

Using Bitty Data Logger with a serial device connected to the micro:bit edge connector

I was asked how to connect a sensor which has a UART interface to a micro:bit and to collect and graph its data in Bitty Data Logger. To answer the question, I did some experimenting, got something working, using my PC as a source of serial data, typed in by me. Here's a video showing the experiment:

Video




Connecting the Device

I don't have one of the sensors I was asked about so I set about connecting my PC to the edge connector of the micro:bit instead, the idea being that I would type data into a serial terminal application like Putty. To make the connection, I used an adapter board which has USB at one end (for my PC) and 4 wires at the other acting as TX, RX, GND and 3.3V. I connected those wires to micro:bit edge connector pins 1, 0, GND and 3.3V respectively.

micro:bit code

My code had to do several things;
  1. map the serial interface to pins 1 and 0 instead of the usual USB port on the micro:bit
  2. read comma delimited strings from the serial interface
  3. convert each string into a number (I performed no validation in my prototype code btw)
  4. send the data over Bluetooth in the format that Bitty Data Logger would understand. See http://www.bittysoftware.com/tutorials/bitty_data_logger_makecode.html for more information on this.

Here's what the code I wrote ended up looking like, first in JavaScript:

let reading = ""
function transmitSensorData()  {
    let pin_shifted = pin << 14;
let ev = pin_shifted | analog_value;
control.raiseEvent(
    9030,
    ev
    )
}
bluetooth.onBluetoothConnected(() => {
    basic.showString("C")
})
bluetooth.onBluetoothDisconnected(() => {
    basic.showString("D")
})
let pin = 0
let analog_value = 0
basic.showString("OK")
serial.redirect(
SerialPin.P0,
SerialPin.P1,
BaudRate.BaudRate115200
)
basic.forever(() => {
    reading = serial.readUntil(serial.delimiters(Delimiters.Comma))
    pin = 1
    analog_value = parseInt(reading)
    basic.showNumber(analog_value)
    transmitSensorData()
})

And in fact, here's the code in full:

MakeCode Project