This version includes the BMP180 pressure/temperature/altitude sensor. The adquisition of these values were done through BLE over a Rasberry Pi.

Dependencies:   BLE_API BMP085 BMP180 I2C_Driver mbed nRF51822

Fork of nRF51822_SimpleControls by RedBearLab

Files at this revision

API Documentation at this revision

Comitter:
kat123
Date:
Sun Jan 01 18:27:03 2017 +0000
Parent:
4:33c71735c529
Commit message:
Last Version including BMP180 sensor lecture.

Changed in this revision

BMP085.lib Show annotated file Show diff for this revision Revisions of this file
BMP180.lib Show annotated file Show diff for this revision Revisions of this file
I2C_Driver.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
nRF51822_BMP180.lib Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BMP085.lib	Sun Jan 01 18:27:03 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/okini3939/code/BMP085/#5e2b1f3c0a6a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BMP180.lib	Sun Jan 01 18:27:03 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/kgills/code/BMP180/#b2219e6e444b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C_Driver.lib	Sun Jan 01 18:27:03 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/cesarcazal/code/I2C_Driver/#2514f1c72462
--- a/main.cpp	Wed Dec 14 10:38:35 2016 +0000
+++ b/main.cpp	Sun Jan 01 18:27:03 2017 +0000
@@ -22,7 +22,9 @@
 #include "Servo.h"
 #include "GattCallbackParamTypes.h"
 #include "BMP180.h"
-
+//#include "BMP"
+I2C i2c(D14, D15);
+BMP180 bmp180(&i2c);
 
 #define BLE_UUID_TXRX_SERVICE            0x0000 /**< The UUID of the Nordic UART Service. */
 #define BLE_UUID_TX_CHARACTERISTIC       0x0002 /**< The UUID of the TX Characteristic. */
@@ -108,7 +110,8 @@
             if(buf[1] == 0x01)
                 analog_enabled = 1;
             else
-                analog_enabled = 0;
+                analog_enabled = 0;   
+            
         }
         else if(buf[0] == 0x02)
         {
@@ -181,23 +184,32 @@
     }
     if(temperature_enabled)
     {
+        bmp180.startTemperature();
+        wait_ms(5);
+        
         float temp;
-        float t=bmp180.getTemperature(&temp);
-        uint16_t value=t*1024;
-        buf[0]=(0x0B) ;
-        buf[1]=(value>>8);
+        bmp180.getTemperature(&temp);    
+        uint16_t value=temp*1024;
+        buf[0]=(0x0B);
+        buf[1]=(value >> 8);
         buf[2]=(value);
         ble.updateCharacteristicValue(rxCharacteristic.getValueAttribute().getHandle(), buf, 3);
+       // printf("Tempreature: %f \r\n", temp);
+        
     }
     if(pressure_enabled)        
     {
+       bmp180.startPressure(BMP180::ULTRA_LOW_POWER);
+       wait_ms(10);
+       
         int pres;
-        int p=bmp180.getPressure(&pres);
-        uint16_t value=p*1024;
+        bmp180.getPressure(&pres);
+        uint16_t value=pres*1024;
         buf[0]=(0x0B);
         buf[1]=(value>>8);
         buf[2]=(value);
         ble.updateCharacteristicValue(rxCharacteristic.getValueAttribute().getHandle(), buf, 3);
+        //printf("Pressure: %d \r\n", pres);
     }
     
     // If digital in changes, report the state
@@ -241,7 +253,7 @@
     ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED);
     ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
     ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME,
-                                    (const uint8_t *)"Biscuit", sizeof("Biscuit") - 1);
+                                    (const uint8_t *)"FaKa123", sizeof("FaKa123") - 1);
     ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS,
                                     (const uint8_t *)uart_base_uuid_rev, sizeof(uart_base_uuid));
     // 100ms; in multiples of 0.625ms. 
@@ -253,8 +265,11 @@
     
     pc.printf("Advertising Start \r\n");
     
+    bmp180.init();
+    
     while(1)
     {
+        //bmp180.init();
         ble.waitForEvent(); 
     }
 }
--- a/nRF51822_BMP180.lib	Wed Dec 14 10:38:35 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/yanndouze/code/nRF51822_BMP180/#43e6a2416ddf