sending and receiving text using bluetooth

135 views
Skip to first unread message

Fernando Inácio

unread,
May 30, 2019, 2:52:10 PM5/30/19
to MIT App Inventor Forum
I am trying to do a bluetooth terminal to interconnect with arduino. Text reception is detected by poling using a timer. Sending and reception works perfect in a isolated way. But working together seems to have a conflict between reception (timer) and sending and the app crashes. 

Ghica

unread,
May 31, 2019, 9:04:16 AM5/31/19
to MIT App Inventor Forum
Post your blocks (and/or a link to your .aia),  and your .ino file so we can find out what may be wrong.
Cheers, Ghica.

Fernando Inácio

unread,
Jun 1, 2019, 7:34:58 AM6/1/19
to MIT App Inventor Forum
This app is sending a number to arduino (only first 3 keys are concluded) and receive a string. After opening the App blueTerm, pressing CONNECT key it is possible to setup bluetooth connection. Digits are sent pressing corresponding key and to receive a buffered string it is required to press RECEIVE key. In a usual way RECEIVE key doesn´t exist being text send directly to text box, but if it is removed CONNECT key allowing to enable e disable clock1 the App remains blocked.
The file project .aia it is attached.
blueTerm.aia

Ghica

unread,
Jun 1, 2019, 11:30:36 AM6/1/19
to MIT App Inventor Forum
You did not post your .ino file
Anyway, it seems that you are receiving text only once, because you are disabling the clock immediately after receiving the first message. So, somehow that will not work.
And why are you sending 1 byte numbers? are these received ok in your Arduino? It is usually much easier to send and receive strings, especially if you do not have much experience with Arduino and/or App Inventor yey.
How are you delimiting messages in your arduino? if that is using println() then you should set the delimiter to 10 in the designer and receive -1 bytes, which will give you complete messages.
Also, the timer interval of 100 is probably too short. What is the delay in your Arduino?

Cheers, Ghica.

Helio Fernando Barbosa

unread,
Jun 5, 2019, 1:36:59 PM6/5/19
to MIT App Inventor Forum
Olá Fernando!
Você fala português?

Fernando Inácio

unread,
Jun 12, 2019, 5:42:30 AM6/12/19
to MIT App Inventor Forum
Sim falo Português.

Fernando Inácio

unread,
Jun 12, 2019, 6:00:30 AM6/12/19
to MIT App Inventor Forum
Arduino file is very simple program just echo received string or chars.
Attached is included a ino file.
CallResponse.ino

Ghica

unread,
Jun 12, 2019, 9:06:18 AM6/12/19
to MIT App Inventor Forum
Fernando,
There is something very wrong with both your app and your .ino file.

In your app you are trying to enable your BT component in your phone, but not connect it.
Usually it is already enabled and you should pair your arduino using the phone settings.
But connecting has to be done at the beginning of your app. 

Choose BT<4

Then, in your ino file, what is this establish contact thing? 

I would advise you to send strings on both sides, that is much easier to handle.
And, do not disable the clock (after connection), that is not useful.
Cheers, Ghica.
Reply all
Reply to author
Forward
0 new messages