CO2 Detector with Lime

GSS adds I2C interface to its low power CO2 sensor

The Internet of Things (IoT) is creating many new exciting application opportunities to create smart environments where sensors monitor for changes so that the appropriate actions can be taken. The fastest growing examples of this are HVAC (Heating Ventilation and Air Conditioning), IAQ (Indoor Air Quality), smart homes and smart offices where a network of sensors monitors temperature and carbon dioxide (CO2) levels to ensure the optimal conditionals are maintained with the minimum of energy expenditure. A challenge for such systems in that the CO2 sensors need mains power to operate incurring costs for cabling and, in the case of installing in existing buildings, redecoration.


Gas Sensing Solutions (GSS) has solved this problem with its low power, LED-based sensor technology. The sensor’s power requirements are so low that wireless monitors can be built that measure CO2 levels as well as temperature and humidity with a battery life of over ten years. Being wireless means that they can be placed wherever they are required with no need for cabling or disruption and simply relocated as building usages changes


CO2 Detector with Lime

GSS CozIR-LP with I2C interface

To make the design of these monitors even easier, GSS has added an I2C interface to its very low power CO2 sensor, the CozIR®-LP. Having the widely used I2C interface now makes the integration of the sensor into a design very easy. The CozIR®-LP is the lowest power CO2 sensor available requiring only 3mW that is up to 50 times lower than typical NDIR CO2 sensors. The GSS patented LED technology also means that the solid state sensor is very robust.  This keeps maintenance costs to a minimum as the expected lifetime is greater than 15 years making them the perfect choice for fit and forget applications that measure low (ambient) levels of CO2 from 0-1%.

“Although HVAC and IAQ are major application areas,” explained Calum MacGregor, CEO at GSS, “the lightweight, miniature size of the CozIR-LP also opens up other new possibilities for CO2 monitoring such as portable and wearable devices. The power requirements are so low that energy harvesting designs, such as solar, are now easily achievable. Here again, the new feature of an I2C interface will simplify the design process of integrating the sensor with other sensors and devices all on the I2C bus.”


GSS will be launching the new I2C-enabled CozIR®-LP on booth C5366 at the AHR Expo in Atlanta, GA, USA on the 14-16 of January 2019.


GSS technology

Most CO2 sensors work by measuring how much light is absorbed by CO2 molecules in the 4.2 to 4.4 microns range as it passes through the sample gas, which is called Non-Dispersive Infra Red (NDIR) absorption. The amount of absorption indicates how much CO2 is present. GSS developed proprietary LEDs that are specifically tuned to emit at these wavelengths. The LEDs use very little power and turn on almost instantly, enabling sensor readings to be made in a few seconds. As a result, GSS has pioneered the development of CO2 sensors that can be powered by batteries for long periods of up to ten years. Competitor sensors use IR sources that require significantly more power per measurement and also take much longer to reach a stable condition for a measurement, resulting in the need for mains power.



co2 sensors to measure co2 levels in a car

Gas Sensing Solutions investigates levels of CO2 on car journeys

Ever wondered why long car journeys make you feel tired and sleepy? Is it the boredom of endless, never changing motorways or perhaps something else? Carbon Dioxide sensor specialists, Gas Sensing Solutions, wondered if it could be a build-up of CO2 gas, because at levels of 1000 ppm and above people can become drowsy and lethargic. So they took a CO2 datalogger from their gas sensor range on a road trip to find out how CO2 levels changed throughout the journey.

co2 sensors to measure co2 levels in a car

Why can car journeys make you feel sleepy?

Dr David Moodie, Technical Manager at GSS, explained, “This follows on from our trip to Asia where we used our CO2 datalogger to measure CO2 gas levels on planes, trains and taxis. We were surprised that levels were the worst in taxis – peaking at an astonishing 10000 ppm on one journey – so we decided to check the levels on our own road trip in the UK.”

datalogger to measure co2 in a car

Measure CO2, temperature & humidity in a car

Before the datalogger took to the road, it was first used to test CO2 levels in a stationary car. This would show the impact on CO2 levels with a group of 4 people in a confined space. The engine was switched off and the windows kept closed to avoid any flow of fresh air inside the vehicle. The datalogger showed that when the passengers got inside the car, the CO2 level was 1000 ppm. It then rocketed to almost 4000 ppm in just 15 minutes. At that stage, the atmosphere inside the cabin had become extremely stuffy and unpleasant.

Graph showing CO2 levels in a stationary car

Graph showing CO2 levels in a stationary car

