Trouble with writing to my arduino nano with BLE

arduino code.txt (1.2 KB)
ble_communicationselect (1).aia (193.0 KB)
Hello, good day.
i am trying to make a arduino based car which uses a app for control.
i have so far managed to get the Arduino code working on my arduino nano 33 iot
but i am having some anoying problems with the mit inventor code.

it has work so far, connects to the device but gets stuck on the first writewithresponse, also gets stuck on write without response. i have tested my arduino code with the nRF connect app and it is able to receive the value's so the arduino code shouldn't be the problem. tho i am not understanding why the mit inventor code is not working, i've looked around for quite a while but am not finding any solutions.

Thank you for your time and effort in advance

I take issue with the positioning of your BLE WriteWith Respose blocks in the ListView1.AfterPicking event after the BLE Connect request.

The Connect takes time, and the following while loop will immediately fail.

A better place to put those blocks would be in the WHEN BLE Connected event block,

or in a Button.Click event.

thank you, indead this is the problem, i have used 2 buttons to send the data and it does work now.
would you know a method to make sure that it can send data quicker tho?
since im not fully understanding the clock and timer function (just copied it). and might there be a way to initiate write right after the arduino has confirmed via the response (if that is even possible)?

thank you for your time

I'm not experienced with BLE, so all I can provide are general advices based on the AI2 event model.

There are events that fire when responses arrive (most likely), and they would be good places to do more writes.

That approach avoids machine-gunning the other device , feeding it data only as fast as it can respond.

I defer to people who have actually used BLE for the rest of your question.


wel i have changed how it works, when using the buttons seperatly it does work, but i am not getting the clocks to delay the execution of the write, it just gets stuck and i don't even see the 10 "written" by the change label text. i do not know what is happening and why.

to fire a response when i get a reply would probably require reading and writing back from my arduino to a value the sliders cannot reach and to then see if the value's are this to then write another response, this should work but the clocks seem like a very handy thing to know.

and indead machine gunning the device with info only makes the source of said info get stuck so... hehe

thank you for your time and effort

ok so i have been testing around a little more and.... it doesn't have to do with the time in between....??
when i remove the loop and timer. it works, i can spam the button all i want, even if the 2 writes are right after each other they both work, would you know a solution to this loop problem? (sorry that im changing subjects and using this as a information source)

image

thank you for your time and effort

Looping in AI2 is only useful for traversing lists, not for spending time or for waiting.

Use Clock Timers for alarm clocks and metronomes and things you want to fire with time delays between them.

You can have more than one Clock with its own Timer event, or you can use deadlines(SystemTime in ms) in global variables to space things out in time.

wel thank you for the effort, i was able to fix and make this work via using the position changed function from the sliders i am using for the value's and connected a timer to this so it diden't get machine gunned with writes

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