Access BLE data remotely
Tags: javascript, php, bluetoothlowenergy, ble
Published: 2021-11-12 14:30:56

<div class="text-justify">

Suppose you have some BLE devices at your home and want to control or scan for those devices while at your workplace. In this project, we will discuss how to access BLE data remotely.  

We have already created a script that communicates through BleuIO dongle remotely and gives us the response. You can access the script at 

[https://github.com/smart-sensor-devices-ab/bledata_remote_access.git](https://github.com/smart-sensor-devices-ab/bledata_remote_access.git)

You are free to clone the script and make changes as you wish. 

In this script, JavaScript is used to connect to the dongle using google chrome’s serial port. There is a simple PHP script that helps pass data through the cloud.

**Step 1: Uploading**

Upload the API folder in any server that supports PHP. This script reads and writes data to a JSON file upon request.

We have uploaded the file at http://smartsensor.io/api/api.php

You can use this URL if you don’t have a server to upload.

**Step 2: Home computer setup**

Open the **index.js** file found in the root folder and update the URL of the API file on both occasions. 

You can leave the url as it is if you want to use file from our server.

<figure class="wp-block-image size-large">![](http://smartsensordevices.com/wp-content/uploads/2021/11/image-5.png)</figure>

Now connect a BleuIO dongle to your home computer and open the **index.html** file from the root folder.

Click **connect **and select the COM port where the dongle is connected.

<figure class="wp-block-image size-large">![](http://smartsensordevices.com/wp-content/uploads/2021/11/image-1.png)</figure>

**Step 3: Office / Workplace / remote computer setup**

Open the **index.html** file found in the user folder and update the URL of the API file on both occasions.

You can leave the url as it is if you want to use file from our server.

<figure class="wp-block-image size-large">![](http://smartsensordevices.com/wp-content/uploads/2021/11/image-4.png)</figure>

Now open this file in a browser and start writing AT commands.

Currently, You can access the following AT commands 

*   ATI (_ Returns firmware version, hardware type and unique organization identifier, device connection status_ )
*   AT+CENTRAL (_Sets the device Bluetooth role to central role._)
*   AT+PERIPHERAL (_Sets the device Bluetooth role to the peripheral._)
*   AT+DUAL (_Sets the device Bluetooth role to dual role. Which means it has both Central and Peripheral role capabilities._)
*   AT+ADVSTART (_Starts advertising_)
*   AT+ADVSTOP (S_tops advertising. Returns ERROR if not already advertising_)
*   AT+GAPSTATUS (_Reports the Bluetooth role_)
*   AT+GAPSCAN=2 (_Starts a Bluetooth device scan with the timer set in seconds. Make sure to set a timer for the scan._)

Once you type one of the above commands, you will start to see the response from the dongle on your browser screen.

I am trying to scan for BLE devices at my home where BleuIO dongle is connected. Here I got a list of devices showing on my browser screen. Make sure the device is on central mode to scan for devices.

<figure class="wp-block-image size-large">![](http://smartsensordevices.com/wp-content/uploads/2021/11/image-3.png)</figure>

You can add more AT commands to the script as required. All you need to do is update the **index.js** file found in the root folder. 

Find the list of AT commands our from getting started guide at

[https://www.bleuio.com/getting_started/docs/commands/](https://www.bleuio.com/getting_started/docs/commands/)

</div>