Saving a .txt file to a micro SD card and sending it via bluetooth

Hi guys, I have a project consisting of 3 water quality sensors; temperature, pH, & turbidity sensors. I also have a HC-06 bluetooth module, a DS3231 RTC module, and a Catalex microSD card adapter. All of these are connected to an arduino mega. The idea of my project is, everytime my sensors are used, their readings will be recorded in a .txt file and then stored inside a microSD card. This .txt file will also include the time when the sensor was used. I also want to send these saved datas (.txt file) to another bluetooth device whenever these devices connect to the bluetooth module. I'm kinda new to Arduino and data logging to microSD card is all I have researched and understood. I still have no idea about the bluetooth part. I also can't seem to find similar projects here in the forum. Is my idea feasible? Also, do I have the right modules? Any help would be appreciated. Thank you so much!

Instead of saving the data in a .txt file, try storing it in a .csv file.
CSV allows for much more visualization options and you can dedicate columns to values, making the data more presentable.

If you can write SD card file to a serial port (serial monitor) you are pretty much there. Bluetooth is just a transport, like a piece of wire. You have more than one hardware serial port, on a Mega, to use.

Yes, it is feasible. The Dumpfile example in SD section of the IDE is really all you need. As above, if you format the file as CSV, you can use it in Excel etc.

For bluetooth, you might find the following background notes useful

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

There is an example of file management and download via bluetooth to the phone.

Thanks everyone, I managed to just read a .txt file that I saved in a micro SD card and that’s alright already.

My next problem is if there’s any BT code for arduino that we can use for connection notifier? Like if I connect my android phone to my HC-06, the HC-06 automatically sends me a “Bluetooth device connection successful!” message to my phone. I understand that if I use the “if (BT.available())”, it will send me my desired message EVERYTIME I send data from my phone to HC-06. But I want the message to only be sent once, and that’s whenever I connect my phone to my HC-06 only.

Also, is there any BT code for arduino that will terminate the connection of the my HC-06 from the terminal connected?

I still can’t find anything, that’s why I had to ask here again. Sorry if there’s an existing topic about my new problems here already. >__<

You are probably looking for the wrong thing, and theorising too much as well. When you are connected, Android will tell you, and a "connection notifier" from HC-06 is unwarranted.

There is not likely to be a termination of connection message, as bluetooth probably cannot tell the difference between disconnection and simply not sending anything. There may be ways around this, but certainly not with an HC-06, and you need to consider whether you really need do it first. I'm betting you don't.

I see. Well at first, I did try putting the notification message inside my void setup as a "BT.print", right after "BT.begin()". It usually works the first time my phone connects it after uploading my code to my Arduino and turning it on. Unless I turn my project off, turn it back on, and reconnect again, I will only see the message once. But my project will have to run for long hours, so when I disconnect and reconnect my phone, I won't see that message anymore. This is kinda important to me 'cuz I also want to place the instructions right after the connection message, so it would really be great if I could get to read the instructions from time to time every after I reconnect.

Ah yes, apparently, the Bluetooth module cant tell the difference. I guess I'll just remove that feature in my project. Yep, I really don't, I need to stick with the HC-06.

RikuIan:
I did try putting the notification message inside my void setup as a "BT.print", right after "BT.begin()". It usually works the first time my phone connects it after uploading my code to my Arduino and turning it on.

The only time that will ever work is when the phone is listening before Arduino is sending.

Unless I turn my project off, turn it back on, and reconnect again, I will only see the message once.

That is because it is in Setup

I also want to place the instructions right after the connection message, so it would really be great if I could get to read the instructions from time to time every after I reconnect.

If you want to see a splash screen on the terminal, you can always get Arduino to send one as a file dump on receipt of a user signal. This might be a good way to go, particularly for those who won't bother, and also has the advantage of having that screen available at any time.