Giter VIP home page Giter VIP logo

bluetoothlechat's Introduction

BLE Chat

This Android App works with a HM-10 BLE module. It can be used for communication between an Android device and a microcontroller.

It has been tested on a Galaxy SIII and a HM-10 module hooked up to an Arduino UNO..

See the HM-10 datasheet for the correct pinout. The tested module had:

PIN 1 => ARDUINO 0 (RX), PIN 2 => ARDUINO 1 (TX), PIN 12 => 3.3V, PIN 13 => GND PIN 23 => LED +.

There was also a 0.1uF capacitor between VCC and ground and a 470 OHM resistor between PIN 23 and the LED.

There seems to be a 21 character (20 characters plus a newline) limit on serial data, at least on the firmware tested. The app limits data input to 20 characters.

There is a text field and a SEND button to send data and a list that displays data coming in via serial, similar to the Google standard Bluetooth Chat sample app.

This code is a slightly modified version of the BT4LEDTest app written by danasf available here: https://github.com/danasf/hm10-android-arduino

That code was based on the Google BLE example called BluetoothLeGatt available here: https://developer.android.com/samples/BluetoothLeGatt/index.html

Below is an Arduino sketch that will echo characters from the serial port that can be used to test BLE Chat.

/* BLE_echo

Test a serial connection to a HM-10
BLE module by reading incoming data
and writing it back out the serial
port.

*/

const int BUFF_LEN = 21; // serial buffer length

char sBuff[BUFF_LEN]; // serial buffer

void setup() { Serial.begin(9600); // open serial port

Serial.setTimeout(20); // timeout defaults to 1000 ms

}

void loop() {

// while bytes available ; if( Serial.available() ) { // read into buffer int bytesRead = Serial.readBytes(sBuff, BUFF_LEN);

// echo read bytes to serial port
for(int i=0; i < bytesRead; i++) Serial.write(sBuff[i]);

} // if

}

bluetoothlechat's People

Watchers

James Cloos avatar Eric Li avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.