hi ALL,
I have a SENSOR_TAG (http://store.linksprite.com/bluetooth-4 ... -nrf51822/), and wanted to know if anyone knew of some documentation for a beginner (a complete noob). I'd like to use a ESP32 to read the data from this TAG
I've looked into the example uPy bluetooth scripts, but the TAG has different details from a standard bluetooth device, like a temp sensor or a HR monitor, etc. I am not sure how to address this TAG - send a notify - connect to it or read the decode the data...
Here are links to images of LighBlue app details for the TAG -
https://ibb.co/0c3ghWj
https://ibb.co/rsNkYHL
I'd appreciate any help I can get.
Thanks
Tag
help with bluetooth esp32
Re: help with bluetooth esp32
One of the best ways to figure this stuff out is to try and connect to it with your phone using the "nRF Connect" app (available for iOS and Android).tagilux wrote: ↑Sun Sep 06, 2020 3:55 pmI've looked into the example uPy bluetooth scripts, but the TAG has different details from a standard bluetooth device, like a temp sensor or a HR monitor, etc. I am not sure how to address this TAG - send a notify - connect to it or read the decode the data...
Then you should be able to modify the "ble_temperature" example to set the correct UUIDs for the services/characteristics that the tag supports.
Re: help with bluetooth esp32
Agreed. Followed this post and downloaded the NRF Connect app. It is very helpful. However, how can you decode the Raw Data properly? It Is something like 0x1AFF4C0002150000000000.......2000DBF (UUID is 00000000-0000-0000-0000-000000000000 Major is 2, Minor is 13)
Most other libraries return something different like
Thank you very much for your help in advance.
Most other libraries return something different like
Code: Select all
04 3E 2B 02 01 02 01 **76 1E 3C BB 18 FE** 1F 03 19 00 00 02 01
04 02 0A FC 0D FF FF FF A1 A2 A3 A4 A5 A6 A7 A8 A9 B1 06 08
62 6C 75 65 79 E4
Re: help with bluetooth esp32
Ok I feel like I should help everyone who may visit this page in the future who are trying to read Ibeacons with their esp32.
If anyone needs help about specific parts of the implementation, feel free to reply to the post
For the raw data:
1: Decode the raw input data with
For the event handler, create a function like
The binary should now look something like #1aff4c0002150000000000000000000000000000000000020019bf
2: It is in binary string, turn it into string with
2.5:
check if it is an beacon by the first few digits? (1aff4c)'
3: get the uuid, major and minor out of them - concatenate the string
the uuid is position 13-44 so
For the major and minor, it is in 0-9, a-f so for every 16 values, it will move up 1 unit. (I reverse engineered it)
To decode this, do:
this will turn it into its original value
now you are officially done!
If anyone needs help about specific parts of the implementation, feel free to reply to the post
For the raw data:
1: Decode the raw input data with
Code: Select all
ubinascii.hexlify(advertise_data)
Code: Select all
def bt_irq(event, data):
if event == _IRQ_SCAN_RESULT:
#do something
#declare the event handler like this:
bluetooth.BLE().irq(handler=bt_irq)
2: It is in binary string, turn it into string with
Code: Select all
the_hexlified_raw_input.decode("utf-8")
check if it is an beacon by the first few digits? (1aff4c)'
3: get the uuid, major and minor out of them - concatenate the string
the uuid is position 13-44 so
Code: Select all
raw_string_input[12:44] #(python index starts from zero, includes the first digit and does not include the last digit)
To decode this, do:
Code: Select all
int(raw_string_input[x:x],16).
now you are officially done!
Re: help with bluetooth esp32
ok no its not that simple different beacons have different characters before the uuid. Will update when I have time. Obviously not the correct way to detect ibeacons as you can simply refer to the hex values but it works for me for now