Arduino to Android BLE Receiving Corrupted String Data

Hi

I have searching for hours trying to find a solution to this. I have an arduino connected to an HM-10 BLE module. If I use an app such as Bluo to see the text I am sending via the HM-10 it displays as expected but when trying to get the same data in AI2 all I get is a corrupted string. It is always the same data regardless of what I send.
I’ve only been at his a couple of days so it’s all new to me but from what I have seen on the web this should work. Blocks and sketch attached.

I must be doing something wrong but I can’t figure it out so if someone could point out where I am going wrong it would be very much appreciated.

Many thanks

Rich

#include <Wire.h>
#include <AltSoftSerial.h>

AltSoftSerial BTserial;

void setup()
{

Serial.begin (38400);
BTserial.begin(38400);
}

void loop(){
Serial.print(“Test”);
BTserial.print(“Test”);

delay (1000); // pause a second
}

BT_Van.aia (167.8 KB)

That 38400 bps might be too high.
9600 bps is a more attainable common denominator default speed.

Thanks. I should have said, I started with the default of 9600 and it didn’t work so I was playing with different rates to see if it helped.

Have you seen this tutorial from the AI2 FAQ?
http://www.martyncurrey.com/arduino-hm-10-and-app-inventor-2/

Note the Register for Strings block usage in Arduino Sketch. Example Project Part 2: Turn an LED on and off 2way control

Also double check for wiring errors (crossed transmit/receive wires), it caused garbage for a user in the old forum once.

I’m opening up this thread to more experienced HM-10 users.

Here’s a custom search for HM-10 in the old forum:
https://groups.google.com/forum/#!searchin/mitappinventortest/HM-10%7Csort:date

This thread might help, it has sample code for both sides:
https://groups.google.com/d/msg/mitappinventortest/2KPxDAAPMRA/x6ZVLv5rCgAJ

Thank you. That was the tutorial that I was using. I’ll have another look at it, I must have missed something out somewhere. As you say the string registration could be it.
I’m pretty sure I can rule out a wiring issue as I’m receving the data correctly in another ready made app.

Now working.
I was using ReadStrings when it wasn’t necessary. I needed to Register for Strings and use the When Strings Received process.
Thanks again for pointing me in the right direction.

Thanks for telling us what worked, and
Happy New Year!

I also faced the same problem.
Please give me any suggestions.
I used Register for string block and read-string block.

Have you compared your code blocks with the tutorial referred to earlier in this thread?
http://www.martyncurrey.com/arduino-hm-10-and-app-inventor-2/ 8

I gothrough this codes and applying into my code block. Then my app is going to hungout state.

Post your exported .aia file and .ino file here.

AQI_APP_1_0.aia (162.5 KB)

I interface the sensors with the MSP430 microcontroller so I can’t upload the .ino file.

So show us the C code. Any kind of source code.
Also tell us about the BLE device info on the MSP430.

Also, your BLE ReadStrings block is unnecessary if you registered for strings.

Ok, I will try this suggestion and i will shere the result.
But I can’t share the MSP430 uc programming code.

My BLE device is HM10S.
I also try with the use of BGx13P. Same problem I faced.

Double check that your two connection strings (UUID, etc) are right for HM-10.
See the Donnelly video at FAQ Section: BlueTooth/BLE and HM-10 two thirds through for how to double check those.