BLEDUINO

From ElecFreaks
Jump to: navigation, search

Introduction

It's time to get Bluetooth 4.0 into your project, together with your phone! For aficionados of smart devices and wearables, now you can go further than hacking things bought in the market to building your own prototype out of garage. The BLEduino - BLE For Aruino board is first of its kind in intergrating BT 4.0(BLE) module into Arduino Uno, making it an ideal prototyping platform for both software and hardware developers to go wireless. You will be able to develope your own smart bracelet,smart pedometer and more. Through the low- power Bluetooth 4.0 technology, real-time low energy communication can be made really easy. The BLEduino integrates with a TI CC2540 BT 4.0 chip with the Arduino UNO development board. It allows wireless programming via BLE, supports Bluetooth HID, supports AT command to config the BLE, and you can upgrade BLE firmware easily. The BLEduino is also compatible with all Arduino Uno pins which means any project made with Uno can directly go wireless! Whatsmore, we also developed the App for the BLEduino (both Android and IOS), and they are completely opensource, so that you can modify and develope your own BLE-hardware platform. Below is a quick demo video covering some of the major features of BLEduino with the help of an Accessory Shield for BLEduino, which will also be available very soon. In short, you can use BLEduino with any Bluetooth 4.0 compatible devices and enjoy features such as wireless transmission, master and slave settings, wireless burning, and even establishing a Bluetooth HID connection with the PC

Model: EF01021

BLEDUINO E.JPG BLEDUINO F.JPG BLEDUINO G.JPG

Feature

  • On-board BLE chip: TI CC2540
  • Transmission range: more than 70m
  • Support Bluetooth HID
  • Support iBeacons
  • Support AT command to config the BLE
  • Transparent communication through Serial
  • master-slave one, arbitrary switching
  • Easy to use BLE firmware updating
  • Microcontroller: Atmega328
  • Bootloader: Arduino Uno
  • Compatible with the Arduino Uno pin mapping
  • Immersion Gold Technology
  • DC Supply: USB Powered or External 7V~12V DC
  • Size: 85mm*53mm

Note

For the demo application and arduino code, we integrated elecfreaks wireless libraries for the beginners. The idea is supplying a simple way for you to use wireless modules without learning the wireless comunication protocol.However, for the developer, recommend to custom or choose the protocol according to the product features or the application.


Application

  • POS system, Bluetooth keyboard, Mouse, Gamepad
  • Industrial remote control, telemetry
  • Automotive testing equipment
  • Portable, battery-powered medical equipment
  • Automated data collection
  • Bluetooth remote control toys
  • Wireless LED Display System between devices.
  • Bluetooth Printer
  • Smart home, industrial control

Electronic Properties

BLEDUINO H.jpg

Pining information

BLEDUINO I.jpg


BLEDUINO J.jpg

Specification

Interface description

BLEDUINO K.jpg


Dimension

BLEDUINO L.jpg


1. Hardware and Software Preparation

Bleduino1.png


Hardware:


Software:

  • 1.Arduino IDE
  • 2.APP:BLECenter(you can download it on app store or google play)
  • 3.Serial port debugging software(sscom32E)

2. Application

Part 1 BLEduino USB Programming

Step 1 Hardware preparation

Connect the BLEduino to the PC via USB cable


Step 2 Install the driver

When connected to the computer, the computer will prompt to install driver, follow the prompts to install it( the way to install the driver is the same with Arduino UNO and the Driver Name is TI CC2540 Drivers).


BLEDUINO N.jpg


Step3 Programming

1. Open the program we need to upload with Arduino IDE, and then choose the Board of Arduino UNO, in addition, the corresponding Serial Port.


BLEDUINO O.jpg


BLEDUINO P.jpg


2.Compiling sketch until Done compiling appears

3.Uploading sketch until Done uploading appears(when uploading, TX, RX LED will be blinking)


Note: When USB programming, BLEduino had to disconnect with other Bluetooth, and the LINK LED will be twinkling when the Bluetooth is disconnected.


BLEDUINO Q.jpg

Part 2 BLEduino Wireless Programming

Step 1 Hardware preparation

Prepared BLEduino, BLE Adapter and USB Cable


Step 2 Host searched slave and then connected to Slave

Connect the BLE Adapter(Defaulted as host),BLEduino(Defaulted as Slave)to the computer.Via serial port debugging software, open the serial port of host and Slave,and then host send AT SCAN+ Enter to search Slave,just as the following screenshot shows


BLEDUINO R.jpg


