Connecting Seeed studio xiao esp32c3 with MIT App Inventor via Bluetooth

Hi @ABG,
This is another variation of code that I used:

and I came up with this error:

I’ve been looking around for projects but the projects on the product page scarcely deal with BLE and do not have the functions for the xiao esp32c3 microcontroller (there’s not much online at all I’ll keep looking). I know for a fact though, that the data is transferred to the app as a string.

Any thoughts? Thanks for all the help.

If it's not text, what does it look like?

Why are you using the ReadString method in the StringReceived event? What happens if you just remove the ReadString blocks?

There are two ways to read the data. You register the BLE component for automatic reading of data using the RegisterForString block, which you did in the Connected event, or you use ReadString e.g. in the clock. Your code with ESP seems to use notifications, so just registering string readings should be enough, and ReadString blocks are unlikely to be needed.

It just looks like their default text, sorry for the confusing phrasing.

Essentially, the data is not displayed in the labels, and the labels stay as they are as they have in default. The text for the label for the temp data is tempOutput, and it just stays that when the app runs (even though the device is connected).

Thanks @Patryk,
I took out the ReadString block and just set the code to be this:

The UUIDs are copied from the arduino code, which is listed above in this conversation:
pServer = BLEDevice::createServer();

pService = pServer->createService(BLEUUID("0000AAAA-0000-1000-8000-00805F9B34FB")); // Custom Service UUID

pTemperatureCharacteristic = pService->createCharacteristic(

  BLEUUID("0000AAAA-0001-1000-8000-00805F9B34FB"),

  BLECharacteristic::PROPERTY_READ |

  BLECharacteristic::PROPERTY_NOTIFY

);

pHeartRateCharacteristic = pService->createCharacteristic(

  BLEUUID("0000AAAA-0002-1000-8000-00805F9B34FB"),

  BLECharacteristic::PROPERTY_READ |

  BLECharacteristic::PROPERTY_NOTIFY

);

I copied them over directly from the code, but it just doesn't seem to work? If I take all the code out that reads the heart rate sensor data, the data for temperature shows up in the label fine, but the two sensor data just can't seem to be displayed together on the app.

Also, thank you Patryk and Abraham for helping so much. It means a lot.

It worked for him, so I don't know why the problem is here.

Edit:

You have a bug here. It should be ...Char2.

You can also try using green logical or blue math blocks instead of pink text comparison blocks.

For diagnostic purposes, add multi-line Labels to show a log of the incoming serviceUuid and characteristicUuid.

It's hard to debug a comparison without seeing what's on both sides

set LblCharacteristicUuid.Text to JOIN(characteristicUuid, '\n', LblCharacteristicUuid.Text)

Hi @Patryk and @ABG, here is my aia
MLEX_vital_reader_3.aia (255.8 KB)

Hi @ABG, I understand. Do you want me to make another label?

Only if the latest @Patryk_F bug fix did not work for you.

The project you shared is also not working? Are there any errors or just no response? Here I added labels to see the raw data if any.
MLEX_vital_reader_3.aia (256.0 KB)

Hi @Patryk, There's just no response
There are no errors.

I have another idea for you to add a little delay in the ESP32 code after sending the temperature.

I also found this topic where the author registers receivers with delay.

Hi @Patryk,
I'll try that out, thanks.

Hi @Patryk, @ABG
I inserted the code that said it worked in that conversation, but the outputs still haven't changed. :frowning: Should I attempt to create two different screens and connect the bluetooth separately?

Hi all, I think I came across the error.
For some reason, the temperature reading works perfectly fine when I just run the code to set the text label to that, but the heart rate reading doesn't work and comes up with this issue:

Even though both the service and characteristic uuids are ones I copied over from the code, this error occurs, and I was wondering if there's something wrong with the code...

Show the current blocks with which this error occurred.

In order to verify the correctness of the ESP code, you should ask the experts in the arduino or esp32 forums. Maybe the problem is in the ESP.

Look for a BLE terminal app that can be used to show BLE traffic independent of AI2, to see transmissions.

@Patryk_F @ABG Hi all, I think someone helped get the code to work for both sensors, I will send over the code as soon as I get it. Thanks for all the help. In the meantime, I have been trying to send text notifications from the phone with this code, but the app keeps on glitching (as described). Is there any way to include a component that controls the sending of the text message to be a one-time thing? Additionally, is it possible to send a text message automatically without pressing on anything? I know that there is an alternative version 2.65u of the mit app companion that apparently bypasses Google app’s limitations but I can’t seem to find it. Thanks again.

It's not Companion's fault that it blocks text messages without user interaction. It's just android updates. In my opinion, a better solution would be to use the SIM800 module connected to ESP32, instead of sending text messages from the app.

But then again, doesn't this block work for you?
component_method (3)