MonkMakes CO2 Sensor for micro:bit
£99.95 ex VAT
This board provides a sensor for CO2, temperature and Relative Humidity measurements to a BBC micro:bit.
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.
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.
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.
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.
Note: 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.
Wire-up the board to your micro:bit then flash the following program onto your micro:bit.
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.
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().