In the previous blocks observe SendText = 3, this is dumb number, when that number is sent and the Bluetooth does not receive it, we get error 516: Unable to write: Broken pipe.
// Juan A. Villalpando
// http://kio4.com/appinventor/9A0_Resumen_Bluetooth.htm
int x;
int y;
int z;
String datos;
void setup() {
Serial.begin(9600);
}
void loop() {
x = random(0, 10);
y = random(10, 100);
z = random(100,1000);
datos = (String) x + "," + (String) y + "," + (String) z;
Serial.println("Números aleatorios:");
Serial.println("Random numbers:");
Serial.println(datos);
delay(800);
}
// Juan A. Villalpando
// http://kio4.com/appinventor/9A0_Resumen_Bluetooth.htm
int x;
int y;
int c;
String datos;
void setup() {
Serial.begin(9600);
pinMode(2,INPUT_PULLUP);
}
void loop() {
x = analogRead(A0);
y = analogRead(A1);
if (digitalRead(2) == HIGH){c=0;} else {c=1;}
datos = (String) x + "," + (String) y + "," + (String) c;
Serial.println(datos);
delay(100);
}
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.
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!
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!
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.