This program shows how to use the VCNL4010 (proximity and ambient light sensor) on the QW dev kit for detecting an open closet door. When the closet is open, a message will be displayed in the console window and a Sigfox message will be send.
Fork of QW-Closet-detection by
QW Closet Detection
This program shows how to use the VCNL4010 (proximity and ambient light sensor) on the QW dev kit for detecting an open closet door. When the closet is open, a message will be displayed in the console window and a Sigfox message will be send.
Code explanation
The program starts with the initialisation/declaration of the leds, pushbuttons and sensor. Also the necessary function prototypes and serial communications are declared. After the initialisation phase, the sensor ID is read. After that, the program is waiting for a push on one of the buttons to calibrate the "device". Once calibrated, the program enters an infinite loop. Each loop the ambient light value is read. When a certain threshold is passed, a led is turned on to indicate an open closet, a message is shown in the console window and a Sigfox message is transmitted. When the Sigfox message is transmitted, the loop continuous.
Sigfox message payload
First there is the "05", this is the Quicksand ID of the example program. This is used by Quicksand to keep track of our example programs. The second value that is transmitted is the ambient light value the moment when an open closet was detected.
More information and other example code can be found on the component page by clicking the link below: https://developer.mbed.org/components/QW-SIGFOX-Development-Kit/
History
Code optimisation + comment
2016-12-15, by quicksandjonas [Thu, 15 Dec 2016 10:10:30 +0000] rev 1
Code optimisation + comment
This program demonstrates the ambient light sensing functionality of the VCNL4010 on the QW Shields.
2015-11-05, by quicksand [Thu, 05 Nov 2015 09:40:10 +0000] rev 0
This program demonstrates the ambient light sensing functionality of the VCNL4010 on the QW Shields.