After the host searched the Slave, the host send AT CON 1 + Enter to connect the Slave, and the Slave can get the host Return Value of connected if connection is successful,at the same time, BLEduino link LED will stop blinking and be always lit.


BLEDUINO S.jpg


Step 3 BLE Adapter(host) Programming for BLEduino(Slave)

After the host connected to Slave,open the program need to be uploaded via Arduino IDE, choose the corresponding Board of UNO,choose the BLE Adapter (host) Serial Port, and then the specific operating steps are the same with USB programming, which has been introduced in detail previously.

Part 3 Mobile APP Control BLEduino

Notice:Before Mobile control BLEDuino you must confirm you Mobile APP support BLE4.0,If the hardware meets the requirements,you must install BLECenter APP into your mobile phone,you can Download this app in app store or google play.

BLECenter control BLE Development Shield by BLEDuino

  • 1.Download BLEDuino Data package
 Download BLEDuino Data  package,such as BLEShield Library、PlainProtocol library、U8glib library and so on,Put this Library into Arduino IDE Libraries directory.
  • 2.Compile and upload BLEShield Demo into BLEDuino
 uncompression BLEDuino Compression package,Open BLEShield_Demo directory files via Arduino IDE,program the firmware to BLEduino MCU with USB, as well as step with previous USB programming.
  • 3.Open BLECenter and click BLEShield Icon

Notic:before open BLECenter APP you must open mobile bluetooth and power on BLEDuino board

 Open BLECenter and click BLEShield Icon,the app will jump BLEShield page,The specific page is as follows:

Bleshield3.png Bleshield4.png

  • 4.Control of each function
 *1.Control Buzzer
     Click BLEShield page Buzzer Button,if the button turn green that the buzzer sounds,if the button turn gray that the buzzer stop sound

Bleshield4.png Bleshield5.png

 *2.Control Relay
     Click BLEShield page Relay Button,if the button turn green that the Relay close and light turn on,if the button turn gray that the Relay open and the  light turn off.

Bleshield4.png Bleshield6.png

Bleshield8.png Bleshield7.png

 *3.RGB Control
    Click color plate Center,the page color plate will change ON image and the RGB light will turn on of the BLE Development Shield,Drag the small ring in the color plate can change the color of the RGB.

Bleshield9.png Bleshield10.png

*4.Joystick Control
   Click BLEShield page's Joystick Button,this page will display joystick Image,Drag the rocker of the BLE Development Shield board,the BLEShield  small ball will movement when the rocker have Draged.

Bleshield15.pngBleshield11.png

Bleshield16.pngBleshield12.png

Bleshield17.pngBleshield13.png

Bleshield18.pngBleshield14.png

  • 5.OLED Control
 Slide the upper part of the BLEShield page will display the OLED control box, enter the data in the input box, click on the send button to display the contents of the OLED screen

Bleshield19.png Bleshield20.png

  • 6.BLEShield Demo Code
#include <BLEShield.h>
#include "Arduino.h"
#include "PlainProtocol.h"
#include "U8glib.h"


#define RIGHT 1
#define UP 2
#define LEFT 3
#define DOWN 4
#define PUSH 5
#define MID 0

//PlainProtocol constructor, define the Serial port and the baudrate.
PlainProtocol myBLEDUINO(Serial,115200);

//BLEShield constructor, for setting the relay,buzzer, temperature, humidity, knob, joystick and RGBLED
BLEShield myBLEShield;

//OLED constructor, for oled display
U8GLIB_SSD1306_128X64 myOled(U8G_I2C_OPT_NONE);

String oledDisplay="";      //the display string recieved from the mobile device

int humidity=0;             //humidity read from DHT11
int temperature=0;          //temperature read from DHT11

int ledRed=0;               //RGBLED red value
int ledGreen=0;             //RGBLED green value
int ledBlue=0;              //RGBLED blue value

int knob=0;                 //knob(potentiometer) value read from analog pin

int joyStick=0;             //joystick state




void setup() {
    myBLEShield.begin();
    myBLEDUINO.init();
    myBLEShield.setRGBLed(0,0,0);   //turn off the RGBLED
}


