Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:practical:hardware:sut:stm32:emb1b_1 [2024/04/21 08:16] – [STM_1B: Reading environmental data with a Bosch integrated sensor] ktokarzen:iot-open:practical:hardware:sut:stm32:emb1b_1 [2024/04/21 09:41] (current) – [FAQ] ktokarz
Line 2: Line 2:
 We will read environmental data using a BME 280 sensor in this scenario. It is one of the most popular sensors in weather stations. It integrates a single chip's digital thermometer, hygrometer (air humidity), and air pressure meter. In our laboratory equipment, this sensor is located inside the yellow pressure chamber, under the fan which can blow the air onto it.\\ We will read environmental data using a BME 280 sensor in this scenario. It is one of the most popular sensors in weather stations. It integrates a single chip's digital thermometer, hygrometer (air humidity), and air pressure meter. In our laboratory equipment, this sensor is located inside the yellow pressure chamber, under the fan which can blow the air onto it.\\
 The sensor communicates with the microcontroller using the I2C bus. In all our laboratory nodes, the I2C bus uses two GPIOs: a D14 (PB_9 in Nucleo numbering) pin for the SDA line, and a D15 (PB_8 in Nucleo numbering) pin for SCL. Every integrated circuit connected to the I2C bus has its own address. BME 280 is visible under the address 0x76. For the details please refer to Table 1: STM32WB55 Node Hardware Details in [[en:iot-open:practical:hardware:sut:stm32|]]\\ The sensor communicates with the microcontroller using the I2C bus. In all our laboratory nodes, the I2C bus uses two GPIOs: a D14 (PB_9 in Nucleo numbering) pin for the SDA line, and a D15 (PB_8 in Nucleo numbering) pin for SCL. Every integrated circuit connected to the I2C bus has its own address. BME 280 is visible under the address 0x76. For the details please refer to Table 1: STM32WB55 Node Hardware Details in [[en:iot-open:practical:hardware:sut:stm32|]]\\
-This scenario can be run stand-alone to read weather data in the laboratory nodes' room. Still, it is also complementary to the scenario STM_1A [[en:iot-open:practical:hardware:sut:stm32:emb1A_1|]] and may enable you to monitor the results of the fan operation that should induct changes in the air pressure.+This scenario can be run stand-alone to read weather data in the laboratory nodes' room. Still, it is also complementary to the scenario [[en:iot-open:practical:hardware:sut:stm32:emb1A_1|]] and may enable you to monitor the results of the fan operation that should induct changes in the air pressure.
  
 ===== Prerequisites ===== ===== Prerequisites =====
Line 9: Line 9:
   lib_deps = adafruit/Adafruit BME280 Library@^2.2.2   lib_deps = adafruit/Adafruit BME280 Library@^2.2.2
 </code> </code>
-To observe air pressure changes over a short time, it is necessary to implement fan PWM control as described in the [[en:iot-open:practical:hardware:sut:esp32:emb1a_1|]].\\+To observe air pressure changes over a short time, it is necessary to implement fan PWM control as described in the [[en:iot-open:practical:hardware:sut:stm32:emb1a_1|]].\\
 Sensor readings can be sent over the network or presented on one of the node's displays (e.g. LCD), so understanding how to handle at least one of the  displays is essential: Sensor readings can be sent over the network or presented on one of the node's displays (e.g. LCD), so understanding how to handle at least one of the  displays is essential:
-  * [[en:iot-open:practical:hardware:sut:esp32:emb5_1|]], +  * [[en:iot-open:practical:hardware:sut:stm32:emb5_1|]], 
-  * [[en:iot-open:practical:hardware:sut:esp32:emb6_1|]], +  * [[en:iot-open:practical:hardware:sut:stm32:emb6_1|]], 
-  * [[en:iot-open:practical:hardware:sut:esp32:emb7_1|]].+  * [[en:iot-open:practical:hardware:sut:stm32:emb7_1|]].
  
 To implement monitoring of the air pressure changes, understanding how to control a fan with PWM is necessary: To implement monitoring of the air pressure changes, understanding how to control a fan with PWM is necessary:
-  * [[en:iot-open:practical:hardware:sut:esp32:emb1a_1|]].+  * [[en:iot-open:practical:hardware:sut:stm32:emb1a_1|]].
  
 Technical documentation for the BME 280 sensor is available here: Technical documentation for the BME 280 sensor is available here:
