Dear lovely inventors,
Now I working with this Arduino code with 'call.ReceiveText' on App.
But there is nothing on my phone.
I upload my block and design. Please, help me, beginner poor Clara
Thanks!
smartfarm (1).aia (80.7 KB)
readString = "";
String data = String(Water_Value) +","+String(Relay) +","+String(Water_Content)+ "," ;
Serial.println(data);
while (Serial.available()) {
delay(3);
char c = Serial.read();
readString += c;
}
if (readString.length() > 0) {
if (readString == "a") {
digitalWrite(Relay, HIGH);
delay(2000);
}
if (readString == "b") {
digitalWrite(Relay, LOW);
delay(2000);
}
What's in the variables "Water_value", "Relay" and "Water_Content"?
To begin with, modify your clock like this:
You set DelimiterByte to "10", but you ran out of a negative value in "NumberOfBytes". The application will now receive the entire message up to the end of line.
Thank you, Patryk!!!
I am making Bluetooth control Water pump for Smartfarm App. Water_value is the value from moisture sensor, Relay is Digital pin number in Arduino, Water_Content is the value of Water content with percentage.
I will edit and reply soon.
Many thanks!!!
In arduino the last comma is also redundant. Do this way:
String data = String (Water_Value) + "," + String (Relay) + "," + String (Water_Content);
With a comma, the app will create a 4-element list instead of 3. The last item in the list will be empty.
1 Like
Dear Patryk,
I found my mistakes!
I confused RX to TX, TX to RX, and Arduino coding error like "}"
while (Serial.available()) {
delay(3);
char c = Serial.read();
readString += c;
if (readString.length() > 0)
{
if (readString == "a") {
digitalWrite(Relay, HIGH);
delay(2000);
}
if (readString == "b") {
digitalWrite(Relay, LOW);
delay(2000);
}
}
delay(2000);
}
}
This code is working.
I appreciate your great help!
And hopefully, I will enjoy MIT App Inventor from now on.
Mostly, You are so helpful. Many many thanks to you.
Regards,
Clara
And I updated my Arduino code again.
Thank you Patryk!!!
1 Like
system
Closed
March 13, 2021, 12:06am
7
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.