With the code created .ino, after getting to readings, it will be stored to the .txt file (thinking if .csv would be better or just use | for separation of different data label) in the microSD. With this, I want it to be sent to the MIT app via HC-05. Also thank you <3
So the Sketch is gathering the data and saving it to the microSD?
yes but with this temporary .ino since I am still learning, only two types of label is being gathered.
Ah - is there really a need to save the data to the microSD?
You can send the data to the App directly - the App doesn't need to know the microSD card exists.
Yes I am also thinking of that but what I want to do is like for example the servo motor did 6 repetition of hitting 120 degrees. It should be shown and saved in the App. As far as what I read, the App needs to be opened for it to be shown and saved so that means the app should be connected while using the device. What I want to do is after using the device, I will just connect the app to the bluetooth of the device so that the data stored in the microSD will be sent instead of the live monitoring which is hassle for my device as its feature is just output progress tracker only after using the device and not while using the device.
Right - very good explanation!
In that case there will be several rows of data in the file - need to ensure it doesn't become too big for the card.
The data should be saved as a .txt file, without any headers (Thumb, Index etc), like this:
"4|2|5|2|6|12|1|04-07-2023\n"
"6|3|7|1|5|8|1|04-07-2023\n"
"2|2|3|7|6|10|5|04-07-2023\n"
sprintf() can be used to achieve this.
Bear in mind that you can't send the file as a file to the App, the Sketch will read the file row-by-row and the App can assemble the rows to save in TinyDB. How should the App display the data to the User?
sprintf? not serial.print()? sorry I am newbie
My goal is to make this app the 3rd screen is negligible and only the 1st,2nd and 4th. First and second screen is what I have done already except the Live Tracking because I don't know if I should still include it because the user will have to connect the device in the app when using which is not really my goal but a good additional as my aim is only output progress report after using the device. Now my problem is that when I go to check history, it should be like something like listviewer where the data is scrollable and is segregated based on their date/time. And per date, there will be 8 different data for each finger (5), wrist, and arm. Ideally, I hope that it can also be segregated per date because there might be times where the device will be used 2 or 3 times per day. Thank you so much for helping sir, am still working too and finding guide on how to do this.
Oh I see. So that's the reason why the app can't read the txt file ahmm... Atleast now I know that it is something impossible directly and not just my coding.
If you connect to Bluetooth on Screen1, you can't do anything Bluetooth related on another Screen. This is because each Screen occupies it's own allocation of memory - meaning each is like being a separate App. What we do is to use Virtual Screens instead.
When we define virtual screens, we use one 'real' App Inventor Screen (most often Screen1). Screen-sized Vertical Arrangements on it are displayed/hidden as required - they are the Virtual Screens. This is generally a better approach for multi-screen Apps, they share data without having to "pass" it between screens and it also reduces code duplication, making the App more efficient and the code easier to follow if you have to return to it at a later date.
So, instead of separate "houses", virtual screens are "rooms" of the same "house".
That was understood, but in your diagram of the App Screens, you have "Start Live Tracking".
So this means you want the App to:
-
Start the data collection via the Arduino Sketch code. The Data is Saved to the MicroSD. How often should the data be recorded?
-
Stop the data collection. When should data collection be stopped?
-
Via the Arduino Sketch code, read the data from the microSD card and receive that data via Bluetooth.
-
Save the data to TinyDB
-
Present the data as a List. You can't really shape the data the way you want to in a ListView, but you can build an HTML table in-App and display that in a WebView component.
So from the App's perspective, it has to both read and write via Bluetooth. We have to ensure there is no reading (get data) when a write (command, i.e. start or stop) is made because you only have one serial Bluetooth connect - think of that connect as a water pipe - the water cannot travel in both directions at the same time
As previously mentioned, you must connect the SdCard module to the Arduino and read it line by line.
First try to read line by line every 2 seconds and watch them on the Serial Monitor.
When you get it, improve the code to send each line by BT.
I don't have the full picture of your Project, so it's nigh on impossible to help with your Sketch in proper compilable detail.
It sounds like you have set-up a Robot Arm? Using servo motors for Arm, Wrist and five fingers? Yet if that were the case, you would need commands for movement sent via the App. So please give a full description of your Project. Note that you can't merely use 'analogRead()' if you have got seven motors. Instead, we would use the Servo library:
See Juan Antonio's diagram to ensure your circuit is correct for the microSD module:
Arduino 51.- Leer y escribir en tarjetas micro SdCard. (Use FireFox to read the page in English)
Thank you now I think that there will be like a total of 3 vertical arrangement to be used. first is for the connection of the bluetooth, next one is for the button which says check history and last one is when the button is clicked, the data will be shown.
Yes the Start Live Tracking is just an optional there. To answer the following questions:
- The data is recorded upon the set condition in the code like for example if the servo hits 120 degrees for example lets say 5 seconds, add one repetition to that certain label or part (for example wrist).
- Data collection is stopped once the device is set to its base/normal angle which is 0 for lets say 30s. This is the time the device is not being used and then will be used for the bluetooth connection to app for the history.
3-5. I haven't understand this yet sir
But yes, I discovered that the connection is half duplex, can't be at the same time only one at a time based from when I connect my HC-05 and a bluetooth serial app in playstore.
Thank you sir, will read this.
How is the device going to be set to it's base angle?
Jiii, when you reply to a post, please quote the question you are answering. Please go through all the questions to ensure you have answered them all
Yes you are correct, a robot arm. This is so far the .ino file that I am using but for the sake of testing, I made the one that I uploaded before for the testing of multiple sensors but sadly, only one reading is being displayed in the app.
The robot must be able to mirror or mimic the movement of the other hand (healthy hand) and the movement is mostly just flexion of the arm (only one axis). After using it for a time, the number of repetitions for arm, wrist, and five fingers will be stored in the microSD. Here, once the condition is met for one repetition for a specific limb, it will be recorded and the final recorded prints of repetition will be stored in the microSD (I haven't made a code with the date yet so only 7 labels instead of 8, thinking if I should do it in the app or in the arduino code itself still researching) After the session, the device is still on but is now in its stable current form (not moving) since the user will connect now the bluetooth of the device to the mobile app. In the mobile app, there will only be 1 screen/page with 3 vertical arrangements. upper most arrangement is the bluetooth connection where the user can choose in a listpicker the list of bluetooth. Under it is the lcheck history button (which should be from the bluetooth). And lastly below the load file is the history itself.
Here is the main .ino file that I will be using (this also moved the 7 motors already and tested it for one hour):
code-as-of-now-03122023.ino (2.9 KB)
Oh hello sorry, I don't know how to quote that? Do I just use "insert previous person's words"? Sorry not yet used to. Also, base angle is the 0 degrees, if the device has all of them in 0 to maybe 4 degrees for tolerance and is stay for like 30 seconds, the device will stop recording, will also start recording once a movement is detected by the sensors. I am not sure how to implement it yet but am searching still. It might take me a while to reply again sir as I will be going outside to buy components and other errands. Thank you again will definitely reply as soon as I went home.