Bluetooth Low Energy Transmits but does not Receive

BLE receive is working!

If anyone is using the standard ESP32 libraries on Arduino IDE or the BLE DEMO instructable written for Thunkable Classic the key is to add property_read to the BLECharectoristics.

See in between ** ** bellow. Was working immediately!

Off a standard timer on Thunkable. Admittedly the BLE receive should probably be an event block

pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID_TX,
BLECharacteristic::PROPERTY_NOTIFY**|BLECharacteristic::PROPERTY_READ**
);

Kind Regards Rich

2 Likes

Thatā€™s great! Iā€™m trying to get a reading from a BLE temperature probe thermometer. I donā€™t know programming, so Iā€™m not sure where the stuff between the ** ** goes in the blocks. Can you explain a little to someone like me?? :slight_smile:

Any help is greatly appreciated!!

Hi Pittsgsal,

This code (The bits between ** **) is for an Espressif esp32 (Like an arduino). It was a way for the Arduino to speak/communicate with thunkable.

This will not help you much with your Bluetooth Thermocouple I am afraid.

You could get temperature sensor for an arduino or esp32 and use the BLE Arduino template and the above extra snippet to transmit the information to thunkable.

Here a common sensors, most also have code ready to go so should only be a bit of studying and copy and paste to get it to work

Cheers Rich

Cheers, Rich!

Iā€™m really at a loss as to how to get this working, as I have an API that explains it, but I just donā€™t have the skills to get the correct info in the blocks, or to even enter something extra that need to be in there to make it work. It supposedly will act like a GATT Server. All the Characteristic numbers are in the doc, and I set Global variables. Iā€™m attaching a pic of the ā€œmeatā€ of the API in case you can magically think of a way to get a temperature from itā€¦ :slight_smile:

Looks like you just need to get the UUID, write that to the string outside the above code block and see what data you get and look for the float between byte 2 and 5.

If the documentation doesnā€™t specify the UUID Google how to find low energy Bluetooth UUID from Charectoristic. Might be easier to connect to it via a laptop find it that way.

You obviously need to connect when the page opens and all thatā€¦ excuse the screen shots just on phone.

I can absolutely connect with no issues. Works great!
The issue comes when Iā€™m looking for a reading from the thermometer. I try to show it in a Label, but it wonā€™t show a temp. I assume that it doesnā€™t KNOW that itā€™s Little Endian, and canā€™t figure out what to do with the gibberish it gets.

You have done all the work already! You may be stuck if you cannot change the device property from notify to read. Its will show as undefined. If you have an old thunkable classic account you can do it easily there.

I guess you might need program it properly not blockely or down a more DIY route with an arduino and sensors. Give you plenty of options too.

If you by some remote chance figure a way. I know the community will be keen to know.

Good luck!

Thanks for the help, Rich! Iā€™m going to keep trying!! Maybe I can figure a way to get an old accountā€¦ lol!

Mike

But if you CAN get read the bytes into text (even if its HEX or ascii) you can use the text code blocks to extract the bytes and convert them.

Using length blocks, Trim then if HEX = hex hex = ascii equivalent

Then use math boxes to add them the right order and store them to a variable then to a label.

@pittsgal That Temperature Measurement appears to be in hexadecimal. I used an online converter to convert 0x2A1C to decimal and got 10780. Perhaps you tried that, too. I knew we could ignore the 0x after reading the article I link to below but I wasnā€™t sure about the rest of the value.

So it seems we need some more information about the type of value that is being output as temperature.

And there is some in the information you posted (I tried to find the API documentation you mentioned but couldnā€™t. Is it available online?).

ā€œByte 1 contains the flag field.ā€ This helps us know if the temperature is in Ā°C or Ā°F but it doesnā€™t affect the actual value of the temperature.

According to the article below, each hexadecimal digit maps to 4 bits (4 binary digits). A byte is eight binary digits or two hexadecimal digits. So Byte 1 consists of the first two hexadecimal digits, ā€œ1C.ā€ So we can ignore those for now.

ā€œByte 2 to 5 is a 4 byte float representing the temperature readingā€¦ā€ Now weā€™re getting somewhere!

If we take Byte 2 to 5 as a single value, we need to evaluate ā€œ2A.ā€ Because thatā€™s all that remains after we remove the 0x prefix and Byte 1 ā€œ1C.ā€

And 2A in hexadecimal converts to 42 in decimal. So the answer is 42 degrees! Woo hoo! But wait, is that 42Ā°F or 42Ā°C? Probably if youā€™re measuring the temperature at home with the physical device, you already know the answer. But if you need help with parsing the value from Byte 1, I could take a crack at that, too.

Mind you, I just figured this out and Iā€™ve never worked with hexadecimal. So even though I feel pretty good about the chances that 42Ā° is correct, you might want someone else to double-check my assumptions.

I found this useful: Hexadecimal - learn.sparkfun.com, especially the part titled " Hex-to-Decimal Example: Convert 0xC0DE" and the couple of sections below that. Also, I had to read this to understand that in ā€œlittle endian,ā€ bytes are read from right to left: Is binary code read from right to left? - Quora.

Edit: I canā€™t leave well enough alone when it comes to learning more about coding! Byte 1ā€™s value of 1C in hexadecimal equals 00011100 in binary. Thatā€™s eight bits: 0, 0, 0, 1, 1, 1, 0, and 0. According to what you posted above, ā€œBit 0 [is the] Temperature scale.ā€ So if we look at bit 0, the value is 0 ā€“ Iā€™m pretty sure thatā€™s the right-most value. So this temperature is in Celsius (a value of 1 would indicate Fahrenheit). I hope Iā€™m right! :smiley:

To contextualize, Iā€™m going to say youā€™re probably measuring some nice hot tub water at about 108 Ā°F.

Screen Shot 2020-11-12 at 4.55.43 PM download download

2 Likes

Confirmed, working.
Check this post

2 Likes

i can confirm that adding the property PROPERTY_READ ble is working both ways on esp32 and iphone 12 pro max ios 14.3
tks!

Thatā€™s great! How did you add the ā€œPROPERTY_READā€ to your app??? Iā€™m clearly not as educated as you guys are!

Thanks!

Hi there, any update about this issue? Thanks

Hi, any one can help to share a sample of data string receiving with BLE?
Thanks

Hi Thunkers and Developers,

I signed up to trial this app development tool specifically for a BLE application using the HM-10 BLE module. The nice thing about Thunkable was its ability to be cross-platform; Android, iOS and now WEB. I was contemplating upgrading to PRO, until reading these threads it appears that the issue with receiving data from the HM-10 has been on-going for over a year, with lots of dedicated users trying to resolve and provide guidance - but no official update to support.

Can someone from Thunkable provide clarity if this issue with the HM-10 will be resolved, or should I (and others) start looking at other app development platforms which support this popular BLE module?

ā€¦as an update:

  1. ā€œreceiveā€ does work with characteristic 0x2A00 which reads the name of the device; so the fundamental read code in thunkable works

  2. having a genuine HM-10 (not a clone) I tried splitting write and read functionalities into a second characteristic 0xFFE1 and 0xFFE2; unfortunately the no change. This would indicate to be the error is in the code which parses the returned information.

Strangely, back to back, the MIT AppInventor has no issue with receiving code, which is bazaar since the thunkable code leverages the AppInventor source codeā€¦

Hi! Iā€™ve some problems with the uuid of the hc08. I can neither receive nor send messageā€¦
someone already did that?