aboutsummaryrefslogtreecommitdiff
path: root/stm32f091/sensor.c
diff options
context:
space:
mode:
Diffstat (limited to 'stm32f091/sensor.c')
-rw-r--r--stm32f091/sensor.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/stm32f091/sensor.c b/stm32f091/sensor.c
index 77ade64..d796130 100644
--- a/stm32f091/sensor.c
+++ b/stm32f091/sensor.c
@@ -7,6 +7,7 @@
#include "backlog.h"
#define SI7021_ADDRESS ((uint16_t)(0x40) << 1)
+#define BMP280_ADDRESS ((uint16_t)(0x76) << 1)
#define REG_TEMP ((uint8_t)(0xE3))
#define REG_HUM ((uint8_t)(0xF5))
@@ -29,7 +30,18 @@ uint8_t ws_sensor_humidity() {
}
uint8_t ws_sensor_atmospheric_pressure() {
- return 0x00;
+ uint8_t buf[12];
+ uint8_t buffer[12];
+ int16_t val;
+
+ buf[0]= 0xF4;
+ buf[1]= 0x07;
+ buffer[0] = 0xF7;
+ HAL_I2C_Master_Transmit(&hi2c1, BMP280_ADDRESS, buf , 2, HAL_MAX_DELAY);
+ HAL_I2C_Mem_Read(&hi2c1, BMP280_ADDRESS, 0xF7, 1, buffer, 2, 100 );
+ val = (buffer[0] << 8 | buffer[1]);
+
+ return (uint8_t) val; // TODO: convert with range
}
void ws_sensor_read() {