Glitched data printing using bluetooth

wait is this the code in arduino?

ok what if my project has 4 modes, each mode has only one number

ohh i get it, its like this right?

im not really understand this, can you show me an example of this?

can you show me an example of this, i do understand this but dont really know what to do with this useful information

it solved the problemm!!! but can you show me more about how to put like strings, am i simply gonna put the strings inside the code then print it out just like the numbers?

can you show me how to print more than 1 values?, the reason why i decided to give this example to you is because i have my big project but theres a problem, its in Vietnamese so i was too lazy to translate everything about it and then give it to you. anyways thank you so much for helping me out, really appreciate you! :hearts:

Here are some examples in blocks for you, starting with the simplest case and working on upwards in complexity:

Here is a simple BlueTooth text receiver sample, for single value per line:
blocks
initialize global message to


You pretty much have that already, but you will need to capture into a message variable before you can get to the next level, multiple readings per message:

Here is an updated blocks sample illustrating these ideas ...

BlueTooth_delimiter_sample.aia (3.4 KB) global message

P.S. These blocks can be dragged directly into your Blocks Editor workspace.

Dragging blocks

In your case, you would need 4 Labels, for x,y,z,power results, and
you would need to print 4 values separated by commas ending with a println() to send the message.

Do you plan on graphing the values in the app?
I have another sample for that.

2 Likes

The more text you send, the harder it is for the receiver to decode it.
Keep it simple, and follow a pattern like comma separated numbers if you can.

The receiving app can always add its own text for display later.

1 Like

This sample is ONLY for if you need to graph 4 values as they arrive:

If you want to send your temperature and humidity on separate lines, you could alternatively send tag:value pairs, like
T:98.6\n
H:100\n
which would arrive individually if you use Delimiter 10 (\n).
Your AI2 logic would look like

if BT.bytesAvailable > 0 then
  set local message to BT.ReadText(-1)   (to get only 1 line)
  if contains(message, ":") then
      set local splits to split message at ":"
      If (select item 1 of splits) = "T" then
         set LabelTemperature.Text to (select item 2 of splits)
      else if (select item 1 of splits) = "H" then
         set LabelHumidity.Text to (select item 2 of splits)
     else set LabelWhatHappenned to local message
end if

I do not have a Charts sample for this yet, but the capability is documented way at the bottom of the Charts Usage Guide in

1 Like

Thank you so much, this will be very useful for my current project and also my future projects!

I dont have

so as long as i keep it really simple like this right?
Mode: Force
Result: 123,45

That's not simple.
It looks complicated to me.

Its info is spread out over multiple lines, needed for a single reading of Force?
The word Result is just boiler plate, causing extra work to strip it off.
The comma between 123 and 45 looks suspiciously like a French decimal point.
Which is it, a list separator, or a decimal separator?

Why not just send
Force:123.45
?

1 Like

ohh ok, thank you so much for the advice, ill try my best to simplified my entire project

what about i have lots of words to print out:
it must be like this
Force mode activated | Result: 123.45

sorry for misunderstand you, actually it is 123.45 not 123,45
its a dot, not a comma, sorry for that

is this still being complicated or simplified?

The text you announced in the app doesn't need to come in from the Bluetooth connection.

You could use a single letter like F to identify the number in Bluetooth, then lookup the long text for F in a dictionary.

1 Like

So i changed the delay between each time it prints out, instead of using only 10ms, i changed to 150ms, so i found out that the larger delay, the stability is bigger
Thank you for your help

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