Line 24: Line 24:
 ===== Suggested Readings and Knowledge Resources ===== ===== Suggested Readings and Knowledge Resources =====
   * [[en:iot-open:introductiontoembeddedprogramming2:cppfundamentals]]   * [[en:iot-open:introductiontoembeddedprogramming2:cppfundamentals]]
-  * [[en:iot-open:hardware2:esp32|]] +  * [[en:iot-open:hardware2:stm32|]] 
-  * [[en:iot-open:practical:hardware:sut:esp32|]]+  * [[en:iot-open:practical:hardware:sut:stm32|]]
   * [[en:iot-open:embeddedcommunicationprotocols2:twi|]]   * [[en:iot-open:embeddedcommunicationprotocols2:twi|]]
 ===== Hands-on Lab Scenario ===== ===== Hands-on Lab Scenario =====
Line 33: Line 33:
  
 ==== Start ==== ==== Start ====
-For statical measurements, ensure the fan is stopped. Note that the fan tends to spin up on itself (explained in EMB1A) when the GPIO controlling the fan is not configured, so it is better to ensure it is set to output and low (0) to keep the fan stopped. Refer to the [[en:iot-open:practical:hardware:sut:esp32:emb1a_1|]] for details on controlling the fan.+For statical measurements, ensure the fan is stopped. Note that the fan tends to spin up on itself (explained in STM1A) when the GPIO controlling the fan is not configured, so it is better to ensure it is set to output and low (0) to keep the fan stopped. Refer to the [[en:iot-open:practical:hardware:sut:stm32:emb1a_1|]] for details on controlling the fan.
  
  
  
 ==== Steps ==== ==== Steps ====
-The steps below present only interaction with the sensor. Those steps should be supplied to present the data (or send it over the network) using other scenarios accordingly, and also with a scenario EMB1A presenting no instructions on controlling the fan that can change the air pressure in the yellow pressure chamber.+The steps below present only interaction with the sensor. Those steps should be supplied to present the data (or send it over the network) using other scenarios accordingly, and also with a scenario STM_1A presenting instructions on controlling the fan that can change the air pressure in the yellow pressure chamber.
  
 === Step 1 === === Step 1 ===
Line 76: Line 76:
 The temperature is Celsius, air pressure is in Pascals (so we divide it by float 100 to obtain the hPa reading), and relative air humidity is in % (frequently referenced as %Rh). The temperature is Celsius, air pressure is in Pascals (so we divide it by float 100 to obtain the hPa reading), and relative air humidity is in % (frequently referenced as %Rh).
  
-Note that the controller class has an exciting function of trading Altitude based on the sea-level pressure (needed to have a correct reading:+Note that the controller class has an exciting function of trading the altitude based on the sea-level pressure. We need to provide as the argument the current value of the sea-level pressure to have a correct altitude reading:
 <code c> <code c>
  float altitude = bme280.readAltitude(1013.00F);  float altitude = bme280.readAltitude(1013.00F);
 </code> </code>
  
-You need to know the sea level pressure (a parameter, here, 1013hPa). It uses ''readPressure()'' internally and returns the altitude level. Note that due to the non-linear characteristics of the air pressure drop with increasing altitude, it does not work correctly at high altitudes.+Note that due to the non-linear characteristics of the air pressure drop with increasing altitude, it does not work correctly at high altitudes.
  
 The library also has a mathematical calculation function that returns current sea level pressure if only altitude and local air pressure are known. It does not read the sensor itself, however: The library also has a mathematical calculation function that returns current sea level pressure if only altitude and local air pressure are known. It does not read the sensor itself, however:
Line 92: Line 92:
  
 ===== FAQ ===== ===== FAQ =====
-**I've got NaN (Not a Number) readings. What to do?**: Check if GPIO is OK (should be 47), check if you initialised controller class and most of all, give the sensor some recovery time (at least 250ms) between consecutive readings.+**I've got NaN (Not a Number) readings. What to do?**: Check if the I2C address corresponds to the BME280 sensor (should be 0x76), check if you initialised controller class and most of all, give the sensor some recovery time (at least 250ms) between consecutive readings.
  
 <WRAP noprint> <WRAP noprint>
en/iot-open/practical/hardware/sut/stm32/emb1b_1.1713687402.txt.gz · Last modified: 2024/04/21 08:16 by ktokarz
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0