Learn electronics, coding, and projects — step by step.

008 - MakeCode MicroBit: Brickcell Color TCS34725

George Bantique October 6, 2023 No Comments

Table of Contents

BMP280 Pressure Sensor

The BMP280 is a popular digital pressure sensor manufactured by Bosch Sensortec. It is commonly used to measure barometric pressure and temperature.

It is capable of measuring pressure ranging from 300 hPa to 1100 hPa.

While the sensor is mainly designed to measure barometric pressure, it also includes a built-in temperature sensor that provides accurate readings in degrees Celsius (°C).

The Brickcell Development Kit comes with one piece of BMP280 pressure sensor module, which can be accessed through the 0x76 I2C address.

Hardware Instruction

Let's explore how to connect the BMP280 pressure sensor to a micro:bit microcontroller and utilize MakeCode for programming.

  1. Connect the Pressure sensor GND pin to micro:bit GND pin.
  2. Connect the Pressure sensor VCC pin to micro:bit VCC pin.
  3. Connect the Pressure sensor serial data pin (SDA) to micro:bit pin 20.
  4. Connect the Pressure sensor serial clock pin (SCL) to micro:bit pin 19.

Software Instruction

Now, let's start programming the micro:bit to utilize the BMP280 pressure sensor.

  1. Login to https://makecode.microbit.org/ using your Microsoft account.
  2. Create a new project by clicking the "New Project" button. You may name it anything you want; I suggest naming it descriptively such as "pressure-bmp280-test".
  3. Click the "Extensions" block just under the "Math" block.
  4. Type https://github.com/gbantique/brickcell-pressure-bmp280/ in the search bar.
  5. Select the "brickcell-pressure-bmp280" from the search results. The "pressure bmp280" block should appear under the "Brickcell" block.
  6. Copy the code provided below.
    
    serial.setBaudRate(BaudRate.BaudRate115200)
    let pressure = 0
    let temperature = 0
    basic.forever(function () {
        pressure = Brickcell.pressure()
        temperature = Brickcell.temperature()
        serial.writeNumber(pressure)
        serial.writeString(" hpa, ")
        serial.writeNumber(temperature)
        serial.writeLine(" C.")
        basic.pause(1000)
    })
    
  7. Open a Serial Monitor such as Termite terminal app https://www.compuphase.com/software_termite.htm/ . Set the baud rate to 115200 bps.

Or you can make a copy of my created project in your MakeCode workspace.

https://makecode.microbit.org/S51130-69783-82888-53560/

Expected Result

If you carefully follow the provided instructions above, you should be able to view the measured pressure in hectoPascal (hPa) and temperature in degrees Celsius (°C) on the serial terminal every 1000 milliseconds.

×

Leave a Reply

Required fields are marked *






Related Articles: (by Categories)