Character modified in Bluetooth

Try other codes for receiving data, here I have put one with readString...
p9A1_bluetooth_textoi_2.aia (3.0 KB)

Bluetooth module in pin 2,3 of Arduino.

#include <SoftwareSerial.h>
SoftwareSerial Bluetooth(2,3);
String texto;

void setup() { 
Serial.begin(9600);
Bluetooth.begin(9600);
Bluetooth.setTimeout(100);
}

void loop() { 
  if(Bluetooth.available()) {
    // texto = Bluetooth.readStringUntil('\n');
    texto = Bluetooth.readString();
    Serial.println(texto);
    Bluetooth.println(texto);
  }
}

Possibly the error is in the way of sending data, use an ENTER key (sendtext button) to send the data instead of the Clock.

Salut Ugo,

merci pour cette info, j’ai effectué la modification sur mon programme comme tu me la conseillé. Malheureusement, cela n’a pas résolu le problème, mais peut-être que c'est plus logique qu'avant, donc je garde la modification que tu ma conseillé. Merci ! :slight_smile:

Je met aussi la traduction pour que tous le monde puisse suivre :
I also put the translation so that everyone can follow:

thank you for this info, I made the modification on my program as you advised me. Unfortunately, this didn't solve the problem, but maybe it makes more sense than before, so I keep the modification you advised me. Thanks ! :slight_smile:

Hi Juan Antonio,

thanks for these informations.

I do not know if I understood well.

I don't think I can use your way of doing it, because I have to (it seems to me) attach a "$" to the start and a "*" to the end, so Arduino knows when to start and when to end the value I want ( I send it quite a few other values).

In your Arduino code, "Bluetooth.setTimeout(100);" is very interesting! I didn't know that. I tried in my code, but the problem is still there. Thanks anyway, maybe I'll use it a day !

Yes I had also thought of using a button to send the text, that might have solved the problem. But the addition of this button did not suit me.

On the other hand, I would have liked very much that when I type the value, AI2 does not send anything, and when I click on the button of the Android keyboard "validated" it sends the value.

Because for example when I type 6584, there are 4 values sent (6-65-658-6584), and the same when I delete and when I retype a value.

Can AI2 detect hitting the "send/submit" button on Android keyboard?

Thanks to you !:slight_smile:

Hi there,

Here is some information that I was able to gather.

There may be unnecessary or missing information.

As a reminder, my problem is that when I enter a value in an AI2 Text Zone, the information transmitted by Bluetooth sometimes arrives with unwanted characters (errors occur at random intervals, see video above).

Materials:

Arduino KEYESTUDIO Mega R3 Plus 2560 board

CNC Shield V3

A4988 controller (modified see HERE)

HC-05 Bluetooth module (I believe)

4-channel relay module (control of 4 LED spotlights)

Sw-18010p vibration sensor module

Circuit board salvaged from a wireless remote → PROfezzion 165ft Nikon

PRIOR joystick control box + optical encoder + two buttons

Footswitch dictaphone Phillips (modified) 3 buttons

UNIROI 0-32V (11.9/12v) stabilized power supply

4 stepper motors (X-Y-Z-R axes)

CHUWI HiPad LTE touch tablet

/
/
/

Information:

HC-05 Bluetooth module → 115000 baud

Arduino program → 115000 bauds for Bluetooth and Serial monitor

Android tablet:

  • Android version 8.0.0

  • Bluetooth version 8.0.0 (application information)

  • Android Bluetooth baud rate → ? Where to find this information ?

  • Baseband version: MOLY.LR11.W1630.MD.MP.V67.2, 2018/06/15 17:37

  • CDMA baseband version: SIXTH.CBP.MD.MP5.V72.2, 2018/04/02 17:53

/
/
/

Communication :

HC-05 → Bluetooth → Android

Android tablet → Wifi (via repeater) → Internet Box

Pc → Wired → Internet Box

/
/
/
Program :

The Arduino program: Nikon-Stacking_V2.ino (50.4 KB)

  • I used three libraries: RotaryEncoder.h | AccelStepper.h | SoftwareSerial.h

The AI2 file: WeTransfer link because file too large HERE

I ask for your indulgence, I am a beginner, this is my first real project.

I started from scratch with AI2 and had some basics in Arduino.

The Arduino program is not finished (example limit switch, AI2 pause button, stop, emergency stop), it can be difficult to follow, and not optimized.

