Giter Site home page Giter Site logo

kubark42 / bluetooth-le-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nicolingg/bluetooth-le-example

0.0 0.0 0.0 1.89 MB

This is an example how you can use an Adafruit Bluefruit LE module to communicate with your own written Qt application via the UART service

License: MIT License

QMake 1.21% C++ 93.35% C 5.44%

bluetooth-le-example's Introduction

Bluetooth-LE-Example

BluetoothLE

This is an example how you can use an Adafruit Bluefruit LE module to communicate with your own written Qt application via the UART service. In this example I use an Arduino Uno which is connected to Adafruit's Bluefruit LE UART Friend and a temperature and humidity sensor. The Arduino gets the temperature and humidity values from the sensor and sends them approximately every 3 seconds via Bluetooth LE to the Qt application which displays the values in a temperature and humidity plot. The app allows you to send a string up to 21 characters long (this is the limitation from BLE) to the Arduino. This allows you to control the Arduino wireless via the Qt-app. In this example we use it to turn on the built-in LED.

The Adafruit Bluefruit LE module comes with the UART service and it is automatically started during the power-up. This means you don't have to do anything special in order to use it. The UUID are:

Base UUID: 6E400001-B5A3-F393-E0A9-E50E24DCCA9E
TX UUID: 6E400002-B5A3-F393-E0A9-E50E24DCCA9E
RX UUID: 6E400003-B5A3-F393-E0A9-E50E24DCCA9E

More information on the UART service can be found here:
https://learn.adafruit.com/introducing-the-adafruit-bluefruit-le-uart-friend/uart-service

Additional information about Adafruit's BLE module here:
https://learn.adafruit.com/introducing-the-adafruit-bluefruit-le-uart-friend/introduction

And if you are interested in learning more about Bluetooth LE make sure you check the following links:

In order to use this example you need:

  1. Qt Creator (Linux should work on Windows but I haven't tested it)
  2. Arduino Uno
  3. Adafruit Bluefruit LE UART Friend (https://www.adafruit.com/products/2479)
  4. Adafruit SHT31-D Temperature & Humidity Sensor Breakout

Of course you can use a different sensor or no sensor at all and simulate a temperature measurement by sending random numbers via Bluetooth to the Qt application.

Please make sure you've installed QWTPlot correctly. QWTPlot can be found here: http://qwt.sourceforge.net/index.html

In the "Arduino" folder you can find the Arduino sketch for this example. Please download and install the two following Adafruit libraries:

Hardware Setup

For the UART Bluefruit LE UART board please use the following pinout:

Bluefruit LE UART Arduino Uno
VIN 3.3V
GND GND
RTS 8
RXI 9
TXO 10
CTS 11
MODE 12

If you are using the SHT31 please see pinout below:

SHT31 Sensor Arduino Uno
VIN 5V
GND GND
SCL SCL
SDA SDA

Step by Step Instructions

  1. Download "Bluetooth LE UART Example" repository
  2. Load Arduino sketch on your Arduino UNO and open the Serial Monitor
  3. Open Qt Bluetooth LE application and turn on the Bluetooth on your computer
  4. Press the search button and wait until the application finds the Adafruit Bluefriend
  5. If it finds something press connect, and the temperature and humidity measurement will start

To disconnect please close the application (a better way is on my TODO list!)

In the Qt app example you can send a string to your Arduino, which gets displayed in the IDE serial monitor (if you are connected to your computer). The "Turn LED on" button turns on/off the Arduino's built-in LED. It basically just sends a string with "LED_ON", which can be interpreted by the Arduino.

Please feel free to use the bluetoothuart class in your next BLE project. All you need to do is to connect the slot "startScan()", "startConnect()" and the signal "changedState(bluetoothleUART::bluetoothleState)" and "newData(QString)".

Slots: startScan(): starts searching for low energy devices startConnect(int i): starts connecting to the device i in QList m_qlDevices

Signals: changedState(): indicates the current state of the bluetooth module newData(QString): contains new data, which was sent by the Arduino

Functions: writeData(QString s): Sends string โ€œsโ€ to the Bluetooth module

Let me know if you have any questions!


Video

IMAGE ALT TEXT HERE


License

See the LICENSE file for license rights and limitations (MIT).

bluetooth-le-example's People

Contributors

kubark42 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.