Environmental Sensor for NRF board

Dependencies:   DHT11

Committer:
krissl
Date:
Wed Jan 16 09:50:35 2019 +0000
Revision:
0:fe5389573740
Test;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
krissl 0:fe5389573740 1 This example creates and updates a standard Battery Level service containing a single
krissl 0:fe5389573740 2 GATT characteristic.
krissl 0:fe5389573740 3
krissl 0:fe5389573740 4 The [battery service transmits](https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.battery_service.xml) a device's battery level in percentage, with 100% being a fully charged battery and 0% being a fully drained battery.
krissl 0:fe5389573740 5
krissl 0:fe5389573740 6 Although the sample application runs on a BLE device, it doesn't show the device's real battery level (because that changes very slowly and will make for a dull example). Instead, it transmits a fake battery level that starts at 50% (half charged). Every half second, it increments the battery level, going in single increments until reaching 100% (as if the battery is charging). It then drops down to 20% to start incrementing again.
krissl 0:fe5389573740 7
krissl 0:fe5389573740 8 # Running the application
krissl 0:fe5389573740 9
krissl 0:fe5389573740 10 ## Requirements
krissl 0:fe5389573740 11
krissl 0:fe5389573740 12 The sample application can be seen on any BLE scanner on a smartphone. If you don't have a scanner on your phone, please install :
krissl 0:fe5389573740 13
krissl 0:fe5389573740 14 - [nRF Master Control Panel](https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp) for Android.
krissl 0:fe5389573740 15
krissl 0:fe5389573740 16 - [LightBlue](https://itunes.apple.com/gb/app/lightblue-bluetooth-low-energy/id557428110?mt=8) for iPhone.
krissl 0:fe5389573740 17
krissl 0:fe5389573740 18 Hardware requirements are in the [main readme](https://github.com/ARMmbed/mbed-os-example-ble/blob/master/README.md).
krissl 0:fe5389573740 19
krissl 0:fe5389573740 20 ## Building instructions
krissl 0:fe5389573740 21
krissl 0:fe5389573740 22 Building instructions for all samples are in the [main readme](https://github.com/ARMmbed/mbed-os-example-ble/blob/master/README.md).
krissl 0:fe5389573740 23
krissl 0:fe5389573740 24 ## Checking for success
krissl 0:fe5389573740 25
krissl 0:fe5389573740 26 **Note:** Screens captures depicted below show what is expected from this example if the scanner used is *nRF Master Control Panel* version 4.0.5. If you encounter any difficulties consider trying another scanner or another version of nRF Master Control Panel. Alternative scanners may require reference to their manuals.
krissl 0:fe5389573740 27
krissl 0:fe5389573740 28 1. Build the application and install it on your board as explained in the building instructions.
krissl 0:fe5389573740 29 1. Open the BLE scanner on your phone.
krissl 0:fe5389573740 30 1. Start a scan.
krissl 0:fe5389573740 31
krissl 0:fe5389573740 32 ![](img/start_scan.png)
krissl 0:fe5389573740 33
krissl 0:fe5389573740 34 **figure 1** How to start scan using nRF Master Control Panel 4.0.5
krissl 0:fe5389573740 35
krissl 0:fe5389573740 36 1. Find your device; it should be named `BATTERY`.
krissl 0:fe5389573740 37
krissl 0:fe5389573740 38 ![](img/scan_result.png)
krissl 0:fe5389573740 39
krissl 0:fe5389573740 40 **figure 2** Scan results using nRF Master Control Panel 4.0.5
krissl 0:fe5389573740 41
krissl 0:fe5389573740 42 1. Establish a connection with your device.
krissl 0:fe5389573740 43
krissl 0:fe5389573740 44 ![](img/connection.png)
krissl 0:fe5389573740 45
krissl 0:fe5389573740 46 **figure 3** How to establish a connection using Master Control Panel 4.0.5
krissl 0:fe5389573740 47
krissl 0:fe5389573740 48 1. Discover the services and the characteristics on the device. The *Battery service* has the UUID 0x180F and includes the *Battery level* characteristic which has the UUID 0x2A19.
krissl 0:fe5389573740 49
krissl 0:fe5389573740 50 ![](img/discovery.png)
krissl 0:fe5389573740 51
krissl 0:fe5389573740 52 **figure 4** Representation of the Battery service using Master Control Panel 4.0.5
krissl 0:fe5389573740 53
krissl 0:fe5389573740 54 1. Register for the notifications sent by the *Battery level* characteristic.
krissl 0:fe5389573740 55
krissl 0:fe5389573740 56 ![](img/register_to_notifications.png)
krissl 0:fe5389573740 57
krissl 0:fe5389573740 58 **figure 5** How to register to notifications using Master Control Panel 4.0.5
krissl 0:fe5389573740 59
krissl 0:fe5389573740 60
krissl 0:fe5389573740 61 1. You should see the battery level value change every half second. It begins at 50, goes up to 100 (in steps of 1), resets to 20 and so on.
krissl 0:fe5389573740 62
krissl 0:fe5389573740 63 ![](img/notifications.png)
krissl 0:fe5389573740 64
krissl 0:fe5389573740 65 **figure 6** Notifications view using Master Control Panel 4.0.5
krissl 0:fe5389573740 66
krissl 0:fe5389573740 67 If you can see the characteristic, and if its value is incrementing correctly, the application is working properly.
krissl 0:fe5389573740 68