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
Revision 4:33c71735c529, committed 2016-12-14
- Comitter:
- kat123
- Date:
- Wed Dec 14 10:38:35 2016 +0000
- Parent:
- 3:823f105078c7
- Child:
- 5:55d6789683d5
- Commit message:
- dd;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
nRF51822_BMP180.lib | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Jan 07 02:49:37 2016 +0000 +++ b/main.cpp Wed Dec 14 10:38:35 2016 +0000 @@ -21,6 +21,8 @@ #include "ble/BLE.h" #include "Servo.h" #include "GattCallbackParamTypes.h" +#include "BMP180.h" + #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. */ @@ -45,6 +47,8 @@ Serial pc(USBTX, USBRX); static uint8_t analog_enabled = 0; +static uint8_t temperature_enabled=0; +static uint8_t pressure_enabled=0; static uint8_t old_state = 0; // The Nordic UART Service @@ -123,6 +127,23 @@ LED_SET = 0; old_state = 0; } + + else if(buf[0]== 0xA1) + { + if(buf[1]==0x01) + + temperature_enabled = 1; + else + temperature_enabled = 0; + } + + else if(buf[0]== 0xA2) + { + if(buf[1]==0x01) + pressure_enabled = 1; + else + pressure_enabled = 0; + } } } @@ -158,6 +179,26 @@ buf[2] = (value); ble.updateCharacteristicValue(rxCharacteristic.getValueAttribute().getHandle(), buf, 3); } + if(temperature_enabled) + { + float temp; + float t=bmp180.getTemperature(&temp); + uint16_t value=t*1024; + buf[0]=(0x0B) ; + buf[1]=(value>>8); + buf[2]=(value); + ble.updateCharacteristicValue(rxCharacteristic.getValueAttribute().getHandle(), buf, 3); + } + if(pressure_enabled) + { + int pres; + int p=bmp180.getPressure(&pres); + uint16_t value=p*1024; + buf[0]=(0x0B); + buf[1]=(value>>8); + buf[2]=(value); + ble.updateCharacteristicValue(rxCharacteristic.getValueAttribute().getHandle(), buf, 3); + } // If digital in changes, report the state if (BUTTON != old_state)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nRF51822_BMP180.lib Wed Dec 14 10:38:35 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/yanndouze/code/nRF51822_BMP180/#43e6a2416ddf