404 Not Found

unread,
Apr 2, 2019, 11:22:26 AM4/2/19
to MIT App Inventor Forum
I tried to send word "popo" to microcontroller by my application through BLE.It was worked but i could only receive letter 'p' insted the whole word.Could it possible that my application actually received the whole word but show just letter 'p'.
Capture.PNG
55882215_775150942868691_2378509152872824832_n.jpg

ABG

unread,
Apr 2, 2019, 1:44:13 PM4/2/19
to MIT App Inventor Forum
Those parentheses around the 'p' suggest that a list is being converted to a string on the AI2 side.

What do the Ai2 tool tips say about what is expected to go into the Values socket where you transmit 'popo' ?
The name Values is plural, suggesting it wants a list.
Does it expect a list?

What happens if you instead supply
 make a list('popo') for Values ?

ABG


gerrikoio

unread,
Apr 2, 2019, 4:44:07 PM4/2/19
to MIT App Inventor Forum
would need to see your Arduino code in particular how you read and write BLE strings

Chris Ward

unread,
Apr 2, 2019, 7:47:09 PM4/2/19
to MIT App Inventor Forum
Hi

We do not know how your Arduino is sending the data, post your Sketch here........
.......but before you do, in the App Inventor Blocks, try register for strings instead of read strings.

Chris Ward

unread,
Apr 2, 2019, 7:50:48 PM4/2/19
to MIT App Inventor Forum
...forgot to say, we really need to see all of the BLE related Blocks to understand your App code. Use this method to post an image of your Blocks:
https://www.professorcad.co.uk/appinventortips#TipsBlocks  How to create an image of your Blocks and add it to your Forum Post

Message has been deleted
Message has been deleted
Message has been deleted

404 Not Found

unread,
Apr 3, 2019, 4:58:17 AM4/3/19
to MIT App Inventor Forum
Thanks,This is my code.
Capture.PNG
Message has been deleted

Chris Ward

unread,
Apr 3, 2019, 6:24:50 AM4/3/19
to MIT App Inventor Forum
Right..... 

Serial.write(Serial.read());

I think it is possible that the write is performed before the read is completed. In any case, the code is reading one byte only.

Try something like this:

String sgRead;

void setup() {

       Serial.begin(9600);   //Set the baud rate of the bluetooth connection
}

void loop() {

       if(Serial.available() > 0)
       {
               //Data from App
               sgRead = Serial.readString();

               //Tiny delay
               delay(100);
               
               //Data to App
               Serial.print(sgRead);
               Serial.println();
               
               //Short delay between each data send/receive.
               //If data is sent in less than every 4-5 seconds, humans can't read it.
               delay(5000);
       }
}

404 Not Found

unread,
Apr 3, 2019, 8:45:14 AM4/3/19
to MIT App Inventor Forum
Thank you so much for every answers.Finally,i can solve the problem by used block BLE.register.string.
Reply all
Reply to author
Forward
0 new messages