Bluetooth HC-06. Arduino. Send. Receive. Send text file. Multitouch. Image

27.- App sends two values ​​separated by commas. Arduino adds them up and returns the sum.

p40i_bluetooth_deslizador.aia (3.5 KB)


  • App sends two comma separated values ​​created by two Sliders.


  • Arduino receives those values, separates them by comma, and adds them up.
    Using Serial.println(addition) returns the sum


String texto;
String a ;
String b;
float suma = 0.0;

void setup() { 

void loop() { 
  if(Serial.available()) {
    // texto = Serial.readString();
    // Serial.println(texto);
    a =  Serial.readStringUntil(',');
    b =  Serial.readStringUntil('\n');
    suma = a.toFloat() + b.toFloat();
   // Serial.println(a);
   // Serial.println(b);
1 Like

28. Bluetooth in Screen1 and Screen2.

p9H4i_pantalla_real_BT.aia (8.7 KB)

When we change from Screen1 to Screen2, we lose the Bluetooth connection.
The proper method to avoid this is to use "virtual screens" with VerticalArrangement as we saw in the post: #12

Now let's see how we can go from Screen1 to Screen2 using the disconnection and connection in the new Screen.

To go from one Screen to another, we disconnect the current connection, when we start the visible Screen we reconnect.

I've put a little delay (for each 1 ... 10000) to make the connection easier.

The app is similar to the previous example, two Sliders send two numbers to the Arduino, it adds them and returns the sum to the app.



Arduino code.

  • The same from the previous post.
1 Like

Excellent collection of tutorials!!
Could you please post how to use textboxes in example 27, instead of using 2 sliders?
For example, how do we enter two decimal numbers in two separate textboxes and that would be sent to the Arduino? But only one or both textboxes can be used at any time to change the corresponding values of the variables in Arduino, with a single "Send" button in app for both textboxes.
Thank you for all your amazing work!

1 Like

29.- Send text from two TextBox.

p9A0i_bluetooth_TextBox2.aia (3.6 KB)


Hi, your tutorials are very useful. I was able to finish a lot of projects thanks to this!

Now I'm stuck with my current project. I'm trying to analogRead from my ESP32, send that data via Bluetooth, and graph that signal in mitAppInventor. I need a sample frequency of around 500 samples per second. Is this possible with ESP32?

I checked your real time graph example, but I don't think it meets my time requirements. Maybe I should save the data to a .csv and then graph from there?

Once again, thank you so much for all your tutorials. They are super helpful!

I don't think App Inventor can take that data rate and draw it in real time.

ESP32 works with Bluetooth classic (uses the Bluetooth client component) and BLE (uses the BLE extension).

Try sending a Base 64 image and see how long it takes.

u have used -1 every where in this project what it means

Reads a number of bytes from the input stream and converts them to text.
If numberOfBytes is negative, read until a delimiter byte value is read.

In Design. Properties BluetoothClient. DelimiterByte = 10
ASCII 10 is \n, New Line, NL.

In Arduino:
ln sends \n
(really \r\n)

So Arduino sends Hello\n
Bluetooth receive Hello\n
\n here means end message because DelimiterByte is 10 and numberOfBytes is -1.

Thank you.
Yeah, I think I'll try to buffer that data in the ESP32, and then send it to the app and make a graph with that.
It definitely can't handle the "real time" part.

Hey Juan, thanks for this potentiometer app. I am trying to modify it such that the Y axis should vary between -90 to 90 and the variable will fluctuate between +ve and -ve along the X-axis. This would be similar to your p91C_grafico_amortiguacion app. But how to do this? I am kinda lost with the complexity of the graphing app. Also, how to add labels to the axes?

I don't know which example of potentiometers you mean, if you mean
9.- A potentiometer in Arduino sends values ​​to the App. Dynamic graph. Shift left.
you can change the value of y, but the value of x is time, you cannot change it between + ve and -ve.
To change the value of y between +90 and -90, change the following label.

if you mean the example:
7.- App gets the value of two potentiometers.
It would not be a dynamic left shift chart, it would be a static chart.

I think it's better if i post this question in a new topic. I would rather avoid cluttering this thread.

Hi, I have posted here too some Tutorials about AppInventor and Arduino, maybe can help you. There are analog and digital values

Have you ever been able to get this to work with apple ISO?

Sorry, in Apple ISO I have not tested it.

I have read somewhere else that Bluetooth is not supported yet in Appinventor :confused

App Inventor works with classic Bluetooth (Bluetooth components) and BLE (extension).

Can you change the sliders by a picture or drawing and then let the servos draw the picture or drawing like a draw robot

You can create a Canvas, slide your finger across the screen and send the coordinates via BT.

30A.- Multitouch with Clock. Press several buttons at the same time.

p9A0i_bluetooth_multitouch.aia (5.8 KB)

In this topic we can see several examples of Multitouch:

Let's take the idea from @TIMAI2, using the TouchDown, TouchUp events, and a Clock.

Touch btn_2 and btn_4, add and get 6 decimal, this is 110 binary or 00000110 Byte.
Send this Byte by Bluetooth.

  • Arduino receives this Byte. It splits bit(0), bit(1), bit(2) and bit(3) and RUN motors.

// Juan A. Villalpando

byte byte_received;
String motor;

void setup() { 

void loop() { 
  if(Serial.available()) {
    byte_received =;
   // Serial.println(byte_received, BIN);
   // Serial.println(byte_received, DEC);

void motores(){
if (bitRead(byte_received, 0)){Serial.print("Motor0: RUN  ");} else {Serial.print("Motor0: ---  ");}
if (bitRead(byte_received, 1)){Serial.print("Motor1: RUN  ");} else {Serial.print("Motor1: ---  ");}
if (bitRead(byte_received, 2)){Serial.print("Motor2: RUN  ");} else {Serial.print("Motor2: ---  ");}
if (bitRead(byte_received, 3)){Serial.print("Motor3: RUN  ");} else {Serial.print("Motor3: ---  ");} 


30B.- Multitouch without Clock.

p9A0i_bluetooth_multitouch_noclock.aia (6.1 KB)

  • Now without Clock.