If you are using only one obnizBLEGateway, the system will be simple.
The system configuration would look like this
![](./images/system-single.png)


A single obniz device can be used to detect multiple BLE Beacon devices.


The basic flow of the program is as follows

1. Establish a connection to multiple obniz devices.
2. Initialize the BLE system
3. Start scan for peripheral BLE devices
4. Save the scan results to a database or other location
5. Repeat 3 to 4.

Here's what it looks like in concrete terms.

```javascript
const Obniz = require('obniz');
var obniz = new Obniz("OBNIZ_ID_HERE");

//  Establish a connection to multiple obniz devices.
obniz.onconnect = async function () {


  //Initialize the BLE system
  await obniz.ble.initWait();

  obniz.ble.scan.onfind = async function(peripheral){
    console.log(peripheral.localName);

    // Save the scan results to a database or other location
    sendToDatabase(peripheral);
  };

  obniz.ble.scan.onfinish = async function(peripherals, error){
    console.log("scan timeout!")
 
    // Start scan for peripheral BLE devices
    await obniz.ble.scan.startWait();
  };
 
  // Start scan for peripheral BLE devices
  await obniz.ble.scan.startWait();


}

function sendToDatabase() {
  
}


```


By customizing the above program, you can have more detailed control.
Please refer to [How to use BLE](/reference/common/ble/) in obnizjs to customize the program.

For example, here are some articles that can help you

- If you want to narrow down your scan results
Set ScanTarget in [conditional search](/reference/common/ble/central-scan#conditional-search)
  
- I want to reduce the amount of communication.
[Filter by device to reduce traffic](/reference/common/ble/central-scan-filter#filtering-on-devices-to-reduce-traffic) E3%82%A3%E3%83%AB%E3%82%BF%E3%83%AA%E3%83%B3%E3%82%B0%E3%82%92%E3%81%97%E3%81%A6%E9%80%9A%E4%BF%A1%E9%87%8F%E3%82%92%E5%89%8A%E6%B 8%9B%E3%81%99%E3%82%8B) 


- I want to scan all the time, not just every 30 seconds.
Set up ScanSetting in [conditional search](/reference/common/ble/central-scan#conditional-search)


- I want to receive multiple advertisements from the same device
Set up ScanSetting in [conditional search](/reference/common/ble/central-scan#conditional-search)
  

The basic flow of the program is as follows

Establish a connection with an obniz device
2. initialize the BLE system
3. perform a scan for peripheral BLE devices
4. save the scan results to a database or other location
5. repeat 3 to 4.


