Service UUID and characteristic UUID problem

image
image


Is there any other default UUID of arduino Nano 33 ble? How can i solve this problem? Thanks.

Dear @HANG, welcome to the Community.
Have you already had a look (i.e. a search) to the previous posts in the forum ?
There are many hints regarding Nano33_BLE-AI2 communication.
Just one example is : App inventor - Arduino Nano33Ble communication issue - #9 by darnell.
Maybe you can find the solution, there.
Another (huge :slight_smile: ) source of information is @Juan_Antonio's web site KIO4.com
Best wishes.

1 Like

Thanks for your help! I tried a simple BLE example program and it success to connect and transfer data with the following blocks.


However, I change back to my original program (include machine learning model), the connecting time of BLE will become very long (around 10s), therefore, it will show the runtime error problem. After 10s, the transfered data still can sent. (in nRF connect app) What can i do to the blocks to solve this problem?

Dear @HANG ,
sorry but I don't understand well your last post.
You've been able to send/receive data with the sample blocks you posted with your Nano33 code, or you modified also the Nano33 code with a simpler one ?
The machine learning code is a part of your app or of your Nano33 ? This second question is to try to understand which of the two codes (app or Nano) is introducing such a lag (>10s) in the communication. And how have you measured such delay ?
Another doubt is : the error message is the same as before ?

I agree that you'd like to receive answers and a solution, instead of other questions, but if you have been able to make the sample working, can you start from that sample and modify only a few lines of code at a time so to build a functioning system, starting from a safe basis, by adding "brick over brick" ? With this approach you can also identify when your code starts to introduce the delay, and which is the part of the code that creates the fault.
Cheers.

image
Here is the simple program that I used to check the UUID and apps block. This one can connect with the app through BLE and transfer the data successfully. The block are just like here.

However, I replace the machine learning code in here such like the photo below.
image
The block did not change. When I clicked the connect button in nRF connect or the MIT app. It will show connecting..... and the connecting time is around 10s. The previous simple program just 1 to 2 seconds. After 10s, the characteristic will show and start receive data in nRF connect. If using the MIT app, it will show the same runtime error message. Will the connecting time become longer because of the program size become larger?

in your first chunk of code there is the line:
TestCharacteristic.writeValue(tempMessage); that sends to the app, while in the second snapshot there isn't.
I suppose you embedded this line for sending the "true" message in your machine learning code, otherwise it is missing any message sending to the app.
To be sure how much time your machine code algorithm lasts, you can put a Serial.println("Begin"); and a Serial.println("End"); to the Serial Monitor with the timestamp enabled, at the beginning and at the end of your algorithm.

So the answer is: "probably" yes, the communication can be delayed (or even stopped) by the machine learning code. If you find that this is the root cause, as a temporary patch, you can put a "live" message sent, for example, every second, by the Nano to the app, to avoid the timeout.

Yes, In the machine learning code, after the classification result is calculated, it will send to the app by TestCharacteristic.writeValue(Result) in string.

And the problem actual situation is When I click the connect BLE button, the program inside the while (central.connected())) will start to run immediatly. But the nRF connect will show connecting.... so long. It is just like it contain a delay in BLE, the machine learning program is still running in arduino.

And the problem actual situation is When I click the connect BLE button, the program inside the while (central.connected())) will start to run immediatly.

You say that because you "see something" ?
I mean: do you send a message to Serial Monitor ? Or you switch on a LED ?
Instead of sending the "result", which is variable I guess, can you send again "Hello world" ? Just to see if there is a problem of data formatting ?
Do you have a neverending loop in your machine code algorithm ? Or a while-do that is lasting so much ?

EDIT neither your app, nor the Nano33 codes, show "Disconnected" ? you just get the runtime error ?

Yes, I connected a OLED display to show the result. Once I connect the BLE, the oled display immediately show the result in 1 to 2 second while the BLE show still connecting in app.

Second, using a Hello World to replace a variable message, it show the same problem.

No. the machine learning code do not include any looping. Only the while (central.connected())) make it to do classification continously.

It will not disconnected. The arduino is still running and keep showing the result on the oled screen. Only the app will show runtime error and cant connect to a correct UUID characteristic to receive message.

Hmmmmm....an OLED display ?
I had in one of my old Arduino projects a weird problem with the OLED driving which was extremely RAM memory consuming because the OLED screen was mapped in the Arduino RAM memory (i.e. 1 pixel = 1 byte of RAM).
I've got no errors from the compiler but the Arduino code started to have strange behaviours due to a too large memory usage when using Strings (which on their own are RAM consuming).
Can you try to avoid to drive the OLED ? (I mean do not load its library and comment out all the related code ?).
(I need a coffe now ... :thinking:)

Sorry to brother you so long :dizzy_face:

I tried to remove all other things in the program (only have BLE and machine learning now). It still have the same problem.

Also, I tried to place the learning model code outside just like the below photo.
image
It do not have any problem.

Take it easy, you don't bother me !
I'm sorry that I've not been clever enough to help you 'till now.
Anyway: if you take out from the BLE loop the machine learning code, it works (if I've correctly understood).
Then, there is something in the machine learning that is interfering.
The ei_printf() lines are those related to the OLED ? Have you tried what I said previously : i.e. have you commented-out (or removed) all the instructions relevant to the OLED ? Comprising the load of its library ? (I suppose that for driving the OLED you have an #include )

Yes, all the oled library, code, circuit also removed. The ei_printf is just similar as Serial.print.
I will try to check for the machine learning code. Thanks!

OK,
if you want that I give a look to your algorithm, you can PM me. :smirk:
Cheers.

1 Like