Next came the road trip. The first car journey involved two people travelling to the supermarket. The CO2 from their exhaled breath increased the concentration of CO2 in the car cabin to around 1400 ppm. Surprisingly, it only took about forty-five minutes to reach this level, which shows how quickly CO2 levels can rise. The datalogger was then left in the car overnight with the windows closed. The graph shows just how long it takes for the CO2 to disperse from a closed car, taking until around 9am the next day to drop down to nearer ambient levels of CO2.

graph showing CO2 levels in car recorded with a datalogger

CO2 levels recorded with a datalogger

The second car journey recorded four people travelling non-stop from Wales to Scotland. With four people, the level of CO2 shot up even faster, reaching 2000 ppm in about twenty minutes. This is the level where CO2 symptoms can start to cause loss of concentration, headaches and sleepiness for example. Fortunately, they opened the windows to bring in fresh air from outside, which reduced the CO2 to more acceptable, ambient levels within an hour.

Dr David Moodie, added, “Our real-world datalogger measurements show how CO2 levels can rapidly build up in an enclosed space with several occupants – and in a relatively short space of time too.  The results on both journeys exceeded The World Health Organisation* guideline that CO2 levels should be below 1000 ppm.” 

Datalogger details

The datalogger used in the experiment measures CO2 concentration, air pressure and temperature, along with relative humidity every few minutes. This unit was designed and built by GSS and it uses one of its low power, ambient air, CozIR®-A sensors. GSS’s unique LED technology at the heart of its sensors means that it has a very low power consumption, unlike many other CO2 sensors that need mains power. This enables battery-powered CO2 monitoring products to be created, such as this datalogger, that is able to record over a 2-week period without needing a change of battery.

co2 datalogger for measuring co2 levels

GSS CO2 datalogger with a CozIR sensor inside

Dr David Moodie, concluded, “This ability to be battery powered for long periods has opened up a whole new range of design possibilities for CO2 monitors. Now it’s possible to have handheld breath monitors with high speed sensing for people with respiratory conditions, portable leak detection instruments, handheld MAP analysers, and wireless air quality monitors for IoT applications. These are just a few examples of what is achievable, the possibilities really are endless.”

Drowsy driving facts and stats

According to a 2005 poll by the American National Sleep Foundation, 60% of adult US drivers – about 168 million people – said that they have driven a vehicle while feeling drowsy in the past year. More than one-third, (37% or 103 million people), have actually fallen asleep at the wheel. Of those who have nodded off, 13% say they have done so at least once a month. According to data from Australia, England, Finland, and other European nations, drowsy driving represents 10 to 30 percent of all crashes. More details at and

A paper on ‘Modelling CO2 concentrations in vehicle cabins’, which focusses on the build-up of CO2, can be found at:

In an article entitled ‘The Drowsy Driving Off Switch’, Air Quality Consultant Dale Walsh found that recycling the air in a car cabin causes CO2 levels to rise rapidly. In his experiment, it took an hour for a level of 2500 ppm to be reached when recycling the air with only one occupant in the car. The article is available at:

manufacturer awards

GSS shortlisted for ‘Manufacturing site of the year’ award

GSS is proud to announce that it has been selected as a finalist in the ‘Manufacturing site of the year’ category of the TechWorks Awards 2018 – the highest accolade in the UK Deep Tech Industry.

manufacturer awards

Manufacturing Site of the Year award finalist

Rachael Yates, Marketing Manager at GSS said: We are delighted to be a finalist in the manufacturing category of these prestigious awards. We continuously strive for excellence, and being recognised as a finalist reinforces the hard work of the whole team in achieving this.” 

The TechWorks Awards mark the excellence of the industry that is driving the tech economy and becoming such a strategic part of the UK’s and Ireland’s future. Finalists across the awards categories span the breadth of the industry sectors through Manufacturing, Automotive, IoT Security, Electronic Systems & Power Electronics. Being shortlisted for the awards is an accolade in itself – standards are unfalteringly high.

This year’s winners will be announced at the TechWorks Gala Dinner & Awards Ceremony at the Grange Tower Bridge Hotel, London – hosted by BBC Political Broadcaster, Strictly Come Dancing contestant and regular Comedy Show Panellist, John Sergeant.GSS finalist in Manufacturing Site of the Year awards

Data: the big trend in MAP

By Joanna Sampson: Gasworld –

Modified atmosphere packaging (MAP) is defined as ‘the packaging of a perishable product in an atmosphere which has been modified so that its composition is other than that of air’ (Hintlian and Hotchkiss, 1986).

It is one of the most updated options to traditional packaging technologies and involves removing and replacing the atmospheric gases with a predetermined gas mixture to slow down the product aging process and preserve the fresh colour, taste and nutrient content throughout an extended shelf life.

