![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
Diff: main.cpp
- Revision:
- 4:33c71735c529
- Parent:
- 3:823f105078c7
- Child:
- 5:55d6789683d5
diff -r 823f105078c7 -r 33c71735c529 main.cpp --- 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)