@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.
@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:
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)
// 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.
}
Clock1.TimerInterval: 5000
Clock2.TimerInterval: 50
BluetoothClient1.DelimiterByte: 10
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
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)
For the app to work it must be installed.
// 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;}
}
}
ooooooooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooooooooooo
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
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.
It would also help to set global Volt to Bluetooth.ReadText inside that if/then before announcing Volt in a Label.
34.- App sends a number as text via Bluetooth and Arduino converts it to binary. Return.
p9A2_ConvertirBinario.aia (9.5 KB)
a) It converts it to binary with 8 bits.
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
int num = Serial.parseInt(); // Read number received as text
String binary = String(num, BIN); // To binary
while (binary.length() < 8) {
binary = "0" + binary; // Fill 0 left
}
Serial.println(binary); // Print binary number and return.
}
}
oooooooooooooooooooooooooooooooooooooooooooooooooo
b) Binary Positional.
[Start in position 0]
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
int num = Serial.parseInt(); // Read number received as text
String binary = "";
for (int i = 0; i < 48; i++) {
if (i == num) {
binary += "1"; // Agregar "1" en la posición correspondiente al número
} else {
binary += "0"; // Agregar "0" en las demás posiciones
}
}
Serial.println(binary); // Print binary number and return.
}
}
oooooooooooooooooooooooooooooooooooooooooooooooooo
c) It converts it to BCD (Binary-Coded Decimal).
[It is necessary that the input has 4 digits: 1256]
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
String textReceived = Serial.readStringUntil('\n');
if (textReceived.length() == 4) {
for (int i = 0; i < 4; i++) {
int num = textReceived.charAt(i) - '0'; // Get numeric value.
String bcd = String(num, BIN); // To BCD
bcd = ("0000" + bcd).substring(bcd.length()); // BCD with 4 bits
Serial.print(bcd + " "); // Print binary number and return.
}
Serial.println();
}
}
}
35.- Arduino sends two random numbers with decimals, separated by commas.
pA0_Bluetooth_Arduino_envia.aia (10.7 KB)
float temperature = 0.0;
float humidity = 0.0;
String tempera_humidity;
void setup() {
Serial.begin(9600);
}
void loop() {
temperature = random(20, 40) * 5.555;
humidity = random(50, 95) * 3.333;
tempera_humidity = String(temperature, 3) + "," + String(humidity, 3);
Serial.println(tempera_humidity);
delay(1000);
}
36.- Ultrasound SR04 sends distance to App by Bluetooth.
pA0_Bluetooth_Arduino_Ultrasonido.aia (3.0 KB)
Arduino Library Ultrasonic.zip:
http://kio4.com/appinventor/9A0_Resumen_Bluetooth.htm#ultrasonido
#include <Ultrasonic.h>
Ultrasonic ultrasonic(12,13); // (Trig PIN, Echo PIN)
void setup() {
Serial.begin(9600);
}
void loop(){
Serial.println(ultrasonic.Ranging(CM));
delay(500);
}
Hello, I tried this and it's not working, when connecting to HC-05 Bluetooth module it works but on the Check Temperature button when I click it it just freeze. Any help? thanks
I already set the DelimiterByte the value 10, still not working
Not working on me
Well, now it's working, after extensive research and checking the hardware parts I used, the app was not the issue, the problem was the power supply, the wire I use was longer, then I try shorter wire, now it works, the problem was power supply shortage.