The three main gases used in this process are oxygen, carbon dioxide and nitrogen. The choice of gas or mixture of gases is very dependent upon the food product being packed.

MAP analyser technologies, which the special feature in gasworld’s Global September issue is looking at, are used for quality assurance in packaging under modified atmosphere.

But what are the key trends driving this industry at the moment?

gasworld spoke to AGC Instruments, Gas Sensing Solutions, MOCON Europe and WITT-Gasetechnik, who all said how data is being collected and stored is the most important trend they are seeing.

MAP CO2 Sensor

Modified atmosphere packaging (MAP)

Source: MOCON Europe

“There seems to be a high focus and demand for collecting and storing data. Hereby enabling producers to improve their productivity and offer improved quality as well as extended traceability to the customers,” said Morten Torngaard, Sales Manager at MOCON Europe.

Mike Loughnane, AGC Instrument’s Business Development Manager, added, “The ability to log and save data and effortlessly send this to a database is probably the most important trend. Audits are becoming increasingly rigorous and food producers must show a ‘paperwork trail’ where this is now stored in computers as opposed to the traditional paper files which are environmentally unfriendly and space prohibitive. Real time data that is easily accessed on computers is a means of monitoring operations in large food production environments.”

WITT-Gasetechnik’s Head of Marketing Alexander Kamschulte echoed, “The documentation of processes and quality assurance is becoming increasingly important. For this reason, we have already equipped our devices with export interfaces and wireless technologies such as Bluetooth or WLAN.”

“The demand for these things will continue to increase. Especially for larger food producers we expect an increasing importance of inline analysers during the packaging process. This, in conjunction with sample testing offers maximum process reliability and documents highest quality standard to the customers.”

gasworld will publish the full feature, titled ’In focus… MAP analyser technologies’, in its upcoming Global September 2018 edition.

Gas Sensing Solutions to attend Sensor Expo Japan to boost its presence in Asia

Gas Sensing Solutions (GSS), a manufacturer of NDIR Carbon Dioxide sensors and custom solutions, will be exhibiting at Sensor Expo Japan 2018 with its Japanese partner, GEC. They will be on booth S32 in East Hall of Tokyo Big Sight from 26 to 28 September 2018.

High speed CO2 sensor

Testing our High Speed CO2 Sensor

“Growing our presence in the Japanese market is a key strategy in our international growth plan,” said Lily Liu, Asia Business Development Manager at GSS. “The Japanese electronics industry is renowned for pioneering innovative solutions based on new technology, such as our award-winning CO2 sensors. These next generation sensors offer lower power, greater speed and robustness, which opens up new application areas that may not have been possible before. For example, CO2 sensors for food processing applications to help keep food fresher for longer; wearable alarms for people entering potentially high CO2 concentration areas at work, such as factories and breweries; and measuring CO2 levels in exhaled breath to monitor and help treat lung diseases.”

GSS has three families of standard products that each focus on a particular strength of its technology, i.e. low power, high speed and robustness. GSS will have demos on its stand to show these three strengths. The CozIR®-LP shows how a battery-powered CO2 sensor can be used for Demand Control Ventilation. The SprintIR®-6S demo shows how fast the sensor responds to changes in CO2 – in less than a second and right up to 100% CO2 concentrations. The ExplorIR® robustness is proven by having it working inside a ball being thrown around the stand. This robustness comes from the sensors being solid-state, enabling them to be used in harsh conditions of vibration and pressure changes such as on vehicles, aircraft or even spacecraft. As the company manufactures its sensors, it also offers a custom CO2 sensor design service.

If you would like to visit GSS at the show, please get in touch to arrange a meeting:

To find out more about the Sensor Expo Japan, visit the website:

Low power CO2 sensor demo

Gas Sensing Solutions exhibits at Sensor China Expo

Gas Sensing Solutions (GSS), a leader in CO2 sensor technology, will be exhibiting at Sensor China Expo 2018 . The company will be on Booth B004 in the Overseas Pavilion from 10 to 12 September 2018.

“China is one of our largest export markets,” said Lily Liu, Business Development Manager at GSS. “We make regular trips to China to support our partners with technical training and advice on designing solutions using our sensors. Naturally, we will also be talking to manufacturers seeking the very best in CO2 sensor technology, as our next generation LED-based sensors set new standards for low power, fast response and robustness.”

Low power CO2 sensor demo

How the CozIR-LP CO2 sensor can be used for Demand Controlled Ventilation (DCV) applications

