Skip to first unread message

Òscar Lorente

unread,
Dec 4, 2017, 3:49:24 PM12/4/17
to mitappinv...@googlegroups.com
Hi! 
First of all, my english level is quite limited so i'm sorry if something is written wrong.

I'm trying to "program" an app to control a motor with a joystick using appinventor2.
When i test it with a basic Arduino code to watch the x and y variations on the Serial Monitor everything is going well until 1 minute later the app suddenly stops running and a "Broken pipe" error is shown. 
I've been reading in many forums and it seems to be a problem related to bluetooth connection but i don't know how to solve it. 

Maybe the main problem comes from the baud rate of HC - 05 module, so I'd like to know the needed configuration and if it could be the problem.

I've attached the appivnentor2 blocks.

Here's my Arduino code:

void setup() {

  Serial.begin(38400);
}

void loop() {

  if (Serial.available() >= 1) {

    int x = Serial.read();
    delay(25); //Don't know if that is necessary
    int y = Serial.read();

    Serial.print("x:");
    Serial.print(x);
    Serial.print("\n");
    Serial.print("y:");
    Serial.print(y);
    Serial.print("\n"); 
    }
}

Thanks!
blocks.png

Òscar Lorente

unread,
Dec 4, 2017, 3:57:19 PM12/4/17
to MIT App Inventor Forum
By the way, here's the bluetooth module-Arduino connection.
2017-12-04.png

Òscar Lorente

unread,
Dec 4, 2017, 4:42:47 PM12/4/17
to mitappinv...@googlegroups.com
It seems that if i keep the "Serial.read(38400)" line in Arduino but configure the HC-05 to 9600 b/s i don't get the error message but i'm always receiving the number "120, 248, -1 or 0" on my Serial Monitor. 

Okay. also the "broken pipe" error but it took me more minuts to get it.

Abraham Getzler

unread,
Dec 4, 2017, 9:24:18 PM12/4/17
to MIT App Inventor Forum
Did you use this board's search for broken pipe ?

ABG

Òscar Lorente

unread,
Dec 8, 2017, 3:47:56 PM12/8/17
to MIT App Inventor Forum
Yep, nothing helped. 

Instead of trying to avoid the problem, I'm looking for another alternative, such as reconnect bluetooth connection between the module and my mobile if the error occurs (with a "When Screen1.Error Ocurred: If getErrorNumber=516...") but the problem is that just before it disconnects from the BT module and the 516 error appears the app starts to slow down for about 10 seconds. So I tried to also avoid that by implementing a block that reconects BT connection if I shake the mobile, but it doesn't work (it only disconnects from the BT module).

Reply all
Reply to author
Forward
0 new messages