Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 3384

Turn on/off Intel(R) Edison Arduino on board LED via Bluetooth SPP by using the IoT dev kit

$
0
0

        Introduction

     This article explains how to set up IoT developer kit and enable Bluetooth SPP and make the Yocto application which getting data from buffer of the pipe which used by BT-DBUS API and control the GPIO to turn on / off LED in the Intel(R) Edison. As you do follow the step by step guide below, you may easily have set-up of the Intel(R) Edision Developer environment with Bluetooth as well as can understand well the Intel(R) Edison hardware and software.

This article based on 2 articles and 1 Intel Edison getting started example.

  • Connecting the Intel® Edison board to your Android* Phone with Serial Port Profile (SPP)

https://software.intel.com/en-us/articles/connecting-the-intel-edison-board-to-your-android-phone-with-serial-port-profile-spp\

  • Communicate to Arduino code with your Android* Phone by Bluetooth Serial Port Profile (SPP) on Intel® Edison

https://software.intel.com/en-us/blogs/2015/05/19/communicate-to-arduino-code-with-your-android-phone-by-bluetooth-serial-port

  • Blinking an LED with the Eclipse* IDE on the Intel® Edison board

https://software.intel.com/en-us/blinking-led-with-eclipse-ide-on-intel-edison-board

 

<fig. The structure of system with an application>

Prerequisite

  • Hardware
    • Laptop (Windows 7 or 8.1 is preferred)
    • Android Smartphone or Tablet with Android BT app (Bluetooth SPP tools pro)
    • Intel(R) Edison Arduino board
  • Install IoT Dev Kit (IDE -> Eclipse*) - If you don't have Intel Edison yet.

(1)        Go to the https://software.intel.com/iot/downloads

(2)        Please select Eclipse and Windows.

(3)        Unzip the iotdk-ide.win.7z

(4)        Run the devkit-launcher.bat (You may need to download JRE-64bit.)

(5)        Eclipse should be launched.

Step by step guide

1.Connect and assemble

More details: https://software.intel.com/en-us/assembling-intel-edison-board-with-arduino-expansion-board

2.Install Device Driver

https://software.intel.com/iot/hardware/edison/downloads

Windows Standalone Driver 1.2.1 (8.97 MB, .exe)

You need to check the installed device driver in your host PC with connected Intel(R) Edison.

3. Connect to your Intel® Edison board using Ethernet over USB

Please refer: https://software.intel.com/en-us/connecting-to-intel-edison-board-using-ethernet-over-usb

  • Create Target Connection (Ignore lib and target image update warning, if any.)

(1)   Run the devkit-launcher.bat

(2)   Select the ‘Create Target Connection’

(3)   Enter connection name: Edison / IP address: 192.168.2.15

(4)   Go to ‘Target SSH Connections’ and right click and select ‘Connect’

(5)   Wait a minute till connection.

(6)   You can launch terminal by right click in the ‘Target SSH Connections’

(7)   Login ID is ‘root’ , if needed.

 

4. Blinking an LED with the Eclipse* IDE on the Intel® Edison board

Please refer: https://software.intel.com/en-us/blinking-led-with-eclipse-ide-on-intel-edison-board

5. Enable Edison Bluetooth and SPP

 

(1)   Change Bluetooth device name

root@edison:~# rfkill list

root@edison:~# rfkill unblock Bluetooth

root@edison:~#bluetoothctl

[bluetooth]# scan on

[bluetooth]# discoverable on

[bluetooth]# exit

root@edison:~#vi /var/lib/bluetooth/XX:XX:XX:XX:XX:XX/settings

Add the line: Alias=MyName-edison

      

root@edison:~#shutdown –r now

 

(2)  Upload Python script of SPP test-profile via DBUS API

Run FTP client in the host PC with Host: 192.168.2.15 / Protocol: SFTP (SSH FTP).

Upload “SPP-pipe-out.py”.

(3) Add test-profile for SPP

root@edison:~# vi /etc/dbus-1/system.d/bluetooth.conf

If the bluetooth.conf file  doesn’t have the line <allow send_interface="org.bluez.Profile1"/>, add this line and save the file.

root@edison:~#shutdown –r now

(4)  Turning on and BT pairing (in the terminals)

root@edison:~# python SPP-pipe-out.py &

root@edison:~#rfkill unblock bluetooth

root@edison:~#bluetoothctl

[bluetooth]# show                 ← to make sure of the Serial Port Profile

[bluetooth]# scan on

[bluetooth]# pair 40:E2:30:21:64:18     ← enter the MAC of your android device

In Android device, select ‘pair’ in the pop-up.

[bluetooth]# discoverable on             ← to connect it in the Android

[bluetooth]# trust 40:E2:30:21:64:18     ← enter the MAC of your android device

 

(5) Run BT app in the Android device and connect by SPP

In Android device, run “bluetooth spp pro” → scan → select your edison → connect → CMD line mode

 

6. Intel(R) Edison BT SPP application

(1) Copy 2 files to your eclipse workspace ‘on board LED blinking C++’ application’s source folder. (e.g. \workspace\ble-spp-led-test1\src)

                          Intel_Edison_BT_SPP.cpp

                          Intel_Edison_BT_SPP.hpp 

(2) Press F5 (Refresh) in the Project Explorer of eclipse.

(3) Add and modify codes in your main() of  'LED blinking C++ applications' by referring the ble-spp-test.cpp.

                          ble-spp-test.cpp

 

7. Turn on / off on board LED via BT SPP from the Android device.

 

(1) Turn on and BT pairing / Run BT app → see the procedure “5. Enable Edison Bluetooth and SPP (4) and (5)” above.

(2) Build and run the BT SPP application in the eclipse. (Please make sure the connection of Edison in the Target SSH Connections of eclipse.)

(3) Send ‘on’ or ‘off’ in the BT SPP Pro of Android device and check the on board LED.

       

     

8. Terms 

SPPSerial Port Profile
DBUS    An inter-process communication protocol
GPIOGeneral purpose input/output

9. References

Intel(R) Edison Bluetooth Guide Document.

Connecting the Intel® Edison board to your Android* Phone with Serial Port Profile (SPP)

https://software.intel.com/en-us/articles/connecting-the-intel-edison-board-to-your-android-phone-with-serial-port-profile-spp\

Communicate to Arduino code with your Android* Phone by Bluetooth Serial Port Profile (SPP) on Intel® Edison

https://software.intel.com/en-us/blogs/2015/05/19/communicate-to-arduino-code-with-your-android-phone-by-bluetooth-serial-port

Blinking an LED with the Eclipse* IDE on the Intel® Edison board

https://software.intel.com/en-us/blinking-led-with-eclipse-ide-on-intel-edison-board

 


Viewing all articles
Browse latest Browse all 3384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>