GSS has a multi award-winning technology that is the basis for its next generation CO2 sensors. Its proprietary mid-infrared LEDs use very little power and turn on almost instantly – giving sensor readings in less than a second. As a result, GSS has pioneered the development of solid-state NDIR CO2 sensors that can be powered by batteries for up to 15 years. Alternative sensors use IR sources that require significantly more power per measurement and also take much longer to reach a stable condition for a measurement, resulting in the need for mains power. Also, being solid-state means that GSS sensors are very robust and stable enabling them to be used in harsh conditions of vibration and pressure changes, such as on vehicles, aircraft or even spacecraft.

GSS has three families of standard products that each focus on a particular strength of its technology. Therefore, designers can select the most appropriate sensor according to the needs of their specific application. The CozIR® family has particularly low power consumption and so provides a long term, low maintenance solution for battery-powered ambient air monitoring systems.

CozIR-LP low power and small CO2 sensor

CozIR-LP low power, small profile CO2 sensor

SprintIR high speed co2 sensor

SprintIR-W high speed sensor

The SprintIR® family provides high speed sensing up to 100% CO2 concentration, for when an ultra-fast measurement result is required. And the ExplorIR® brand is for measuring up to 100% CO2 levels in tough applications, such as those subjected to harsh environments, vibrations, and handling.

100% co2 sensor for tough applications

ExplorIR-W robust sensor

Within each family there are further sub-brands according to specific features, such as size, output and Temperature + Relative Humidity (RH) integration. As the company manufactures its sensors, it also offers a custom CO2 sensor design service.

GSS will have demonstrations on its stand to showcase these three strengths. The CozIR®-LP shows how a battery-powered CO2 sensor can be used for Demand Control Ventilation. The SprintIR®-6S demo shows how fast the sensor responds to changes in CO2. The ExplorIR® robustness is proven by having it working inside a ball being thrown around the stand.


If you would like to meet GSS at the show, please contact us:

Find out more about the Sensor China Expo here:

co2 sensors for refrigeration applications

Gas Sensing Solutions targets growing CO2 refrigerant market with range of low power, high sensitivity CO2 sensors

Gas Sensing Solutions (GSS), a leader in CO2 sensor technology, has announced that it is targeting the growing market of CO2 refrigeration systems with its award-winning CO2 sensors.

A century ago, CO2 was commonly used as a refrigerant, but had practically disappeared by the 1950s with the use of other gases such as HVFC, CFC and HFC.1 The air conditioning and refrigeration industry has now been urged to move to more “natural” refrigerants like CO2, with the onset of huge price increases for traditional HFCs.2 The reduction of harmful greenhouse gases is also a key consideration, as these traditional gases contribute up to four thousand times more than CO2 to global warming.3

co2 sensors for refrigeration applications

Measuring CO2 levels in refrigeration applications

Dr David Moodie, Technical Manager at GSS, said, “CO2-based water chillers, chest freezers, beverage coolers and heat pumps are increasingly being developed and commercialised, making this a very exciting new market for us as providers of innovative CO2 sensors.4 For example, CO2-based refrigeration systems are in use in a large number of Swedish supermarkets, with other countries following this trend towards a highly green refrigeration solution.”5

It is important to have CO2 sensors in this application to monitor for potential CO2 leaks. CO2 exists in the atmosphere, and background (normal) outdoor air levels are around 250-350 ppm.6 CO2 is harmless to humans, except when concentrations are four to five times greater than normal. For example, at 2000-5000 ppm, health problems such as headaches, loss of attention and slight nausea may be experienced.7 As CO2 gas is odourless and colourless, leaks could easily go unnoticed. A speedy warning of increased CO2 levels is therefore vital in ensuring people’s safety in CO2 refrigeration applications.

GSS has a range of standard CO2 sensors for refrigeration applications. The ExplorIR®-W is a particularly robust design, built with mid-infrared LED technology at its core. It’s this solid-state technology that enables the earliest warning of any possible CO2 leaks. This also provides the required long lifetime and high precision needed in leak detection applications.

Available with an extended temperature range, the ExplorIR®-W can operate right down to -25º C as required in many supermarket freezers. It is available in measurement ranges of 0-5%, 0-20% and 0-100% CO2 concentrations according to the specific application. The sensor can be adapted for special requirements, or developed into a custom CO2 sensor solution for leak detection applications.


CozIR®-A CO2 sensor used to evaluate LoRaWAN and sensor applications

A customer of Gas Sensing Solutions (GSS Ltd) based in Budapest, Hungary has built a sensor panel device using the CozIR®-A CO2 sensor.

