I am developing an android app that fetches temperature from a bluetooth thermometer. I followed the instructions on the google developer page.
https://developer.android.com/guide/topics/connectivity/bluetooth-le.html
I could scan the devices and get connected to the thermometer. I am exactly using the same code from the following github.
https://github.com/googlesamples/android-BluetoothLeGatt/
Instead of using the the heart rate service and associated characteristics. I am using temperature service and the characteristic. I have changed these value on the following page that I downloaded from github
android-BluetoothLeGatt/Application/src/main/java/com/example/android/bluetoothlegatt/SampleGattAttributes.java
I using the following bluetooth thermometer.
http://www.cooper-atkins.com/Products/Blue2/
This is the API document I got from COOPER-ATKINS.
https://drive.google.com/open?id=1eq93Qc6uy0Vv9KompukLuIUnJK4B-e-0
In page 6 I have highlighted the service uuids and characteristic uuids I have replaced in the github code.
I could read the temperature data but only once. If the temperature changes I could not see the temperature value is refreshed in app automatically. I have to hit the temperature list button to get the recent value. Could anyone suggest what I am missing or doing wrong.
Please let me know if you need more info.
The characteristics you highlighted have both read and indicate property.
Reading the characteristic (Calling BluetoothGatt.readCharacteristic in Android) only obtains the value at that instant by definition.
You have to enable the indication to get every update of the value.
You can find how to enable a notification (not indication) on this SO thread. You can substitute the constant value to enable indication.
Related
The project I am currently working on involves a weight scale that has built-in BLE and my smartphone. The scale connects to the smartphone via BLE to send the current weight data to its app (I assume this is prioritized.) Although I can't figure out how to get the correct UUID to communicate with the scale in my own Android App as it doesn't seem to be using the standard GATT Services. The devices seem to use 0x2901, 0x2902...0x290X
Scale model: HNY200 (Color Black)
Link to scale: https://www.healthometernuyu.com/nuyu-products/scales/wireless-scale/HNY200KD.html
After using a BLE scanner on my phone I was able to determine the BLE Name for the device (Much like the SSID in a network) and the MAC Address. However, it also shows a long list of CUSTOM SERVICE and CUSTOM CHARACTERISTIC options each with Descriptors and their properties such as read and write. I would assume the data im searching for (The weight value) would come packaged in a CUSTOM CHARACTERISTIC with the properties including READ. After analyzing each individual one the value is either the exact same hexadecimal number each time or has no value at all. The ones with no value instead have "OTA_STATUS", "OTA_CMD", or "OTA_DATA" but does not reveal anything besides that.
BLE Scan of the device looking at the most interesting characteristics (but not all):
https://imgur.com/a/iHWDoSM
I currently dont have any code for the android app as I am just following along with the Android Developers Tutorial. However, in previous research, It seems as though I will need the correct UUID's as I might have to reverse engineer the protocol the scale is using to send prioritized data to its app. Some BLE scanners work to find the scale and some do not.
I expected one characteristic to reveal a value of the weight being displayed on the scale and instead I got very large hex values, nothing at all, or some string value such as "OTA_DATA".
I am making an Android app to receive data from Arduino(NRF24L01).
Arduino(NRF24L01) can send data only with Bluetooth device name.
So I get the value by putting the analog value in the BLEname.
Like this YouTube video.
https://youtu.be/F9yMTdcd33w?t=240
However, the Android application does not come back with the information of a device once it is already connected.
ex)
BLE Device name : "A=i" //(i=analog.value;)
first BLE SCAN -> find -> BLE Device name : "A=12"
I change i,(i=14;)
Second BLE SCAN -> find -> BLE Device name : "A=12"
why????????? i want "A=14"!!
Therefore, I would like to create an application that will continue to scan and retrieve device name information.
Is there any example I can refer to?
P.S I am sorry that I have not translated the translator and the context is not smooth.
You can refer this example for BLE scanning and connection or you can use customize as you want.
BleConnect
I'm developing an android app that reads data from Texas Instruments SensorTag CC2650.
I'm able to discover BLe device, connect to one of these and finally get battery value of the SensorTag. But I don't kow how get the value of temperature by the specific sensor.
For the battery I take the specific service next the characteristic and finally I run the command:
BluetoothGatt.readCharacteristic(...)
For temperature I've read that I have to turn on the sensor first, next I must enable the notification and finally I can get the value on the method onCharacteristicChanged of the callback.
Can someone give me the code for doing this?
I found this link to be very useful with the old SensorTag 1) http://evothings.com/quick-guide-to-making-a-mobile-app-for-the-ti-sensortag-using-javascript/
I have connected my android application with bluetooth OBD device. Now, on running commands like vehicle speed,rpm,ambient air temperature,I m getting the desired and right response but when I hit the distance command(0131\r) ,I am again getting the response NO DATA.
Please help me in solving this.
Unfortunately according to the SAE J1979 spec, vendor support for pretty much every single PID is optional. Commands, such as 0100\r\n give you an indication of which PIDs are theoretically supported by your vehicle, but whether an ECU will respond or not is completely vendor and vehicle dependent (and sometimes also depending on temporary/environmental conditions).
I a trying to understand and modify the BLE sample von Android.com, now I can discover my sample BLE Device (HTC Fetch) and now I want to understand all that GATT and BLE stuff.
What are Characteristics and what are Profile and what are Serivces and what do they mean in the Bluetooth Low Energy World? I used HTC Dev and found a Service and a Characteristics UUID.
https://www.htcdev.com/devcenter/opensense-sdk/bluetooth-smart/htc-fetch/
But I guess what I need is the Find Me Profile, cause for the first steps I only want to get the Find Me react to a Button click.
https://developer.bluetooth.org/gatt/profiles/Pages/ProfileViewer.aspx?u=org.bluetooth.profile.find_me.xml
How to implement this in my App?
When I understand everything I try Power and Proximity (reading RSSI and compare with defined range).
Can some one help me understanding Bluetooth LE?
Here's a related post
How to use the profile of PROXIMITY PROFILE,IMMEDIATE ALERT SERVICE and Find Me Profile in android 4.3 BLE?
Basically you can approximate a proximity level using tx+power - rssi or distance roughly with
d = (rssi-A)/-20 (where A = rssi at one meter) or simply use rssi mapping out ranges to display You could also initially base it on just the connection range and skip rssi.
As for the FindMe, simply write the low or high alert values to make it sound when you press a button in your app. For pressing a button on the device use the UUIDs shown in the documentation.
sample code for that device is forthcoming