I still have a few issues that I haven't taken much time to research yet:

  • I have some latency between joystick action and position display on AI2 Android (but I won't deal with this problem here, maybe it will be in a new topic :slight_smile: )

  • When I activate the Z rotary encoder, I have the X Y motors moving slightly a few steps. Maybe a ground issue, or the optical encoder causing the problem, I don't know yet.

When you open the AI2 file, maybe all the labels, images, buttons will be shifted, because I positioned them (at pixels!) for my tablet (1920x1200 resolution).

You will see that there is a lot of image overlay following the actions, it is to make small animations when you press the buttons.

I was wondering, if we set the HC-05 module to 115000 baud, how does it work with Android? Does Android automatically set itself to 115,000 baud? Or did I misunderstand the principle?

I thank you in advance!

[I use Google Translet French → English]










It's AI2 Jon :grin:

There isn't an officially released Bluetooth version 8, the latest is v5.3 BLE, released in 2021.

The HC-05 modules are Classic BT v2.0

Classic BT typically uses a Serial Baud Rate of 9600
BLE typically uses a Serial Baud Rate of 9600 or 115200

Ideally your devices should all sing the same Bluetooth song.

Whoops ! :roll_eyes:

I made the change :grinning_face_with_smiling_eyes:

...and:

I tried to find the Bluetooth version of my tablet by following the indications found on Google.

They say to go to:

Setting > Application > Bluetooth > Version

I have :

Setting > App & notifications > App info > Show system processes > Bluetooth > version 8.0.0 (which is apparently not the BT version)

I will try to download an application that will give me all the technical details of the tablet

HC-05 module:

Yes, I had made a baud change with AT commands.

I had set to 115200 baud.

I double-checked it yesterday to be sure.

(he also tells me he's a "slave", I don't know if that's important)t)

I have just downloaded an application (AIDA64) which indicates all the technical data of my device.

Bluetooth version, it says "4+".

I will read the post, it looks interesting, thank you!

ChrisWard,

I read what you suggested.

There is something interesting. I may have misunderstood, but he writes that the baud rates of the BluetoothClient and the Arduino BT module must be the same.

When it says " BluetoothClient" is it talking about AI2's BluetoothClient?

Because I don't see where to set this value?

Capture d’écran 2022-12-10 150233

Ouch - that's an early BLE version - could be glitchy unfortunately so needs as perfect an environment as possible. I suggest using a Serial Baud Rate of 9600.

The HC05 modules support BT Classic version 2. So you need a BLE module such as an HM-10 (BLE 4.0) or maybe an HM-16 (BLE 4.1 to 5.0)

I ironed the HC-05 module at 9600 baud, as well as in the Arduino program.
I still have garbage characters...

I will take a closer look at the modules you offer.

The App Inventor BT Client is normally used with a Baud Rate of 9600, so the BT Module (HC-05) would need to be the same, as would the Serial comms via the Arduino Sketch Serial(9600).

A similar harmony is required for BLE but the MIT BLE extension can work with a selection of Baud Rates.

Oh okay!
I switched everything back to 9600 baud (HC-05 + Ardunio module), but the problem is still there...

This selection is done by itself? Or is it up to us to choose the right one? (I may not have understood :upside_down_face:)

I was wondering what is the use of "polling rate" in BT client properties? Do you think this might have something to do with my problem?

123

It means it can work with a range of different devices that may have different baud rates.

I have never noticed it! The default value is actually 10, so start with that. I think it is to do with scanning Bluetooth devices that could be connected to, i.e. how many attempts to collect each device address. Or perhaps how many times it will test for incoming bytes per system defined time interval. I have asked the powers that be.

Very well thank you! Let me know when you get a response. :slight_smile:

Next week I will try this value (currently it is 100 I believe)

Do you think it could come from there? which one do you recommend me to take? On Amazon.fr (delivery in 2 days) there is the [HM-10 BLE4.0] and the [HM-11 BLE4.0] (what's the difference?) or you advise me to take the HM- 16 (Aliexpress 3 weeks)?
How do I know which one would be better, since the only information I could get from my Android tablet was BLE version 4+ (->4+? What does that mean? 4.0 -4.1-4.2-.. .-?)

Thank you for your help ! :+1:

What I can tell you is that BT Classic and BLE, whilst both Bluetooth, are as different as chalk and cheese. It's therefore important to ensure that the Project's devices all use the same Bluetooth Version.

https://www.professorcad.co.uk/appinventortips#TipsBluetooth