Hello, I finally managed to connect the Bluetooth and control the movement of the two servos, however I experienced the following error in the reception and display of data from two sensors, one for pH and the other for water quality, as I see it is because It is not able to separate the data received due to how long it may be. Attached you will find the .aia project and the .ino code.
AQUA_SENSOR (2).aia (215.4 KB)
Aqua_sensor.ino (2.2 KB)
This is your output code:
// Enviar los datos de pH y TDS por Bluetooth (Serial Monitor)
Serial.print("pH: ");
Serial.print(ph);
Serial.print(";");
Serial.print(" TDS: ");
Serial.print(TDS);
Serial.println(";");
delay(1000);
This is your current Clock Timer:
Here is a draggable fix:
You might want to put those two ListViews together in a Horizontal Arrangement to save space, considering their data arrive together.
I added the Delimiter Byte=10 to work with your println(), and I fixed your broken list handling.
This is the standard Delimiter advice:
Be sure to use println() at the end of each message to send from the sending device, to signal end of message.
Only use print() in the middle of a message.
Be sure not to println() in the middle of a message, or you will break it into two short messages and mess up the item count after you split the message in AI2.
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:
ReceiveText(numberOfBytes)
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.
Some people send temperature and humidity in separate messages with distinctive prefixes like "t:" (for temperature) and "h:" (for humidity).
(That's YAML format.)
The AI2 Charts component can recognize these and graph them. See Bluetooth Client Polling Rate - #12 by ABG
To receive YAML format messages, test if the incoming message contains ':' . If true, split it at ':' into a list variable, and find the prefix in item 1 and the value in item 2.
...
Thank you very much, everything works perfectly, then I will export the data to a Google spreadsheet and that's it, thank you very much.
I need help again, add this function and out of nowhere it stopped showing the data, it doesn't even show error messages, and the .ino archive is the same.
AQUA_SENSOR (3).aia (225.1 KB)
Post your block image here, that may help others to help you quickly.
And what did you added?
I only included another command for the servo and tried to create the blocks to save in tinydb but it caused all this and proceeded to delete everything, I don't know if it is possible that it is the bluetooth module because the servos are formatted in the same way and it works on the serial monitor too All signals are observed, both those sent to the servos and the sensors.
It caused all what?
Delete what? Components? Blocks? Data?
I only delete the tinydb blocks that I had created, but from that moment on the lists do not receive data, although the Arduino serial monitor does continue to receive them.
I see you have two ListViews, one per data stream:
But the two procedures you call to update them operate on the same ListView:
I suggest:
Take the code from those procedures and bring them back inline where they were called, to see the data flow more clearly.
Change the ListView choices to reflect which one gets the data it deserves
Insert a ListView.Refresh block after the Elements replacement, just in case.
For debugging, akso copy the incoming unsplit message into a Label so you can see any incoming data surprises.
Yes I know, I saw it after submitting the post, but I simply change that and nothing works like the first time, the lists do not show the data it received in theory according to the Arduino code.
For a mystery like this, you need to set up an input message logger.
Here's 3 of them:
https://groups.google.com/d/msg/mitappinventortest/II_RlElGddU/J0q_E-2rAwAJ
ok, i understand give me a moment and if I can resolve the problem with that I will tell you
I even created a new app with the initial characteristics and the data is still not being taken, I tried another phone and still nothing, what could it be? The bluettoht sends the data to the motors without problem so I don't know if it is possible that it is the module or the Arudino, I don't know.
Show us your new code and the logging results.
I added that, however, although it shows me the time in the text field, the data taken by the arduino is not shown yet, do you have any suggestions? I've even tried another Arudino, another cell phone and the same app and still nothing works that I've tried.
You might need to increase the Height of CampodeTexto1, or switch it to multiline, to see its full content.
You are asking to show a lot of data on your screen, using height percentages on a scrollable screen may cause errors.
You can squeeze a lot of data into the Elements of a List Picker, without filling up the Screen.
I posted three loggers to this board recently.
One of them was to a List Picker.