void draw (void)
{
    myOled.setFont(u8g_font_unifont);
    
    myOled.setPrintPos(10,16);      //set the print position
    myOled.print("H:");
    myOled.print(humidity);         //show the humidity on oled
    myOled.print("%");
    
    myOled.setPrintPos(10,32);
    myOled.print("T:");             //show the temperature on oled
    myOled.print(temperature);
    myOled.print("C");
    
    myOled.setPrintPos(88,16);
    myOled.print("R:");             //show RGBLED red value
    myOled.print(ledRed);
    myOled.setPrintPos(88,32);
    myOled.print("G:");             //show RGBLED green value
    myOled.print(ledGreen);
    myOled.setPrintPos(88,48);
    myOled.print("B:");             //show RGBLED blue value
    myOled.print(ledBlue);

    myOled.setPrintPos(10,48);
    myOled.print("K_State:");
    myOled.print(knob);             //show knob(potentiometer) value read from analog pin
   
    myOled.setPrintPos(10,60);
    if (oledDisplay.length()) {
        myOled.print(oledDisplay);  //if the display string recieved from the mobile device, show the string
    }
    else{
        myOled.print("Joystick:");  //if string is null, show the state of joystick
        switch (joyStick){
            case MID:
                myOled.print("Normal");
                break;
            case RIGHT:
                myOled.print("Right");
                break;
            case UP:
                myOled.print("Up");
                break;
            case LEFT:
                myOled.print("Left");
                break;
            case DOWN:
                myOled.print("Down");
                break;
            case PUSH:
                myOled.print("Push");
                break;
            default:
                break;
        }
    }
}


void loop()
{
    if (myBLEDUINO.available()) {    //receive valid command
        if (myBLEDUINO.equals("BUZZER")) {     //if the command name is "BUZZER"
            myBLEShield.setBuzzer(myBLEDUINO.read());  //read the content and set the buzzer
        }
        else if (myBLEDUINO.equals("RELAY")){      //if the command name is "RELAY"
            myBLEShield.setRelay(myBLEDUINO.read());   //read the content and set the relay
        }
        else if (myBLEDUINO.equals("DISP")){       //if the command name is "DISP"
            oledDisplay=myBLEDUINO.readString();   //read the string to local value
        }
        else if(myBLEDUINO.equals("RGBLED")){      //if the command name is "RGBLED"
            ledRed=myBLEDUINO.read();              //read the red value first
            ledGreen=myBLEDUINO.read();            //read the green value then
            ledBlue=myBLEDUINO.read();             //read the blue value at last
            
            myBLEShield.setRGBLed(ledRed, ledGreen, ledBlue);   //set the color to the RGBLED
            }
        else if(myBLEDUINO.equals("TEMP")){    //if the command name is "TEMP"
            myBLEDUINO.write("TEMP", temperature);     //return the value of temperature to mobile device
            }
        else if(myBLEDUINO.equals("HUMID")){   //if the command name is "HUMID"
            myBLEDUINO.write("HUMID", humidity);   //return the value of humidity to mobile device
            }
        else if(myBLEDUINO.equals("JOY")){    //if the command name is "JOY"
           // myBLEDUINO.write("JOY", myBLEShield.readKnob());  //return the value of the knob(potentiometer) to mobile device
           myBLEDUINO.write("JOY",myBLEShield.readJoystick_x(),myBLEShield.readJoystick_y());
            }
    }
    
    static unsigned long oledTimer=millis();        //every 200ms update the oled display
    if (millis() - oledTimer >= 200) {
        oledTimer=millis();
        myOled.firstPage();                         //for more information about the U8glib library, go to https://code.google.com/p/u8glib/
        do{
            draw();
        }
        while(myOled.nextPage());
    }
    
    static unsigned long DHT11Timer=millis();       //every 2s update the temperature and humidity from DHT11 sensor
    if (millis() - DHT11Timer >= 2000) {
        DHT11Timer=millis();
        temperature=myBLEShield.readTemperature();
        humidity=myBLEShield.readHumidity();
    }
    
    static unsigned long Timer500ms=millis();       //every 500ms update the knob(potentiometer) and the joystick
    if (millis() - Timer500ms >= 500) {
        Timer500ms=millis();
//        knob=myBLEShield.readKnob();
        knob=myBLEShield.ReadDigital(Key_Pin);
        joyStick=myBLEShield.readJoystick();
    }
    
    if (myBLEShield.joystickAvailable()) {          //if the state of joystick is changed
        joyStick=myBLEShield.readJoystick();        //update the joystick
//        myBLEShield.write("ROCKER", joyStick);          //send the command and value to mobile device
        oledDisplay="";                             //clear the oled display string to show the new state of joystick on oled
    }
}

LED of BLECenter tutorial

  • 1.Compile and upload LED_Demo into BLEDuino
 uncompression BLEDuino Compression package,Open Led_Demo directory files via Arduino IDE,program the firmware to BLEduino MCU with USB, as well as step with previous USB programming.
  • 2. Open BLECenter and click LED Icon
  Open BLECenter app,click LED icon will jump LED page,page detail as follow:

