#include "extdrv/tmp101_temp_sensor.h"
#include "extdrv/tsl256x_light_sensor.h"
#include "extdrv/veml6070_uv_sensor.h"
+#include "extdrv/bme280_humidity_sensor.h"
#define MODULE_VERSION 0x01
+
+/***************************************************************************** */
+/* Sensor */
+
+/* Note : 8bits address */
+#define BME280_ADDR 0xEC
+struct bme280_sensor_config bme280_sensor = {
+ .bus_num = I2C0,
+ .addr = BME280_ADDR,
+ .humidity_oversampling = BME280_OS_x16,
+ .temp_oversampling = BME280_OS_x16,
+ .pressure_oversampling = BME280_OS_x16,
+ .mode = BME280_NORMAL,
+ .standby_len = BME280_SB_62ms,
+ .filter_coeff = BME280_FILT_OFF,
+};
+
+
+
/***************************************************************************** */
/* Luminosity */
/***************************************************************************** */
int main(void)
{
+ /* TSL2561 and VEML6070 */
uint16_t uv = 0, ir = 0;
uint32_t lux = 0;
+ /* TMP101 */
int deci_degrees = 0;
+ /* BME280 */
+ uint32_t pressure = 0, temp = 0;
+ uint16_t humidity = 0;
+ int comp_temp = 0;
+
int ret = 0;
system_init();
uprintf(UART0, "Temp config error: %d\n", ret);
}
msleep(10);
+
/* Configure lux sensor */
ret = tsl256x_configure(&tsl256x_sensor);
if (ret != 0) {
}
msleep(10);
+ /* Configure barometric + humidity + temp sensor */
+ ret = bme280_configure(&bme280_sensor);
+ if (ret != 0) {
+ uprintf(UART0, "Humidity config error: %d\n", ret);
+ }
+ msleep(10);
+
+
while (1) {
ret = tmp101_sensor_start_conversion(&tmp101_sensor);
if (ret != 0) {
uprintf(UART0, "Temp start conversion error: %d\n", ret);
break;
}
- msleep(460); /* Wait for the end of the conversion : 40ms min */
+ msleep(60); /* Wait for the end of the conversion : 40ms min */
ret = tmp101_sensor_read(&tmp101_sensor, NULL, &deci_degrees);
if (ret != 0) {
uprintf(UART0, "Temp read error: %d\n", ret);
uprintf(UART0, "UV read error: %d\n", ret);
break;
}
+ msleep(10);
+
+ ret = bme280_sensor_read(&bme280_sensor, &pressure, &temp, &humidity);
+ if (ret != 0) {
+ uprintf(UART0, "Humidity read error: %d\n", ret);
+ break;
+ }
+
+ comp_temp = bme280_compensate_temperature(&bme280_sensor, temp) / 10;
+ pressure = bme280_compensate_pressure(&bme280_sensor, pressure) / 100;
+ humidity = bme280_compensate_humidity(&bme280_sensor, humidity) / 10;
/* Display all */
- uprintf(UART0, "Lux: %d, IR: %d, UV: %d, Temp: %d,%d\n", lux, ir, uv,
+ uprintf(UART0, "Lux: %d, IR: %d, UV: %d, Temp: %d,%d degC\n", lux, ir, uv,
(deci_degrees/10), (deci_degrees%10));
+ uprintf(UART0, "Patm: %d hPa, Temp: %d,%02d degC, Humidity: %d,%d rH\n\n",
+ pressure,
+ comp_temp / 10, (comp_temp > 0) ? (comp_temp % 10) : ((-comp_temp) % 10),
+ humidity / 10, humidity % 10);
+
+ msleep(400); /* Add some delay */
}
i2c_off(I2C0);