From microsd in arduino (either in txt or csv file) to MIT

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:

  1. Start the data collection via the Arduino Sketch code. The Data is Saved to the MicroSD. How often should the data be recorded?

  2. Stop the data collection. When should data collection be stopped?

  3. Via the Arduino Sketch code, read the data from the microSD card and receive that data via Bluetooth.

  4. Save the data to TinyDB

  5. 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 :upside_down_face:

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.

http://kio4.com/arduino/51_lectorsdcard.htm

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:

  1. 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).
  2. 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 :face_with_monocle:

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.

About Arduino UNO + Bluetooth + SdCard

You just drag the cursor over the words you wish to quote, they are highlighted and a pop-up menu offers the chance to Quote - click it and it even starts a post for you :grin:

1 Like

Thank you <3 . I just got back home and started researching but can't still read multiple sensors from before I left.

I tried this but my problem is that, there is no label for what each data before the comma (,) is so I am still trying to do what to do.

Labels are unnecessary - the data is always collected in the same sequence. Including labels complicates App reception via Bluetooth as each BT packet only carries a payload (your data) of 20 bytes - so best to keep the data size as small as possible and keep it practical, as per my example App Inventor file.

Sensors or Servo Motors?