Led1.png


  • 3.Click led Button control Led
  Click every pin one to one correspondence button,BLEDuino wiring Led will turn on,if you click go on the led will turn off

Led2.pngLed4.png

Led1.pngLed3.png

Notic:there are use one pin as demo,you can use this page control every pin out high or low level

  • 4 Led Demo Code
#include <PlainProtocol.h>
#include "Arduino.h"

//PlainProtocol constructor, define the Serial port and the baudrate.
PlainProtocol myBLEDUINO(Serial,115200);

int led_pin = 0;
int led_state = 0;
int led_value = 0;
void setup() {
    myBLEDUINO.init();
}

void loop() {
  if(myBLEDUINO.available()) { //receive valid command 
    if(myBLEDUINO.equals("LED")) {
      //read led data
      led_pin = myBLEDUINO.read();
      led_state = myBLEDUINO.read();
      led_value = myBLEDUINO.read();
      pinMode(led_pin,OUTPUT);
      digitalWrite(led_pin,led_value);
    }
  }
}

Relay of BLECenter tutorial

  • 1.Compile and upload LED_Demo into BLEDuino
 uncompression BLEDuino Compression package,Open Relay_Demo directory files via Arduino IDE,program the firmware to BLEduino MCU with USB, as well as step with previous USB programming.
  • 2. Open BLECenter and click Relay Icon
  Open BLECenter app,click Relay icon will jump Relay page,page detail as follow:

Relay1.png


  • 3.Drag OFF or ON Icon control Relay
  Drag OFF or On icon control Relay of the BLE Development Shield board ,when the relay closed the led will turn on,when the relay open the led will turn off.

Relay3.pngRelay2.png

Relay1.pngLed3.png

Notic:APP controll relay pin not change

  • 4.Relay Demo code
#include <PlainProtocol.h>
#include "Arduino.h"

//PlainProtocol constructor, define the Serial port and the baudrate.
PlainProtocol myBLEDUINO(Serial,115200);

int relay_pin = 0;
int relay_state = 0;
int relay_value = 0;
void setup() {
    myBLEDUINO.init();
}

void loop() {
  if(myBLEDUINO.available()) { //receive valid command 
    if(myBLEDUINO.equals("POWER")) {
      //read led data
      relay_pin = myBLEDUINO.read();
      relay_state = myBLEDUINO.read();
      relay_value = myBLEDUINO.read();
      pinMode(relay_pin,OUTPUT);
      digitalWrite(relay_pin,relay_value);
    }
  }
}

BLEDuino of BLECenter tutorial

Notice:this Demo Code can set Arduino output or input,Analog input,pwm output.

  • 1.Compile and upload BLEDuino_Demo into BLEDuino
 uncompression BLEDuino Compression package,Open BLEDuino_Demo directory files via Arduino IDE,program the firmware to BLEduino MCU with USB, as well as step with previous USB programming.
  • 2. Open BLECenter and click BLEDuino Icon
  Open BLECenter app,click BLEDuino icon will jump BLEDuino page,page detail as follow:

Bleduino2.png


  • 3.Digital IO port output test
  click subscript Digital-Out.Digital-In Items,then  the page will show a select windows,select Digital-Out items,then  a switch button will display on the right in the select Items,such as follow:

Bleduino3.pngBleduino4.pngBleduino5.pngBleduino6.png

ALL of this pin support Digital out,if this wiring a led,you can control the led by click the swtich button

  • 4.Digital IO port input test
  click subscript Digital-Out.Digital-In Items,then  the page will show a select windows,select Digital-In items,then the left will display "1" or "0" on the right in the select Items,such as follow:

Bleduino3.pngBleduino7.pngBleduino8.png

ALL of this pin support Digital In,you read IO port level

  • 4.Pwm test
 click subscript Digital-Out.Digital-In Items,then  the page will show a select windows,select Digital-In items,then the left will display "1" or "0" on the right in the select Items,such as follow:

Bleduino9.pngBleduino10.pngBleduino11.png Bleduino12.pngBleduino13.pngBleduino14.png

Notice:According this step only set once,if you want set another value,you must set again

  • 5.Analog test
 click subscript Digital-Out.Digital-In Items.Analog,then  the page will show a select windows,select Analog items,then the left will display 0-1024 on the right in the select Items,such as follow:

Bleduino15.pngBleduino16.pngBleduino17.png


