App inventor TinyDB(data base)

I'm going to use tinydb. I want to save and load measurements from Arduino.
Please let me know if there is anything wrong.

Plz help me.

1 Like

AI2 and this board unfortunately can't translate your variable names to English.

It might be a while for some one who can read your language comes along to help.

In the meantime, here is some standard BlueTooth Text Delimiter advice for you to read...

Please see the Delimiter article in FAQ

Be sure to use println() at the end of each message to send from the sending device, to signal end of message. Do not rely on timing for this, which is unreliable.

In the AI2 Designer, set the Delimiter attribute of the BlueTooth Client component to 10 to recognize the End of Line character.
Also, return data is not immediately available after sending a request,
you have to start a Clock Timer repeating and watch for its arrival in the Clock Timer event. The repeat rate of the Clock Timer should be faster than the transmission rate in the sending device, to not flood the AI2 buffers.

In your Clock Timer, you should check

  Is the BlueTooth Client still Connected?
  Is Bytes Available > 0?
     IF Bytes Available > 0 THEN
       set message var  to BT.ReceiveText(-1) 

This takes advantage of a special case in the ReceiveText block:

Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.

If you are sending multiple data values per message separated by | or comma, have your message split into a local or global variable for inspection before trying to select list items from it. Test if (length of list(split list result) >= expected list length) before doing any select list item operations, to avoid taking a long walk on a short pier. This bulletproofing is necessary in case your sending device sneaks in some commentary messages with the data values.


I see in your Blocks that the code for receiving the data is still wrong. If you want to receive all of the data, use the maths Block '-1'. Third time I have mentioned this. :upside_down_face:

  1. How many measurements to be saved, how often will they be saved and over what length of time?

  2. When retrieved from TinyDb, what should the App do with the data?

I get an error when I use -1 block. I want to save all the measurements.

Show us the error code.

So that is just the value - but how many times will it be saved during the run of the App?

Note, you do not need 'Clock 2' to get the date, you can do that in the 'Clock 1' Block. I can't see the format you need for the date as it is off-image, but you should be able to make the format without needing to extract a portion of it later. Since it is to be used as a Tag, it must be prefixed with a character.

Use the 'Screen Error Occurred' Block to see error messages, their error number and component/function with the error:

GetErrorInfo.aia (31.6 KB)

You can also set this in a TextBox to copy paste if required. Just replace '<br>' with '\n'