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

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

33.- Two Screens. Screen1 to Connect. Screen2 to view data.

p9A02_bluetooth_dospantallas.aia (5.5 KB)

:eight_spoked_asterisk: For the app to work it must be installed.

  • We can go from one screen to another without losing the connection.

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

#include <SoftwareSerial.h>
SoftwareSerial BT(2,3);

int number = 0;
String numberS = "0";
char caracter = '0';

void setup(){
 BT.begin(9600);
 Serial.begin(9600);
}
 
void loop(){
  // Send number every 800 ms.
  delay(800);
  number = number + 1;
  if(number == 1000){number = 0;}
  Serial.println(number);
  numberS = (String) number + '\n';
  BT.write(numberS.c_str());

  // If receive char 'r' by BT, restart number.    
  if(BT.available()) {
    caracter = BT.read();
    Serial.println(caracter);
    if(caracter == 'r'){number = 0;}
    }
}
  • Sketch sends a number by BT every 800 ms: 1 2 3 4 5 6 7 8...
  • If this code receives the character 'r' by BT, the count is reset (number = 0)

ooooooooooooooooooooooooooooooooooooooooooooooooooo

  • Screen1 Select and Connect BT.
  • Receives the numbers by BT and store them in a comma separated string in a TinyDB, Always in the ReceiveText tag. 1,2,3,4,5,6,7,8,...
  • Shows all data in Label etq_receive.
  • Button "Open Screen2" open this screen.

oooooooooooooooooooooooooooooooooooooooooooooooo

  • Screen2 shows in Label etq_receive all data of TinyDB, ReceiveText tag.
  • TinyDB1 is the same on both screens, since they have the same NameSpace.
  • Button: "Send 'r' (by Screen1)", close Screen2 and sends 'r' to Screen1.
  • When Screen1 receive 'r', SendText 'r' by BT to Arduino. Arduino reset (number = 0). Return to Screen2.
    bluetooth_dos_pantallas2i

ooooooooooooooooooooooooooooooooo
Similar to this topic: [Extension] Dynamic graph. Shift left graph. Sinusoidal wave. Bluetooth

hello super tutorial YES !!!, a question: Is it possible to transmit a csv file from the arduino / esp8266 to the mobile? if so what are the constraints?
Thanks for reading.
Happy holidays to you

1 Like

Hello,
I just try to get data (voltage) from Arduino. voltage from the photo resistor.

void loop()
{
int Volt = analogRead(A0);
Serial.print(Volt);
delay(500);
}

I can't see any data in MitappInvertor

Serial.print(Volt);

to

Serial.println(Volt);

if BluetClient.Is Connected...... in a ClockTimer

Clock Timerinterval : 400
BluetoothClient.DelymiterByte: 10

Take a look at the examples in this topic.