Bluetooth Low Energy (BLE) Tutorial for Arduino Using BleuIO

by bleuio in Circuits > Arduino

5 Views, 0 Favorites, 0 Comments

Bluetooth Low Energy (BLE) Tutorial for Arduino Using BleuIO

arduino.jpg

The project is a simple example showcasing a quick way to setup an Arduino with a USB Host Shield as a USB CDC Host capable of communicating with the BleuIO Dongle.

When a BleuIO Dongle is connected to the USB port, the BleuIO Dongle will start advertising. It will then act as a terminal, taking input and sending data to the Arduino Virtual Com Port. We have used an Arduino Uno Rev. 3 with SparkFun’s USB Host Shield (DEV-09947) for this example.

Supplies

3.1 What you will need

  • A BleuIO dongle with firmware version 2.1.0 or later (https://www.bleuio.com/getting_started/docs/release_history/#release-v210)
  • An Arduino Uno Rev. 3 (https://store.arduino.cc/products/arduino-uno-rev3)
  • A USB Host Shield (https://www.sparkfun.com/products/9947)
  • The Arduino IDE (https://www.arduino.cc/en/software)
  • Host USB shield library 2.03.2

Requirments for the SparkFun board

  • With the SparkFun board, it seems like you MUST supply external power on Vin or the barrel jack. 5V from the USB cable did not work.
  • You must also apply a jumper from pin D7 to RESET.

About the Code

amc_example.png

You can get project HERE

https://github.com/smart-sensor-devices-ab/arduino...

project based on the ‘acm_terminal’ example in the Host USB Shield Library 2.0

The largest possible max.packet size for the function Acm.RcvData() is 64 bytes, so to accommodate the amount of data we will receive, we are using three buffers to receive the data from the BleuIO Dongle.


If the buffers have received any data, we print it out to the serial terminal connected to the Virtual COM Port.

We also store the latest data from the dongle into the dongle_input buffer and run it through a simple “parser” to showcase an easy way of how you can react to events and have the Arduino do something.


In this example, we are explicitly looking for BLE connection or disconnect events. When found, we just print out “<>” or “<>” to the terminal.

How to Setup Project

manage_lib.png
install_lib.png

Downloading the project from GitHub

Get project HERE

https://github.com/smart-sensor-devices-ab/arduino...

clone the project, or

download it as a zip file and unzip it, into your Arduino folder.

Downloading the USB Host Shield Library 2.0
Either download the Library from Here (https://felis.github.io/USB_Host_Shield_2.0/) and place the folder into your libraries folder inside your Arduino folder. (For information on installing libraries, see: http://www.arduino.cc/en/Guide/Libraries)

Or download it through the Arduino IDE:

In Arduino IDE choose Sketch>Include Library>Manage Library

Search for USB Host Shield Library 2.0 and click ‘Install’

Running the Example

upload.png
serial_monitor.png
start.png

  • In Arduino IDE click the upload button to upload the project to your Arduino.
  • Open up the ‘Arduino Uno Viritual COM Port’ with a serial terminal emulation program like TeraTerm, Putty or CoolTerm.Serial port Setup:
    Baudrate: 115200
    Data Bits: 8
    Parity: None
    Stop Bits: 1
    Flow Control: None
  • Or inside the Arduino IDE open up Arduino Monitor and in the bottom right corner select ‘Carriage Return’ and ‘115200 baud’
  • You should see the word ‘Start’ and then see the dongle running two commands: setting response data and starting the advertising. You can now type commands to the dongle.