ChipCAD has incorporated the CozIR®-A in their Micromite GPS LoRa MOTE design.  The sensor measures up to 1% CO2 concentrations, and is designed for ambient air applications.

The Micromite device is targeted at design engineers to quickly evaluate LoRaWAN and its sensor applications.

The ChipCAD article is available here: 

The full application spec can be read here:


co2 sensors for incubators

GSS sensors provide more accurate control of CO2 levels in laboratory incubators

Gas Sensing Solutions is helping to solve a challenge with laboratory incubator applications. Incubators are typically used to grow bacteria and micro-organisms, and to culture cells and tissues for research and clinical purposes. The incubator’s job is to help mimic a cell’s natural environment and provide stable conditions for safe, reliable study. Incubators typically only measure up to around 5% CO2 concentration levels, but some researchers need to have concentrations of up to 20% CO2 or higher. GSS CO2 sensors are therefore being used to monitor and control the incubator atmosphere as they can measure concentrations up 100%.

co2 sensors for incubators

Using a CO2 sensor in an incubator application

Having stable CO2 control was rated as the top feature when purchasing a CO2 incubator according to a recent survey by Lab Manager*. Stability is therefore an important requirement for a CO2 sensor in order to maintain the integrity of research and experiments in incubator applications.

GSS CO2 sensors are manufactured in-house using proprietary mid-infrared LEDs as the core technology. This solid-state platform provides the durability needed to consistently measure CO2 in the incubator environment. In addition, because the sensors use LED technology, they generate minimal heat when taking CO2 measurements. This has the added benefit of not altering the environment inside the incubator, which could potentially affect the research or experiment being carried out. By contrast, alternative CO2 sensor designs have to heat up a source of infrared every time they take a measurement, which may need to be accounted for in the incubator.

The ExplorIR® range of sensors are available in three measurement ranges of 0-5%, 0-20% and 0-100% to ensure an optimal fit with the environment being measured. Specifically, the ExplorIR®-W sensor operates at a temperature range of 0º to 50º C, but is also available with extended temperature range from -25°C to 55°C to suit diverse applications. The sensor is easy to set up with a UART interface over 4 pins. A technical datasheet with drawings is available on the GSS website.



How to monitor CO2 levels with a BBC micro:bit and a bitty data logger

Written by Martin Woolley |

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.

GSS CozIR®-A low power ambient air CO2 sensor

CozIR®-A ambient air CO2 sensor

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

Connecting a micro:bit to the CozIR®-A 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 sensor to a micro:bit, you make connections like this:

CozIR®-A Micro:bit
3V3 3V
TX RX (pin 1)
RX TX (pin 0)

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:


micro:bit connected to CozIR®-A CO2 sensor

close-up of the micro:bit connected to CozIR®-A CO2 sensor

Close-up of micro:bit with connections

GSS CozIR®-A CO2 sensor with connection

Close-up of GSS CozIR®-A CO2 sensor

Communicating with the CozIR®-A Carbon Dioxide 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 custom block written by Simon Monk of Monk Makes that took care of the nitty gritty details of talking to the sensor, which made her application very easy to read. Here’s the original code which she sent to me:

MakeCode application code for co2 monitoring

MakeCode original code

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 Block and Serial Communications

The CozIR®-A custom block 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 {



return co2



How the variable gets assigned the latest measurement, is explained by looking at another part of the custom block’s code. 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.

onButtonPressed block code

onButtonPressed block code.

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 CO2 sensor data:

Event ID 9020 9030
Event Name Pin Selection Data
Direction of Communication bitty data logger to micro:bit micro:bit to bitty data logger
Purpose Let’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 Format Bits 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:

MakeCode application code

MakeCode application code.

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:

MakeCode function block

MakeCode function block.

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 seperately 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:

Accept a Bluetooth connection

Accept a Bluetooth connection.

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

Request co2 sensor data types.

Request sensor data types.


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.


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:

Full Solution


<div style=”position:relative;height:0;padding-bottom:70%;overflow:hidden;”><iframe style=”position:absolute;top:0;left:0;width:100%;height:100%;” src=”” frameborder=”0″ sandbox=”allow-popups allow-forms allow-scripts allow-same-origin”></iframe></div>



<div style=”position:relative;height:0;padding-bottom:70%;overflow:hidden;”><iframe style=”position:absolute;top:0;left:0;width:100%;height:100%;” src=”” frameborder=”0″ sandbox=”allow-popups allow-forms allow-scripts allow-same-origin”></iframe></div>

Contact the author

Martin Woolley | Developer Relations Manager, EMEA at Bluetooth SIG