BLE_HTS_Demo

This BLE_HTS_Demo program enables you to collect Temperature and Humidity data reading from sensor and transmit to collector device such as smartphone.

Below documents teach you how to install app that can connect and read data from our DELTA-DFCM-NNN40 development board. There are two versions, Android and iPhone.

/media/uploads/Marcomissyou/ios_app_for_environment_sensor_0518.pdf

/media/uploads/Marcomissyou/android_app_for_environment_sensor.pdf

Revision:
1:a7ecbb0ccc61
Parent:
0:ef0f188a6fdd
Child:
2:13ffe50056f9
--- a/main.cpp	Wed Jun 03 03:13:27 2015 +0000
+++ b/main.cpp	Wed Jun 03 05:40:14 2015 +0000
@@ -1,5 +1,3 @@
-
-
 /* mbed Microcontroller Library
  * Copyright (c) 2006-2013 ARM Limited
  *
@@ -29,21 +27,9 @@
 
 #define NEED_CONSOLE_OUTPUT 1 /* Set this if you need debug messages on the console;
                                * it will have an impact on code-size and power consumption. */
-
-#if NEED_CONSOLE_OUTPUT
-Serial  pc(p25, p23);
-#define DEBUG(...) { pc.printf(__VA_ARGS__); }
-#else
-#define DEBUG(...) /* nothing */
-#endif /* #if NEED_CONSOLE_OUTPUT */
-
 BLEDevice  ble;
-
-InterruptIn Button0_LowInt(p7);   
-
-DigitalOut  led0(p4);
-DigitalOut  led1(p5);
-DigitalOut  led2(p6);
+ 
+DigitalOut  led0(p7);
 
 static const uint8_t UUID_HUMI_AND_UVI[] = {0xf5, 0x59, 0xa2, 0x49, 0xbe, 0xb1, 0x4c, 0x54, 0xa1, 0x0a, 0xc7, 0x95, 0x7e, 0x17, 0xf8, 0x67};
 uint8_t wrs_HumiUVI_payload[11] = {0, };
@@ -79,8 +65,6 @@
 //
 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
 {
-    DEBUG("Disconnected!\n\r");
-    DEBUG("Restarting the advertising process\n\r");
     ble.startAdvertising();
 }
 
@@ -92,10 +76,6 @@
      * heavy-weight sensor polling from the main thread. */
     triggerSensorPolling = true;
 }
-
-void LowInt() {
-    led0 = !led0;
-}
 /**************************************************************************/
 /*!
     @brief  Program entry point
@@ -107,14 +87,9 @@
     nrf_gpio_cfg_output(19);    // SWIO 
     nrf_gpio_pin_clear(19);
     
-    Button0_LowInt.fall(&LowInt);
-    
     if (hts221_init() ) //led2=1;
 //    else led2=0;
     HTS221_Calib();
-    /* Setup blinky: led1 is toggled in main, led2 is toggled via Ticker */
-//    led1=1;
-//    led2=0;
     
     Ticker ticker;
     ticker.attach(periodicCallback, 2);
@@ -138,8 +113,6 @@
     ble.addService(htsService);   
     
     while (true) {
- //       if (triggerSensorPolling ) {
-//            triggerSensorPolling = false;
 
             HTS221_ReadTempHumi(&tempCelsius, &humi);
             uvi = UVIS25_ReadUVI();
@@ -155,29 +128,15 @@
             ble.updateCharacteristicValue(htsTemp.getValueAttribute().getHandle(), htsTempPayload, 12);  
 
             ble.waitForEvent(); 
-            wait(1);
-            //humi_ix100 = humi * 100;   
+            wait(1); 
             wrs_HumiUVI_payload[0] = 0x03;    // flag
             memcpy(&wrs_HumiUVI_payload[1],&humi,4);
-            //wrs_HumiUVI_payload[1] = humi_ix100%0xff;
-//            wrs_HumiUVI_payload[2] = humi_ix100/0xff;
-//            wrs_HumiUVI_payload[3] = humi_ix100/0xffff;
-//            wrs_HumiUVI_payload[4] = exponent;
             wrs_HumiUVI_payload[5] = uvi;
       
             ble.updateCharacteristicValue(wrs_HumiUVI.getValueAttribute().getHandle(), wrs_HumiUVI_payload, 6);
             ble.waitForEvent();                    
-            DEBUG("%f,%f,%d\r\n", tempCelsius, humi, counter++);
             wait(1);
             
-        //} else {
-//           ble.waitForEvent();
-//        }
     }
         
-}
-
-// Gill modify   
-// 20150331 change humi data format to float 
-// 20150408 diable triggerSensorPolling function, using while loop and wait 
-// 20150428 change external clock to internal RC
\ No newline at end of file
+}
\ No newline at end of file