Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/NicoLingg/Bluetooth-LE-Example
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
https://github.com/NicoLingg/Bluetooth-LE-Example
Last synced: 3 months ago
JSON representation
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
- Host: GitHub
- URL: https://github.com/NicoLingg/Bluetooth-LE-Example
- Owner: NicoLingg
- License: mit
- Created: 2016-12-13T15:00:06.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-03-05T15:16:44.000Z (8 months ago)
- Last Synced: 2024-06-24T01:39:57.700Z (5 months ago)
- Language: C++
- Size: 1.85 MB
- Stars: 26
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bluetooth-LE-Example with Qt GUI
![BluetoothLE](/BluetoothLE.jpg)
This example demonstrates how to use an Adafruit Bluefruit LE module to communicate with a custom Qt application via the UART service. In this example, an Arduino Uno is connected to Adafruit's Bluefruit LE UART Friend, along with a temperature and humidity sensor. The Arduino reads 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 of up to 21 characters (due to the BLE limitation) to the Arduino. This feature enables wireless control of the Arduino through the Qt app. In this example, we use it to turn on the built-in LED.
The Adafruit Bluefruit LE module includes the UART service, which automatically starts during power-up. Thus, no special setup is required to use it. The UUIDs are:
Base UUID: 6E400001-B5A3-F393-E0A9-E50E24DCCA9E
TX UUID: 6E400002-B5A3-F393-E0A9-E50E24DCCA9E
RX UUID: 6E400003-B5A3-F393-E0A9-E50E24DCCA9EFor more information on the UART service, visit:
- https://learn.adafruit.com/introducing-the-adafruit-bluefruit-le-uart-friend/uart-serviceFor additional information about Adafruit's BLE module, see:
- https://learn.adafruit.com/introducing-the-adafruit-bluefruit-le-uart-friend/introductionIf you are interested in learning more about Bluetooth LE, make sure to check the following links:
- https://en.wikipedia.org/wiki/Bluetooth_low_energy
- http://doc.qt.io/qt-5/qtbluetooth-le-overview.html
- https://www.bluetooth.com/
- https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=286439&_ga=1.161190325.907721094.1478372197
- https://www.csrsupport.com/download/49793/CS-327738-RP-2-Training%20and%20Tutorials%20-%20Introduction%20to%20Bluetooth%20Smart.pdf
- Robin Heydon at Bluetooth World 2013 - Bluetooth Low Energy Basics (available on youtube.com)### To use this example, you need:
1. Qt Creator (It 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 BreakoutYou can use a different sensor or no sensor at all and simulate temperature measurements by sending random numbers via Bluetooth to the Qt application.
Ensure you have installed QWTPlot correctly. QWTPlot can be found here:
- http://qwt.sourceforge.net/index.htmlIn the "Arduino" folder, you can find the Arduino sketch for this example. Please download and install the following Adafruit libraries:
- Adafruit_BluefruitLE_nRF51:
-- https://learn.adafruit.com/introducing-the-adafruit-bluefruit-spi-breakout/software
- Adafruit_SHT31:
-- https://learn.adafruit.com/adafruit-sht31-d-temperature-and-humidity-sensor-breakout/wiring-and-test### 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 | 12If you are using the SHT31, please see the pinout below:
SHT31 Sensor | Arduino Uno
--------------|------------
VIN | 5V
GND | GND
SCL | SCL
SDA | SDA### Step by Step Instructions
1. Download the "Bluetooth LE UART Example" repository.
2. Load the Arduino sketch onto your Arduino UNO and open the Serial Monitor.
3. Open the Qt Bluetooth LE application and turn on 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 measurements will start.
To disconnect, please close the application.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 the Arduino's built-in LED on and off. It essentially sends a string with "LED_ON," which the Arduino can interpret.
Please feel free to use the bluetoothuart class in your next BLE project. All you need to do is 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_qlDevicesSignals:
- changedState(): indicates the current state of the bluetooth module
- newData(QString): contains new data, which was sent by the ArduinoFunctions:
- writeData(QString s): Sends string “s” to the Bluetooth module************************************************************************
# Video
[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/qy3yA00mp0Q/0.jpg)](https://www.youtube.com/watch?v=qy3yA00mp0Q)
************************************************************************
# License
See the [LICENSE](LICENSE) file for license rights and limitations (MIT).