Arm Mbed OS support forum

Weather station with bme280 and stm32l432kc

I am a newbie so please bear with me…

does anyone have code for STM32l432KC working with a BME280 sensor (Adafruit)? I cannot get the hang of this!!1

Thanks in advance

Hello,

There is old page with component BME280 Combined humidity and pressure sensor | Mbed. The library seems to be usable with MbedOS 5.15 and with small change also with MbedOS6+.
Inside the library you can also see how to initialize the sensor, and how to obtain and calculate the values from sensor.

example

I can not verified that because I not have this sensor but the code is compilable (with Online compiler )also with Mbed S6+

#include "mbed.h"
#include "BME280.h"
 
BME280 sensor(I2C_SDA, I2C_SCL);
 
int main() {
    
    while(1) {
        printf("%2.2f degC, %04.2f hPa, %2.2f %%\n", sensor.getTemperature(), sensor.getPressure(), sensor.getHumidity());
        thread_sleep_for(1000);
    }
}

But I also found your old (more than year)questions and are still same. Probably no one understand what you exactly want.

So maybe try to describe it better, this situation not seems be so complicated.

  • What tool you use? - Mbed CLI / Online compiler / Mbed Studio
  • What MbedOS version you want to use? - MbedOS 2 / 5+ / 6+
  • What you achived or where you stuck with the example?

BR, Jan

OS6 version library here tested with the L432.
Currently working with On-line, and Studio IDE/Compilers (both on and off line versions).
There is example code in the BME280.h file

This is the part I use that has the pull up resistors and regulator fitted.
images
Connect up something like this:

and you should get a terminal output like this (I use Tera Term)

The serial print speed is set to 115200 in the mbed_app.json file, you can change this
to what you prefer.

1 Like

Thanks for the response. I will try to upload the attached code. Is there a good program to learn this type of programming that you all could recommend?

Robert,
Sorry for the late reply.
This may be a little advanced, although interesting.
I would suggest starting with some basic coding with LED’s and finding your way around how to control the pins of your device and gradually move onto more involved projects.
There will be plenty of examples on Mbed, check some of the ST’s examples they do have a lot here.