GP 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 Gases PRO board v30 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 Gases PRO v30 technical guide. - Cycle time: 30 seconds

Code

1
/*
2
* ------------ [GP_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 <WaspSensorGas_Pro.h>
29
#include <TSL2561.h>
30
31
/*
32
* Waspmote OEM. Possibilities for this sensor:
33
* - CENTRAL SOCKET
34
* P&S! Possibilities for this sensor:
35
* - SOCKET_E
36
*/
37
38
void setup()
39
{
40
USB.println(F("Luxes sensor example"));
41
// Configures the I2C isolator
42
pinMode(GP_I2C_MAIN_EN, OUTPUT);
43
}
44
45
void loop()
46
{
47
///////////////////////////////////////////
48
// 1. Turn on the sensor
49
///////////////////////////////////////////
50
51
// Power on the 3v3.
52
PWR.setSensorPower(SENS_3V3, SENS_ON);
53
// Enable the communication with the board
54
digitalWrite(GP_I2C_MAIN_EN, HIGH);
55
// Power on the sensor.
56
TSL.ON();
57
58
///////////////////////////////////////////
59
// 2. Read sensor
60
///////////////////////////////////////////
61
62
// Read the luminosity sensor
63
TSL.getLuminosity();
64
65
// And print the value via USB
66
USB.println(F("***************************************"));
67
USB.print(F("Luminosity: "));
68
USB.print(TSL.lux);
69
USB.println(F(" luxes"));
70
71
///////////////////////////////////////////
72
// 3. Power off sensor
73
///////////////////////////////////////////
74
75
// Disable the communication with the board
76
digitalWrite(GP_I2C_MAIN_EN, LOW);
77
// Power off the sensor.
78
PWR.setSensorPower(SENS_3V3, SENS_OFF);
79
80
///////////////////////////////////////////
81
// 4. Sleep
82
///////////////////////////////////////////
83
84
// Go to deepsleep
85
// After 30 seconds, Waspmote wakes up thanks to the RTC Alarm
86
PWR.deepSleep("00:00:00:30", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);
87
}
Copied!

Output

1
H#
2
Luxes sensor example
3
***************************************
4
Luminosity: 15 luxes
5
***************************************
6
Luminosity: 18 luxes
7
***************************************
8
Luminosity: 16 luxes
9
***************************************
10
Luminosity: 20 luxes
Copied!
Last modified 1yr ago