SCP v30 07: Luxes sensor
This is the basic code to manage and read the luxes sensor.

Required Materials

1 x Waspmote 1 x Battery 1 x Smart Cities PRO board 1 x Luxes Accuracy Sensor

Notes

- Remember to connect the battery to Waspmote for proper operation. - The connection of the sensor is described in the Smart Cities PRO technical guide. - Cycle time: 30 seconds

Code

1
/*
2
------------ [SCP_v30_07] - Luxes sensor --------------
3
4
Explanation: This is the basic code to manage and read the
5
luxes sensor.Cycle time: 30 seconds
6
7
Copyright (C) 2017 Libelium Comunicaciones Distribuidas S.L.
8
http://www.libelium.com
9
10
This program is free software: you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
14
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
19
20
You should have received a copy of the GNU General Public License
21
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
23
Version: 3.1
24
Design: David Gascón
25
Implementation: Alejandro Gállego
26
*/
27
28
#include <WaspSensorCities_PRO.h>
29
30
/*
31
Waspmote OEM. Possibilities for this sensor:
32
- SOCKET_1
33
- SOCKET_2
34
- SOCKET_3
35
- SOCKET_4
36
- SOCKET_5
37
P&S! Possibilities for this sensor:
38
- SOCKET_A
39
- SOCKET_B
40
- SOCKET_C
41
- SOCKET_E
42
- SOCKET_F
43
*/
44
luxesCitiesSensor luxes(SOCKET_E);
45
46
// variable
47
uint32_t luminosity;
48
49
void setup()
50
{
51
USB.println(F("Luxes sensor example"));
52
}
53
54
void loop()
55
{
56
///////////////////////////////////////////
57
// 1. Turn on the sensor
58
///////////////////////////////////////////
59
luxes.ON();
60
61
///////////////////////////////////////////
62
// 2. Read sensor
63
///////////////////////////////////////////
64
65
// Read the luminosity sensor
66
luminosity = luxes.getLuminosity();
67
68
// And print the value via USB
69
USB.println(F("***************************************"));
70
USB.print(F("Luminosity: "));
71
USB.print(luminosity);
72
USB.println(F(" luxes"));
73
74
///////////////////////////////////////////
75
// 3. Power off sensor
76
///////////////////////////////////////////
77
luxes.OFF();
78
79
///////////////////////////////////////////
80
// 4. Sleep
81
///////////////////////////////////////////
82
83
// Go to deepsleep
84
// After 10 seconds, Waspmote wakes up thanks to the RTC Alarm
85
USB.println(F("Enter deep sleep mode"));
86
PWR.deepSleep("00:00:00:10", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);
87
USB.ON();
88
USB.println(F("wake up!!"));
89
}
Copied!

Output

1
H#
2
Luxes sensor example
3
The sensor is placed in socket 2
4
***************************************
5
Luminosity: 57 luxes
6
***************************************
7
Luminosity: 58 luxes
8
***************************************
9
Luminosity: 55 luxes
10
***************************************
11
Luminosity: 58 luxes
Copied!
Last modified 1yr ago