> **Source:** Core Electronics is an Australian maker-electronics retailer and manufacturer based in Newcastle, NSW, run by a team of makers and educators. We design and manufacture our own product lines (PiicoDev, CE originals) and are official retailers for iconic maker and industrial brands including Raspberry Pi, Arduino, Adafruit, SparkFun and DFRobot. Orders ship Australia-wide from our Newcastle warehouse. Prices are in AUD and include GST. Pricing, stock and dispatch on this page are generated from the store's live catalog. Full machine-readable index: https://core-electronics.com.au/llms.txt

# Monk Makes CO2 Sensor for micro:bit

**Type:** Product page · **SKU:** CE06258 · **Brand:** [Monk Makes](https://core-electronics.com.au/brands/monk-makes-australia)
**Page:** https://core-electronics.com.au/monk-makes-co2-sensor-for-micro-bit.html ([markdown](https://core-electronics.com.au/monk-makes-co2-sensor-for-micro-bit.html.md))

## Retired product

This product is retired and no longer available for purchase. Search the catalogue for an alternative.

## How to buy

- **Search the catalogue:** `https://core-electronics.com.au/search/{query}.md` (URL-encode the query; pages 2-3 at `search/{query}/{page}.md`; `search.md?q=` also works)
- **Payment methods, purchase orders, policies and contact details:** https://core-electronics.com.au/llms.txt
## Description

This board, designed for use with the Lets Talk Science Living Space Project, provides a CO2, temperature and Relative Humidity measurements to a BBC micro:bit.

- Works with both the [micro:bit V1](https://core-electronics.com.au/micro-bit-by-bbc.html) and [micro:bit V2](https://core-electronics.com.au/micro-bit-v2-australia.html)[1](https://core-electronics.com.au/#Note1)
 
### Getting Started

Wire-up the board to your micro:bit as shown above. Then flash the following program onto your micro:bit by clicking the image to open the blocks editor and then click on Download (bottom of the web page) and copy the hex file onto your micro:bit.

![](https://www.monkmakes.com/wp-content/uploads/2018/09/microbit-screenshot-1024x947.png)

Once the program is uploaded, pressing Button A will display the CO2 level in parts per million of CO2. Pressing button B will display the temperature in degrees C and both buttons together will show the relative humidity.

If you are wondering about the big gray serial redirect block in the on start block, well this block starts serial transfer of data between the micro:bit and the CO2 sensor.

### MicroPython

You can also use the board with MicroPython as the following code example shows.

Unless you are interested in the serial protocol used, you may want to copy the code below into your program and make use of the functions get\_co2(), get\_tempC() and get\_rh().

*from microbit import \**

*uart.init(tx=pin0, rx=pin1)*

*co2 = 0*
*tempC = 0*
*rh = 0*

*def check\_incoming\_messages():*
 *global co2, tempC, rh*
 *if uart.any():*
 *response = str(uart.read(), 'UTF-8')*
 *if len(response) &lt; 8:*
 *return*
 *cmd\_letter = response\[1\]*
 *cmd\_value\_str = response\[2:8\]*
 *value = int(cmd\_value\_str)*
 *if cmd\_letter == 'Z':*
 *co2 = value*
 *elif cmd\_letter == 'T':*
 *tempC = (value - 1000) / 10.0*
 *elif cmd\_letter == 'H':*
 *rh = value / 10*
 
*def get\_co2():*
 *uart.write('Z\\r\\n')*
 *sleep(100)*
 *check\_incoming\_messages()*
 *return co2*
 
*def get\_tempC():*
 *uart.write('T\\r\\n')*
 *sleep(100)*
 *check\_incoming\_messages()*
 *return tempC*

*def get\_rh():*
 *uart.write('H\\r\\n')*
 *sleep(100)*
 *check\_incoming\_messages()*
 *return rh*
 
*\# Copy the code above into your program and then use the functions*
*\# get\_co2, get\_tempC and get\_rh in your own code*

*while True:*
 *display.scroll(get\_co2())*
 *if button\_a.was\_pressed():*
 *display.scroll('T=' + str(get\_tempC()))*
 *if button\_b.was\_pressed():*
 *display.scroll('RH=' + str(get\_rh()))*
 *sleep(500)*

### CO2 Concentrations

So, what do these readings mean?

Fresh outdoor air should give a reading of around 400. In a smallish room with a few people in it, this will rapidly rise above 1000, as people breathe out CO2. If it gets above 2000 then your air is getting dangerously unhealthy.

### Calibration

Your sensor is a sensitive scientific instrument and the readings it gives will gradually get less accurate. If you leave the sensor powered-up in a well ventilated room for 24 hours, then it will calibrate itself automatically.

You can also force calibration using the Calibrate CO2 block in the COZIR blocks category. This will set the sensor’s readings back to 400. So you should run this block only after the sensor has been in fresh air for 30 mins or so.

### Altitude Compensation

If you live somewhere high up, then you need to tell the sensor about this by putting a Set Altitude block into your On Startup block and then changing its number to your altitude above sea-level in meters.

### Battery Power

Once you have the code all working, you can disconnect the USB power and instead power the CO2 Sensor Board through the DC barrel jack using either a battery pack or a DC adapter. In both cases the power supply should be of between 5 and 9V.

**When powered by batteries in this way, the CO2 sensor will provide power back to the micro**:bit**. But make sure you have the power leads connected right between the CO2 sensor board and the micro**:bit **or your micro**:bit **could be damaged.**

1 There may be some rare cases where there are incompatibilities. BBC are working closely with accessory makers to ensure your accessories will continue to work in the same way.

## Images

- [Product image 1](https://core-electronics.com.au/media/catalog/product/c/o/co2_for_mb-1.jpg)
