Using a BMP280 with the BBC Microbit V2 and Zephyr OS

I wanted to continue my investigation of the Microbit V2 and Zephyr by adding an external I2C device. The BMP280 module I chose is able to report back temperature and atmospheric pressure. I thought it would be nice to combine this with the earlier ST7789 example to produce a live reading of temperature and pressure on the display. This required a slight modification to the ST7789 setup as it is not possible to use both I2C1 and SPI1 in the same NRF52833 (microbit) project. This was easily fixed as the NRF52833 has SPI interfaces 0 to 2. I chose SPI1 which led me to write the following app.overlay file:

&spi2 {
 compatible = "nordic,nrf-spi";
 status = "okay";
 sck-pin = <17>;
 mosi-pin = <13>;
 /* Redirecting MISO to a pin that is not connected on the microbit v2 board */
 miso-pin = <27>;
 clock-frequency = <1000000>;
};
&i2c1 {
	compatible = "nordic,nrf-twim";
	status = "okay";
	sda-pin = < 0x20 >; // P1.0 = pin reference 32+0 = I2c_EXT_SDA
	scl-pin = < 0x1a >; // P0.26 = pin reference 0x1a = I2C_EXT_SCL
};

Code is available over here on github.

Environmental sensing using the STM32G071

stm32g071_environment_assembled_board
Full size image
This project displays information about the environment on an ST7789 display. There’s a text version of the data and a simple trend graph of the dust/pollen data. The sensors used are as follows:
Pressure/Temperature: BMP280
Light : TLS2561
Dust : DM501A

The BMP280 and TLS2561 connect back to the STM32G071 over the I2C1 bus. The DM501A light sensor connects back to a GPIO pin. This pin is sampled at 1kHz. When a dust particle is detected in the sensor this pin is driven low. The program simply counts the number of milliseconds (samples) that this pin is low over a 1 minute interval and displays this figure.

Environmental information is sent back to a host PC using a UART. It is also written to the ST7789 display.

Code is available over here on github.