Notice:According this step only read once,if you want get again ,please repeat again value

  • 6.BLEDuino Demo Code
#include <PlainProtocol.h>

//PlainProtocol constructor, define the Serial port and the baudrate.
PlainProtocol myBLEDUINO(Serial,115200);

#define WRITE_DIGITAL 0
#define READ_DIGITAL 1
#define READ_ANALOG 2
#define WRITE_PWM 3

uint8_t pin_num;
uint8_t pin_state;
uint8_t pin_value;

void setup() {
  myBLEDUINO.init();
}

void loop() {
  if(myBLEDUINO.available()) {
    if(myBLEDUINO.equals("BLEDUINO")) {
      //read led data
      pin_num = myBLEDUINO.read();
      pin_state = myBLEDUINO.read();
      pin_value = myBLEDUINO.read();
      
      switch(pin_state) {
        case WRITE_DIGITAL:
          write_digital(pin_num,pin_value);
        break;
        case READ_DIGITAL:
          read_digital(pin_num);
        break;
        case WRITE_PWM:
          write_pwm(pin_num,pin_value);
        break;
        case READ_ANALOG:
          read_analog(pin_num);
          break;
      }
    }
  }
}

void write_digital(uint8_t _pin_num,uint8_t _pin_value) {
  pinMode(_pin_num,OUTPUT);
  digitalWrite(_pin_num,_pin_value);
}

void read_digital(uint8_t _pin_num) {
  pinMode(_pin_num, OUTPUT);
  digitalWrite(_pin_num,LOW);
  pinMode(_pin_num,INPUT);
  byte value[4];
  value[0] = _pin_num;
  value[1] = READ_DIGITAL;
  value[2] = 0;
  value[3] = digitalRead(_pin_num);
  myBLEDUINO.write("BLEDUINO",value[0],value[1],value[2],value[3]);
}

void write_pwm(uint8_t _pin_num,uint8_t _pin_value) {
  pinMode(_pin_num,OUTPUT);
  analogWrite(_pin_num,_pin_value);
}

void read_analog(uint8_t _pin_num) {
  pinMode(_pin_num,OUTPUT);
  digitalWrite(_pin_num,LOW);
  pinMode(_pin_num,INPUT);
  int value = analogRead(_pin_num);
  uint8_t byte_one = (value & 0xFF00) >> 8;
  uint8_t byte_two = value & 0xFF;
  uint8_t packet_to_send[4];
  packet_to_send[0] = _pin_num;
  packet_to_send[1] = READ_ANALOG;
  packet_to_send[2] = byte_one;
  packet_to_send[3] = byte_two;
  //send to bluetooth
  myBLEDUINO.write("BLEDUINO",packet_to_send[0],packet_to_send[1],packet_to_send[2],packet_to_send[3]);
}

Part 4 AT Command description

  • 1. AT   // Test command,if send ok,the ble Adapter will response OK.
  • 2. AT+VERSION  // Get the BLE Adapter FirmWare,Response form:+VERSION=V*.*.
  • 3. AT+HELP // View, How many commands are support in the BLE Adapter.
  • 4. AT+NAME // this command main Get/Set BLE Adapter display name.
  • 5. AT+BAUD // View, Get/Set work Baud rate.
  • 6. AT+RENEW  // Restore factory settings.
  • 7. AT+ROLE // Get/Set work role(Central or Peripheral).
  • 8. AT+SCAN // Scan Peripheral,if you want this command,you must set BLE Adapter work Central mode.
  • 9. AT+CON // Connect Peripheral device,this mainly use for central.
  • 10.AT+MYMAC //Get current Device MAC Address.
  • 11.AT+TRANSMODE //Get/Set Transmit mode

Notice:If you want learn more,please Download the detailed AT Command document.

Version Tracker

Revision Descriptions Release
v0.9b Initial public release date

Bug Tracker

Bug Tracker is the place you can publish any bugs you think you might have found during use. Please write down what you have to say, your answers will help us improve our products.

Additional Idea

The Additional Idea is the place to write your project ideas about this product, or other usages you've found. Or you can write them on Projects page.

Resources

How to buy

Click here to buy:

http://www.elecfreaks.com/estore/bleduino-ble-for-arduino.html

See Also

Other related products and resources.

Licensing

This documentation is licensed under the Creative Commons Attribution-ShareAlike License 3.0 Source code and libraries are licensed under GPL/LGPL, see source code files for details.

External Links

Links to external webpages which provide more application ideas, documents/datasheet or software libraries