Community
cancel
Showing results for 
Search instead for 
Did you mean: 
CLin82
New Contributor I
1,231 Views

Connect BLE device to the Intel Edison problem

Jump to solution

Hi all,

I am doing a IoT project using Intel edison. I have a PIR sensor with BLE functionality. I want the PIR BLE sensor to be a peripheral and the Edison to act as a central. When the motion is detected, the sensor send a char '1', otherwise it sends '0 to the Edison board. Once the Edison received the data, it will display it using serial port.

I have read the Intel Edison Bluetooth Guide Chapter 6.1 and it tells me how to unblock the Bluetooth and connect to other devices (bluetoothctl---scan on---connect). I found my BLE device and connected to it successfully. Now it is the problem of how the Edison receive data coming from the sensor. I found many people used SPP_loopback.py to communicate with their BLE device. Is it the right direction that I should go?

By the way, I am not very familiar with linux command, " using SCP, copy SPP_loopback.py file over to your board", how should I do that ?

 

And I am using arduino IDE and Windows 8.1.

 

Thanks !

Message was edited by: Cheng Lin

1 Solution
Pedro_M_Intel
Employee
87 Views

Hello channinglin,

You can find a guide on how to run SPP-loopback.py in . Regarding how to copy the SPPloopback.py file to your board's file system, it's quite simple, follow these next steps:

1. Copy the whole content of SPP-loopback.py.

2. On your board's terminal enter the command: "vi SPP-loopback.py"

3. The vi environment will then appear, hit the "i" key to enter in edit mode.

4. Paste the content of SPP-loopback.py in vi (right button on your mouse when using PuTTY on Windows, from the terminal's settings when using screen on Linux)

5. Hit the escape button to exit the edit mode on vi and enter ": x".

Now the SPP-loopback.py script is stored on your board, you can now follow the guide I linked above.

Nevertheless, if you are using a BLE device, I suggest you to use GattTool instead of SPP. In https://devzone.nordicsemi.com/question/71/is-there-a-serial-port-profile-for-ble/ Is there a serial port profile for BLE? you will find a very interesting reason why you should use it. You can install GattTool by following steps:

1. wget https://www.kernel.org/pub/linux/bluetooth/bluez-5.24.tar.xz https://www.kernel.org/pub/linux/bluetooth/bluez-5.24.tar.xz --no-check-certificate

2. tar -xvf bluez-5.24.tar.xz

3. cd bluez-5.24

4. ./configure --disable-systemd --disable-udev

5. make

6. make install

You can learn about the functionalities of GattTool with BLE devices in:

http://joost.damad.be/2013/08/experiments-with-bluetooth-low-energy.html starlight: Experiments with Bluetooth Low Energy (4.0) under Linux

http://i-miss-erin.blogspot.com/2010/12/gatttool-in-bluez-over-bredr.html Reading, Writing and Arithmetic: gatttool in bluez over BR/EDR

http://sancho.ccd.uniroma2.it/cgi-bin/man/man2html?gatttool+1 Man page of GATTTOOL

Peter.

View solution in original post

5 Replies
Pedro_M_Intel
Employee
88 Views

Hello channinglin,

You can find a guide on how to run SPP-loopback.py in . Regarding how to copy the SPPloopback.py file to your board's file system, it's quite simple, follow these next steps:

1. Copy the whole content of SPP-loopback.py.

2. On your board's terminal enter the command: "vi SPP-loopback.py"

3. The vi environment will then appear, hit the "i" key to enter in edit mode.

4. Paste the content of SPP-loopback.py in vi (right button on your mouse when using PuTTY on Windows, from the terminal's settings when using screen on Linux)

5. Hit the escape button to exit the edit mode on vi and enter ": x".

Now the SPP-loopback.py script is stored on your board, you can now follow the guide I linked above.

Nevertheless, if you are using a BLE device, I suggest you to use GattTool instead of SPP. In https://devzone.nordicsemi.com/question/71/is-there-a-serial-port-profile-for-ble/ Is there a serial port profile for BLE? you will find a very interesting reason why you should use it. You can install GattTool by following steps:

1. wget https://www.kernel.org/pub/linux/bluetooth/bluez-5.24.tar.xz https://www.kernel.org/pub/linux/bluetooth/bluez-5.24.tar.xz --no-check-certificate

2. tar -xvf bluez-5.24.tar.xz

3. cd bluez-5.24

4. ./configure --disable-systemd --disable-udev

5. make

6. make install

You can learn about the functionalities of GattTool with BLE devices in:

http://joost.damad.be/2013/08/experiments-with-bluetooth-low-energy.html starlight: Experiments with Bluetooth Low Energy (4.0) under Linux

http://i-miss-erin.blogspot.com/2010/12/gatttool-in-bluez-over-bredr.html Reading, Writing and Arithmetic: gatttool in bluez over BR/EDR

http://sancho.ccd.uniroma2.it/cgi-bin/man/man2html?gatttool+1 Man page of GATTTOOL

Peter.

View solution in original post

CLin82
New Contributor I
87 Views

Hi Peter,

Thanks for your help, I will try it today and come back to you if I have further questions.

MMend9
New Contributor I
87 Views

If you really want to use SPP, this will get you there.

1. Use your favorite text editor to edit the file /etc/systemd/system/bluetooth.target.wants/bluetooth.service

2. Find the line that reads:

ExecStart=/usr/lib/bluez5/bluetooth/bluetoothd

3. Add -C to the end of it, so it reads:

ExecStart=/usr/lib/bluez5/bluetooth/bluetoothd -C

4. Save the file

5. Reboot the edison

6. If you have not paried your BT device with the Edison, do so now.

7. Set the Edison for BT SPP:

~# rfkill unblock bluetooth

~# sdptool add --channel=1 SP

~# rfcomm listen 0 1 2>&1 &

That's it.

Depending on how you have your Edison setup, you'll need to execute the 3 commands in step 7 every time the Edison boots up.

CLin82
New Contributor I
87 Views

Hi TwistedTrasistor,

What do you mean by "Use your favorite text editor to edit the file /etc/systemd/system/bluetooth.target.wants/bluetooth.service" ? Where is the bluetooth.service ?

MMend9
New Contributor I
87 Views

"bluetooth.service" is a file in the "/etc/systems/system/bluetooth.target.wants" directory in your Edison.

You need to edit that file to add the -C to the end of that line.

Reply