# Simple BLE Example (Scan Advertising Devices, List Details, Connect to One Sensor Device)

**URL:** https://community.particle.io/t/simple-ble-example-scan-advertising-devices-list-details-connect-to-one-sensor-device/54155
**Category:** BLE // NFC
**Created:** [January 10, 2020, 7:03am UTC](https://community.particle.io/t/simple-ble-example-scan-advertising-devices-list-details-connect-to-one-sensor-device/54155 "2020-01-10T07:03:31Z")
**Posts on this page:** 4
**Page:** 2

<div class="post-metadata">

### Author: ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)
#### Post date: [January 12, 2020, 8:41pm UTC](https://community.particle.io/t/simple-ble-example-scan-advertising-devices-list-details-connect-to-one-sensor-device/54155/22 "2020-01-12T20:41:29Z")

</div>

> [@neal\_tommy](#):
>
> (without having to have 2-3 of the same UUIDs for each sensor).

Once you know _which_ of the multiple options works for the particular UUIDs you are looking at then you don't need to include all the alternatives.

---

<div class="post-metadata">

### Author: ![neal\_tommy](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/neal_tommy/32/1169_2.png) [@neal\_tommy](https://community.particle.io/u/neal_tommy)
#### Post date: [January 14, 2020, 4:14pm UTC](https://community.particle.io/t/simple-ble-example-scan-advertising-devices-list-details-connect-to-one-sensor-device/54155/23 "2020-01-14T16:14:45Z")

</div>

@ScruffR - would appreciate your eye on the [revised code](https://go.particle.io/shared_apps/5e1de7d605556d00058e12ac) here. I’m still only outputting Temperature data as per the below example :

Temp 29.5 °C (raw: 2950)  
Humd 0.0 (raw: 0)  
Temp 29.5 °C (raw: 2950)  
Humd 0.0 (raw: 0)

I only assume it is something simple which I’m missing. I was worried that the Temperautre.valid() was causing this but essentially when we receive temperature data we should also have all the other data with…?

Any clues here?

---

<div class="post-metadata">

### Author: ![neal\_tommy](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/neal_tommy/32/1169_2.png) [@neal\_tommy](https://community.particle.io/u/neal_tommy)
#### Post date: [January 14, 2020, 4:22pm UTC](https://community.particle.io/t/simple-ble-example-scan-advertising-devices-list-details-connect-to-one-sensor-device/54155/24 "2020-01-14T16:22:26Z")

</div>

Hold the bus… I seem to have broken through to something here. Am using a hybridisation between two sets of code and am getting something.

Temp 29.6 °C (raw: 2956)  
Humd 36.1 (raw: 3606)  
Temp 29.6 °C (raw: 2956)  
Humd 36.1 (raw: 3606)

No action required yet, thanks, will come back if I get all the sensor data out.

N.

---

<div class="post-metadata">

### Author: ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)
#### Post date: [January 14, 2020, 4:24pm UTC](https://community.particle.io/t/simple-ble-example-scan-advertising-devices-list-details-connect-to-one-sensor-device/54155/25 "2020-01-14T16:24:40Z")

</div>

```cpp
Serial.printlnf("Humd %.1f % (raw: %d)", Humd, rawHumd);

```

Sincer `%` is used to _escape_ variable placeholders you need to also _escape_ the percent sign itself.  
Consequently you’d need to do this

```cpp
Serial.printlnf("Humd %.1f %% (raw: %d)", Humd, rawHumd);

```

in order to get the symbol turn up in the output.

Are you sure you want to have the _humidity_ reading to depend on the validity of the _temperature_ characteristics?

```cpp
  else if (Temperature.valid()) { 
    loopDelay = 1000; // when connected read every second could be modulated via delta temp more volatile temperature may warrant a lower loop cadance
    
    Temperature.getValue(&rawTemp); // request temperature from BLE peripheral
    temp = rawTemp / 100.0; // convert from 100ths, although too simple
    Serial.printlnf("Temp %.1f °C (raw: %d)", temp, rawTemp);
    
    Humidity.getValue(&rawHumd);
    if (sizeof(rawHumd) == Humidity.getValue((uint8_t*)&rawHumd, sizeof(rawHumd)))
        Humd = rawHumd / 100.0;
    
    //Humidity.getValue(&rawHumd); // request temperature from BLE peripheral
    //Humd = rawHumd / 100.0; // convert from 100ths, although too simple
    Serial.printlnf("Humd %.1f %% (raw: %d)", Humd, rawHumd);
    
  }

```

[Previous page](https://community.particle.io/t/simple-ble-example-scan-advertising-devices-list-details-connect-to-one-sensor-device/54155.md?page=1)
