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

http://ai2.appinventor.mit.edu.ezproxy.canberra.edu.au/reference/components/connectivity.html#BluetoothClient

ReceiveText(numberOfBytes)
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:
Serial.println("Hello");
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
// http://kio4.com/appinventor/9A0_Resumen_Bluetooth.htm

byte byte_received;
String motor;

void setup() { 
 Serial.begin(9600);
}

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

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: ---  ");} 
Serial.println();
}

oooooooooooooooo000000000000000000oooooooooooooooooo

30B.- Multitouch without Clock.

p9A0i_bluetooth_multitouch_noclock.aia (6.1 KB)

  • Now without Clock.

Olá gostaria de saber se teria como informar no app, a medição de um contador de fluxo de água.
Teria como me ajudar?

@Felipe_Carvalho
Open a new topic and show your work, code, drawings, devices used ...

Check example:
8.- App receives data from Arduino. Clock.Interval. Arduino delay. Buffer.

Estou precisando fazer com que no aplicativo comunique com o arduino a partir dessa programação:
#include <LiquidCrystal.h>

float vazao; //Variável para armazenar o valor em L/min
float media = 0; //Variável para fazer a média
int contaPulso; //Variável para a quantidade de pulsos
int i = 0; //Variável para segundos
int Min = 00; //Variável para minutos
float Litros = 0; //Variável para Quantidade de agua
float MiliLitros = 0; //Variavel para Conversão

LiquidCrystal lcd(8, 7, 6, 5, 4, 3);

void setup() {
Serial.begin(9600);

lcd.begin(16, 2);
lcd.setCursor( 0, 0);
lcd.print("Sensoriamento de");
lcd.setCursor( 0, 1);
lcd.print(" fluxo de Agua ");
delay(3000);
lcd.clear();

pinMode(2, INPUT);
attachInterrupt(0, incpulso, RISING); //Configura o pino 2(Interrupção 0) interrupção
}

void loop () {
contaPulso = 0;//Zera a variável
sei(); //Habilita interrupção
delay (1000); //Aguarda 1 segundo
cli(); //Desabilita interrupção

vazao = contaPulso / 5.5; //Converte para L/min
media = media + vazao; //Soma a vazão para o calculo da media
i++;
lcd.setCursor(0, 0);
lcd.print(vazao); //Escreve no display o valor da vazão
lcd.print(" L/min "); //Escreve L/min
lcd.setCursor(0, 1);
lcd.print(Min);
lcd.print(":"); //Escreve :
lcd.print(i); //Escreve a contagem i (segundos)
lcd.print("Min "); //Escreve :
MiliLitros = vazao / 60;
Litros = Litros + MiliLitros;
lcd.print(Litros);
lcd.print("L ");

// Neste conjunto de linhas fizemos a média das leituras obtidas a cada 1 minuto
if (i == 60) {
Min++;
lcd.print(Min);

if (Min >= 60) {
Min = 0;
}
media = media / 60; //faz a média
Serial.print("nMedia por minuto = "); //Imprime a frase Media por minuto =
Serial.print(media); //Imprime o valor da media
Serial.println(" L/min - "); //Imprime L/min
media = 0; //Zera a variável media para uma nova contagem
i = 0; //Zera a variável i para uma nova contagem
}
}

void incpulso () {
contaPulso++; //Incrementa a variável de pulsos
}

a onde a montagem do circuito é a seguinte

não precisa do LCD, só preciso com que as informações do sensor de fluxo consiga passar a quantidade de litros para o aplicativo

O sensor usado foi o [Sensor de Fluxo de Água G 1/2 1-30 l/min]

E o site usado como base foi o https://www.usinainfo.com.br/blog/sensor-de-fluxo-de-agua-para-arduino-1-30-lmin/

Por enquanto eu fiz esse aplicativo:



Porem o dados não estão sendo mostrados corretamente

Você teria outra solução ou alteração no meu trabalho?

31.- Automatic connection and disconnection cycle of Bluetooth.

p9A01_bluetooth_conec_desco.aia (3.2 KB)

  • Arduino creates random numbers from 0 to 500 continuously and sends them over Bluetooth with a delay of 100 ms.

// Juan A. Villalpando
// http://kio4.com/appinventor/9A01_Bluetooth_Conec_Desco.htm

int value_pot0;

void setup() {
Serial.begin(9600);
}

void loop() {
// value_pot0 = analogRead(A0);
value_pot0 = (int) random(0,500);
Serial.println(value_pot0);
delay(100); // It should be slower than the Clock Interval.
}

  • App connects Bluetooth for 5 seconds, during that time it receives data. Disconnect. Stay disconnected for 5 seconds. Repeat the cycle.
    (approximate times).

Clock1.TimerInterval: 5000
Clock2.TimerInterval: 50
BluetoothClient1.DelimiterByte: 10

  • "for each" loop, create a small delay.

32.- Two Bluetooths alternately connect and disconnect cyclically.

p9A01_bluetooth_conec_desco_2.aia (3.4 KB)

In these tutorials we saw how to connect two Bluetooth devices at the same time to the same application, for this we use two components, BluetoothClient1 and BluetoothClient2.

https://groups.google.com/g/mitappinventortest/c/tsUYqkXNZ3U/m/__y8bPk3BwAJ

http://kio4.com/appinventor/9X_bluetooth_dos_arduino.htm

  • Now we are going to connect two Bluetooth to the same application but cyclically, that is, the app connects to a Bluetooth, for 5 seconds during this time it receives random numbers from 100 to 199. It disconnects. It connects to the other Bluetooth for 5 seconds, during that time it receives random numbers from 2000 to 2999. It disconnects. This sequence repeats continuously.

  • We will use a single BluetoothClient1.

  • The two Bluetooth are sending numbers continuously. Look at the Arduino codes. Just change the range of the random numbers.

Code for Arduino 1. (100...199)

// Juan A. Villalpando
// http://kio4.com/appinventor/9A01_Bluetoot_Conec_Desco.htm

int value_pot0;

void setup() {
Serial.begin(9600);
}

void loop() {
// value_pot0 = analogRead(A0);
value_pot0 = (int) random(100,199);
Serial.println(value_pot0);
delay(100); // It should be slower than the Clock Interval.
}

Code for Arduino 2. (2000...2999)

// Juan A. Villalpando
// http://kio4.com/appinventor/9A01_Bluetoot_Conec_Desco.htm

int value_pot0;

void setup() {
Serial.begin(9600);
}

void loop() {
// value_pot0 = analogRead(A0);
value_pot0 = (int) random(2000,2999);
Serial.println(value_pot0);
delay(100); // It should be slower than the Clock Interval.
}

Clock1.TimerInterval: 5000
Clock2.TimerInterval: 50
BluetoothClient1.DelimiterByte: 10