This is an example to broadcast measured value of BME280 through BLE GATT service.

Dependencies:   BME280

please refer detail information at GitHub. https://github.com/soramame21/BLE_Server_BME280

Committer:
edamame22
Date:
Fri Apr 14 02:51:57 2017 +0000
Revision:
0:f22fa5cc4d56
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
edamame22 0:f22fa5cc4d56 1 # BLE_Server_BME280
edamame22 0:f22fa5cc4d56 2 This mbed application for BLE GATT server running over TY51822r3 with a builtin BLE shield and wired Bosch BME280 sensor. It broadcasts measured value of temperature, humidity and pressure to BLE GATT client.
edamame22 0:f22fa5cc4d56 3
edamame22 0:f22fa5cc4d56 4 # Getting started with it on mbed OS
edamame22 0:f22fa5cc4d56 5
edamame22 0:f22fa5cc4d56 6 This is a very simple guide, reviewing the steps required to get BLE_Server_BME280 working on mbed OS platform.
edamame22 0:f22fa5cc4d56 7 Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
edamame22 0:f22fa5cc4d56 8
edamame22 0:f22fa5cc4d56 9 ## Get the example application!
edamame22 0:f22fa5cc4d56 10
edamame22 0:f22fa5cc4d56 11 From the command line, clone the example:
edamame22 0:f22fa5cc4d56 12
edamame22 0:f22fa5cc4d56 13 ```
edamame22 0:f22fa5cc4d56 14 git clone https://github.com/soramame21/BLE_Server_BME280
edamame22 0:f22fa5cc4d56 15 cd BLE_Server_BME280
edamame22 0:f22fa5cc4d56 16 mbed deploy
edamame22 0:f22fa5cc4d56 17 ```
edamame22 0:f22fa5cc4d56 18
edamame22 0:f22fa5cc4d56 19 ### Now compile
edamame22 0:f22fa5cc4d56 20
edamame22 0:f22fa5cc4d56 21 Invoke `mbed compile` specifying the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5:
edamame22 0:f22fa5cc4d56 22
edamame22 0:f22fa5cc4d56 23 ```
edamame22 0:f22fa5cc4d56 24 mbed compile -m TY51822r3 -t ARM
edamame22 0:f22fa5cc4d56 25 ```
edamame22 0:f22fa5cc4d56 26
edamame22 0:f22fa5cc4d56 27 Your PC may take a few minutes to compile your code. At the end you should get the following result:
edamame22 0:f22fa5cc4d56 28
edamame22 0:f22fa5cc4d56 29 ```
edamame22 0:f22fa5cc4d56 30 [snip]
edamame22 0:f22fa5cc4d56 31 Link: BLE_Server_BME280
edamame22 0:f22fa5cc4d56 32 Elf2Bin: BLE_Server_BME280
edamame22 0:f22fa5cc4d56 33 +-----------------------+-------+-------+------+
edamame22 0:f22fa5cc4d56 34 | Module | .text | .data | .bss |
edamame22 0:f22fa5cc4d56 35 +-----------------------+-------+-------+------+
edamame22 0:f22fa5cc4d56 36 | Misc | 17384 | 29 | 404 |
edamame22 0:f22fa5cc4d56 37 | drivers | 1489 | 8 | 56 |
edamame22 0:f22fa5cc4d56 38 | features/FEATURE_BLE | 12796 | 38 | 512 |
edamame22 0:f22fa5cc4d56 39 | hal | 558 | 16 | 0 |
edamame22 0:f22fa5cc4d56 40 | platform | 1759 | 8 | 92 |
edamame22 0:f22fa5cc4d56 41 | rtos | 598 | 8 | 0 |
edamame22 0:f22fa5cc4d56 42 | rtos/rtx | 6598 | 100 | 5036 |
edamame22 0:f22fa5cc4d56 43 | targets/TARGET_NORDIC | 23070 | 270 | 2423 |
edamame22 0:f22fa5cc4d56 44 | Subtotals | 64252 | 477 | 8523 |
edamame22 0:f22fa5cc4d56 45 +-----------------------+-------+-------+------+
edamame22 0:f22fa5cc4d56 46 Allocated Heap: unknown
edamame22 0:f22fa5cc4d56 47 Allocated Stack: unknown
edamame22 0:f22fa5cc4d56 48 Total Static RAM memory (data + bss): 9000 bytes
edamame22 0:f22fa5cc4d56 49 Total RAM memory (data + bss + heap + stack): 9000 bytes
edamame22 0:f22fa5cc4d56 50 Total Flash memory (text + data + misc): 64729 bytes
edamame22 0:f22fa5cc4d56 51
edamame22 0:f22fa5cc4d56 52 Image: .\BUILD\TY51822r3\ARM\BLE_Server_BME280.hex
edamame22 0:f22fa5cc4d56 53 ```
edamame22 0:f22fa5cc4d56 54
edamame22 0:f22fa5cc4d56 55 ### Program your board
edamame22 0:f22fa5cc4d56 56
edamame22 0:f22fa5cc4d56 57 1. Connect your mbed device to the computer over USB.
edamame22 0:f22fa5cc4d56 58 1. Copy the binary file to the mbed device .
edamame22 0:f22fa5cc4d56 59 1. Press the reset button to start the program.
edamame22 0:f22fa5cc4d56 60
edamame22 0:f22fa5cc4d56 61 You can verify the output of this application either:
edamame22 0:f22fa5cc4d56 62 - on a serial terminal for your respective OS
edamame22 0:f22fa5cc4d56 63
edamame22 0:f22fa5cc4d56 64 BME280 data are read and print every second.
edamame22 0:f22fa5cc4d56 65
edamame22 0:f22fa5cc4d56 66 OR
edamame22 0:f22fa5cc4d56 67 - on a BLE enabled Android device with the Nordic nRF connect app
edamame22 0:f22fa5cc4d56 68
edamame22 0:f22fa5cc4d56 69 You can scan for the "BME280" device and "connect" to it. Upon successful discovery of services, you can enable "notifications" and start getting the sensor's data.
edamame22 0:f22fa5cc4d56 70
edamame22 0:f22fa5cc4d56 71
edamame22 0:f22fa5cc4d56 72 Congratulations if you managed to complete this test!
edamame22 0:f22fa5cc4d56 73
edamame22 0:f22fa5cc4d56 74 ### Monitoring the application
edamame22 0:f22fa5cc4d56 75 The application prints debug messages over the serial port, so you can monitor its activity with a serial terminal emulator. Start the [serial terminal emulator](https://developer.mbed.org/handbook/Terminals) and connect to the [virtual serial port](https://developer.mbed.org/handbook/SerialPC#host-interface-and-terminal-applications)
edamame22 0:f22fa5cc4d56 76 presented by TY51822r3. Use the following settings:
edamame22 0:f22fa5cc4d56 77
edamame22 0:f22fa5cc4d56 78 * 9600 baud.
edamame22 0:f22fa5cc4d56 79 * 8N1
edamame22 0:f22fa5cc4d56 80 * No flow control
edamame22 0:f22fa5cc4d56 81
edamame22 0:f22fa5cc4d56 82 After pressing the **RESET** button on the board, you should be able to observe the application's output as following.
edamame22 0:f22fa5cc4d56 83
edamame22 0:f22fa5cc4d56 84 ```
edamame22 0:f22fa5cc4d56 85 Inside BLE..starting payload creation..
edamame22 0:f22fa5cc4d56 86 ble.gap().startAdvertising() => 0
edamame22 0:f22fa5cc4d56 87 1004.25 hPa, 25.64 degC, 24.64 %
edamame22 0:f22fa5cc4d56 88 1004.28 hPa, 25.64 degC, 24.64 %
edamame22 0:f22fa5cc4d56 89 1004.25 hPa, 25.64 degC, 24.66 %
edamame22 0:f22fa5cc4d56 90 1004.30 hPa, 25.64 degC, 24.61 %
edamame22 0:f22fa5cc4d56 91 ```
edamame22 0:f22fa5cc4d56 92
edamame22 0:f22fa5cc4d56 93 ### Discovering BME280 from `nRF Connect`
edamame22 0:f22fa5cc4d56 94 [Please click this link for reading detail explanation](./img/Discovering.md)
edamame22 0:f22fa5cc4d56 95
edamame22 0:f22fa5cc4d56 96
edamame22 0:f22fa5cc4d56 97 ## Required hardware
edamame22 0:f22fa5cc4d56 98 * [TY51822r3 target platform](https://developer.mbed.org/platforms/Switch-Science-mbed-TY51822r3/)
edamame22 0:f22fa5cc4d56 99
edamame22 0:f22fa5cc4d56 100 It is a Bluetooth low energy development board with the Nordic's nRF51822 Rev.3 SoC.
edamame22 0:f22fa5cc4d56 101
edamame22 0:f22fa5cc4d56 102 [Instractions for updating firmware](https://developer.mbed.org/teams/Switch-Science/wiki/Firmware-Switch-Science-mbed-TY51822r3)
edamame22 0:f22fa5cc4d56 103
edamame22 0:f22fa5cc4d56 104 [Latest firmware version](https://developer.mbed.org/media/uploads/asagin/lpc11u35_sscity_if_crc.bin)
edamame22 0:f22fa5cc4d56 105
edamame22 0:f22fa5cc4d56 106 * [BME280 sensor](https://developer.mbed.org/components/BME280-Combined-humidity-and-pressure-se/)
edamame22 0:f22fa5cc4d56 107
edamame22 0:f22fa5cc4d56 108 * Breadboard, wires, 2 registers (2.2k-ohm) and a USB cable.
edamame22 0:f22fa5cc4d56 109
edamame22 0:f22fa5cc4d56 110 ## Wiring
edamame22 0:f22fa5cc4d56 111 BME280 uses I2C interface (SDI/SCK) to communicate with TY51822r3. please refer following table about paired pin wiring between BME280 and TY51822r3.
edamame22 0:f22fa5cc4d56 112
edamame22 0:f22fa5cc4d56 113 | BME280 Pin | TY51822r3 Pin |
edamame22 0:f22fa5cc4d56 114 |--------------|-----------------|
edamame22 0:f22fa5cc4d56 115 | 1 SDO | GND |
edamame22 0:f22fa5cc4d56 116 | 2 SCK | P0_7 scl I2C0 |
edamame22 0:f22fa5cc4d56 117 | 3 SDI | P0_30 sda I2C0 |
edamame22 0:f22fa5cc4d56 118 | 4 CSB | VDD |
edamame22 0:f22fa5cc4d56 119 | 5 GND | GND |
edamame22 0:f22fa5cc4d56 120 | 6 Vcore | VDD |
edamame22 0:f22fa5cc4d56 121 | 7 Vio | VDD |
edamame22 0:f22fa5cc4d56 122
edamame22 0:f22fa5cc4d56 123 * SDI and SCK must be pulled-up by 2.2k-ohm registers.
edamame22 0:f22fa5cc4d56 124
edamame22 0:f22fa5cc4d56 125
edamame22 0:f22fa5cc4d56 126 ## Overview
edamame22 0:f22fa5cc4d56 127 ![Overview of Demo](./img/myImageBME280.png)
edamame22 0:f22fa5cc4d56 128
edamame22 0:f22fa5cc4d56 129
edamame22 0:f22fa5cc4d56 130
edamame22 0:f22fa5cc4d56 131 Please find the BLE GATT Client application under https://github.com/soramame21/BLEClient_mbedDevConn repo.