Quicksand micro-electronics / Mbed 2 deprecated QW_Temperature_Light_Monitor

Dependencies:   QW_Sensors mbed

Fork of QW_Temperature_Light_Monitor by Lieven Hollevoet

Files at this revision

API Documentation at this revision

Comitter:
quicksand
Date:
Mon May 02 12:03:27 2016 +0000
Parent:
1:b2c941af91c6
Commit message:
Added a header byte (0x02) that indicates this example. Added blinking LED to show the device is alive.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b2c941af91c6 -r 33e92af45279 main.cpp
--- a/main.cpp	Tue Mar 08 09:48:32 2016 +0000
+++ b/main.cpp	Mon May 02 12:03:27 2016 +0000
@@ -48,6 +48,7 @@
 /* Ticker for scheduled transmissions */
 Ticker tTX;
 Ticker tSense;
+Ticker heartbeat;
 
 /* Function prototypes */
 void sw1interrupt();
@@ -69,8 +70,15 @@
 /* Serial connection to sigfox modem */
 Serial modem(PA_9, PA_10);
 
+void beat()
+{
+    LED_3 = !LED_3;
+}
+
 int main()
 {
+    /* Blinking LED */
+    heartbeat.attach(&beat, 0.5);
     /* Storage for VCNL4010 readout */
     unsigned char ID=0, Current=0;
     //unsigned int  ProxiValue=0, AmbiValue=0;
@@ -207,6 +215,8 @@
 void sw2interrupt()
 {
     pc.printf("\n\rButton 2 pressed\n\r");
+    LED_1 = 0;
+    handleIRQ1 = true;
 }
 
 void dataScheduledTX()
@@ -232,11 +242,12 @@
     char     command[32];
     
     VCNL4010.ReadAmbiOnDemand (&ambiValue);      // read ambi value on demand
+    sensor.Sense();
     tAvg = sensor.GetAverageTemp();
     tAvgByte = (int8_t)tAvg;
     ambiValueShort = (uint16_t)ambiValue;
 
-    sprintf(command, "AT$SF=%04X%02X,2,0\n", ambiValueShort, tAvgByte);
+    sprintf(command, "AT$SF=02%04X%02X,2,0\n", ambiValueShort, tAvgByte);
     
     pc.printf("Sending ambient light level %i cts and temperature %i degrees C over Sigfox\n", ambiValueShort, tAvgByte);
     pc.printf("using modem command: %s", command);