Add Bluetooth to your Arduino Project

Maker Faire - May 17, 2014

Presented by Don Coleman / @doncoleman

Phone <===> Arduino


  #include <SoftwareSerial.h>

  #define RxD 6
  #define TxD 7

  SoftwareSerial bluetooth(RxD,TxD);
  int counter = 0;
					

  void setup() {
    Serial.begin(9600);
    bluetooth.begin(9600);
    Serial.println("Bluetooth Counter\n");
  }
	

  void loop() {
    Serial.println(counter);
    bluetooth.println(counter);
    counter++;
    delay(1000);
  }
	

Demo

Computer receives data from Arduino

Bluetooth Serial

PhoneGap Plugin

https://github.com/don/BluetoothSerial

Demo

Phone receives data from Arduino

Bluetooth Low Energy

aka Bluetooth Smart

BLE doesn't have SPP

but available hardware has "serial like" services

UART Service

  • RX - write without response
  • TX - read, notify

BLE hardware

c red, green, blue

c0,0,255\n


  #include <SoftwareSerial.h>
  // ...
  SoftwareSerial bluetooth(RxD,TxD);
  // ...
					
  void loop() {

    if (bluetooth.find("c")) {
      red = bluetooth.parseInt();
      green = bluetooth.parseInt();
      blue = bluetooth.parseInt();
      showColor(red, green, blue);
    }
  }
 void showColor(int r, int g, int b) {        
   uint32_t color = strip.Color(r, g, b);
   for (int i=0; i < strip.numPixels(); i++) {
     strip.setPixelColor(i, color);
   }
   strip.show();
 }

Demo

Phone controls LED strip on Arduino
Control NeoPixel LED on Arduino from Android

MAKE: PROJECTS Bluetooth Low Energy Lock

BLE Central

https://github.com/sandeepmistry/noble

BLE Peripheral

https://github.com/sandeepmistry/bleno

http://rfduino.com

RFduino Cordova Plugin

https://github.com/don/corodva-plugin-rfduino

Thank You

Don Coleman

@doncoleman

don@chariotsolutions.com

http://don.github.io/slides/

 

 

Creative Commons License
Add Bluetooth to your Ardunio Project by Don Coleman
is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Based on a work at https://github.com/don/.../2014-05-17-makerfaire-bluetooth.