-
Notifications
You must be signed in to change notification settings - Fork 5
/
RAK12010_light.cpp
58 lines (52 loc) · 1.31 KB
/
RAK12010_light.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* @file RAK12010_light.cpp
* @author Bernd Giesecke ([email protected])
* @brief Functions for RAK12010 light sensor
* @version 0.1
* @date 2022-02-01
*
* @copyright Copyright (c) 2022
*
*/
#include "app.h"
#include "Light_VEML7700.h" // Click here to get the library: http://librarymanager/All#RAKwireless_VEML7700
/** Light sensor instance */
Light_VEML7700 VEML = Light_VEML7700();
/**
* @brief Initialize light sensor
*
* @return true success
* @return false failed
*/
bool init_rak12010(void)
{
Wire.begin();
if (!VEML.begin())
{
MYLOG("VEML", "VEML7700 not found");
return false;
}
// MYLOG("VEML", "Found VEML7700");
VEML.setGain(VEML7700_GAIN_1_8);
VEML.setIntegrationTime(VEML7700_IT_800MS);
VEML.powerSaveEnable(true);
VEML.setPowerSaveMode(VEML7700_POWERSAVE_MODE4);
return true;
}
/**
* @brief Read value from light sensor
* Data is added to Cayenne LPP payload as channel
* LPP_CHANNEL_LIGHT2
*
*/
void read_rak12010(void)
{
float light_lux = VEML.readLux();
// #if MY_DEBUG > 0
// float light_white = VEML.readWhite();
// float light_als = VEML.readALS();
// MYLOG("VEML", "L: %.2fLux W: %.2f ALS: %.2f", light_lux, light_white, light_als);
// #endif
g_solution_data.addLuminosity(LPP_CHANNEL_LIGHT2, (uint32_t)VEML.readLux());
set_light_rak14000(light_lux);
}