stm32l432kc with bme280 code

02 Aug 2019

I am very new to microprocessors and trying to connect stm32l4 with bme280. I really don't even know where to start. andy articles, books and/or advise you can give me to start?

Thanks in advance robert

  1. include "mbed.h"

I2C i2c( D0, D1 ); Serial pc( USBTX, USBRX ); int bme280_sensor_addr = 0x77 << 1;

int main() { i2c.frequency (100000); char data[10]; char id_register_value[1] = {0xD0}; i2c.write( bme280_sensor_addr, id_register_value, 1, true ); data[1] = 0; bme280_sensor_addr, data, 1, false ); pc.printf( "ID = %2x\r\n", data[0] );

char temp_register[1] = {0xFA << 8 | 0xFB}; i2c.write( bme280_sensor_addr, temp_register, 2, true );

char temp_data[2] = {0, 0}; bme280_sensor_addr, temp_data, 2, false );

int temp_value = ((int)temp_data[1] ) | temp_data[0]; pc.printf( "Temp = %d\r\n\n", temp_value );


29 Aug 2019

Hi Robert,

There is a page about BME280 which has a sample program, we recommend that you start from that. And a note, SDI and SCK must be pulled-up by 2.2k-ohm resistors.

Thanks, Desmond

14 Sep 2019

Hi Desmond,

Thanks for the response. Where would I find the page about BME280 you are suggesting that I read?

Thanks again, Robert

15 Sep 2019

Hi Robert,

Apologize for not attaching the link address.

You can find the component documentation and the library and a hello world sample here.

Hope this helps.

Regards, Desmond

You need to log in to post a reply