Problem with broken pipe

Hi! I have a problem maybe is because i have -1 or idk. After 1-2 minutes after i use the application in Android i recive text broken pipe What i make wrong?


Thank you for help!

Dear @Andrei_Grumazescu,
before we can help you we need some info more: what kind of Arduino board and what type of BT shield are you using ?
As a general hint if you use the SoftwareSerial library it's better to map the serial pins on 2,3 or 10,11 (examples) but not on 0,1 which are the pins used by the board to connect the Serial Monitor. In this case (0,1) you are using the "real" serial line of the Arduino board, therefore it is useless to load the SoftwareSerial library.
Another general hint is: don't rely on delay() function because in some Arduino implementations it disables the interrupt, thus blocking the Serial communication as well. You better could use the delaymicroseconds().
Last comment on Arduino code is: instead of creating int and float variables at every loop, just create the global variables only once, on top of the file, and use them in the loop, without the need to re-create them at every loop.

App side: when the app receives the string from the board, I see that you use the block "list from csv" instead of the standard block "spilt text at ',' ". Probably it works well, anyway, but the split text allows you to select the separator character, so instead of a "," you can use a character that you are sure (or at least more confident) that will never be a part of your data (in this case the list from csv can be foolished by a "," embedded within your data), and the resulting data in the app can be formatted erroneously.
Where is the transmission block ? Is it a timer ?
What is the period (how many milliseconds) of your receiving timer ?

Resuming: as a first step, please let us know your Arduino hardware. Then try to answer to my questions.
Cheers.

Thank you very much for your answer!
I'm using Arduino Uno, and for bluetooth I'm using HC-05. For the reception period I tried 2 seconds initially, now I put 5

The Ai2's clock should be set faster than the loop delay of your arduino program. In the loop of the program you have a delay of 2000ms, set the clock in Ai2 to 1500ms.

1 Like

Thank you both very much! I managed to find the problem, I was struggling with the code part but it was actually from time :slight_smile: Thank you again if you take the time to respond. :tipping_hand_man: :crown:

Dear @Andrei_Grumazescu,
happy that everything now works. As @Patryk_F has already said, the receiving period shall be always shorter than the transmission one otherwise multiple frames overwite themselves.
(Anyway don't forget my hints on the Arduino side for your future project :nerd_face:)
Best wishes

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.