Add light sensor driver
This commit is contained in:
parent
42af035ae6
commit
b9ffab5c2b
@ -122,6 +122,17 @@ void read_sensor2(int32_t* temp, uint32_t* pressure, uint32_t* humidity) {
|
||||
*humidity = comp_data.humidity;
|
||||
}
|
||||
|
||||
double read_light_sensor() {
|
||||
uint8_t raw_high = 0;
|
||||
|
||||
i2c_read(0x4a, 0x03, &raw_high, 1);
|
||||
|
||||
uint8_t exp = raw_high >> 4;
|
||||
uint8_t mant = raw_high & 0b00001111;
|
||||
|
||||
return pow(2, exp) * mant * 0.72;
|
||||
}
|
||||
|
||||
void init_sensors()
|
||||
{
|
||||
// INIT SENSOR
|
||||
|
@ -11,9 +11,11 @@
|
||||
#include "bme280.h"
|
||||
#include "bme280_defs.h"
|
||||
#include "driver/i2c.h"
|
||||
#include "math.h"
|
||||
|
||||
void init_sensors();
|
||||
void read_sensor2(int32_t* temp, uint32_t* pressure, uint32_t* humidity);
|
||||
void read_sensor(int32_t* temp, uint32_t* pressure, uint32_t* humidity);
|
||||
double read_light_sensor();
|
||||
|
||||
#endif /* COMPONENTS_SENSORS_SENSORS_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user