Hello, I am trying to send a txt file with different voltage values (that was taken from a sensor) to an android device. Currently my txt file is 3.3Mbs and it takes me about 1 hour to transfer that data. I am using an Arduino Uno, ethernet shield (for the sdcard part), bluetooth shield ( i have both the HC-05 and HC-06) and I am using the android app called Blueterm to test all of this. So, my questions are:
Why does it take this long to transfer the data?
How can I speed up the time it takes to transfer the data?
Will changing the bluetooth's baudrate make a difference?
If I were to use a Arduino Mega would I get better results?
Here is my code:
#include <SoftwareSerial.h>
#include <SD.h>
int state = 0;
int flag = 0; //Makes sure that it doesnt keep reading the file after closing it
int Tx = 2; // Connect the Bluetooth Rx to this pin
int Rx = 3; // Connect the Bluetooth Tx to this pin
File Datafile;
SoftwareSerial bluetooth(Rx,Tx);
void setup()
{
// sets the pins as outputs:
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
bluetooth.begin(9600); // Default connection rate for my BT module
pinMode(10,OUTPUT); //For the pin set up reffer to Gammas code
digitalWrite(10,HIGH); //For my own purposes..
}
void loop()
{
//if some data is sent, read it and save it in the state variable
if(bluetooth.available() > 0)
{
state = bluetooth.read(); //listens to the android device for an input
flag = 0;
}
// if the state is 1 data will be sent to the android device
if (state == '1')
{
if (flag == 0)
{
bluetooth.println("testing text");
sdreader();
flag = 1;
}
}
}
void sdreader()
{
bluetooth.print("Initializing SD Card....");
if (!SD.begin(4))
{
bluetooth.println("initialization failed!");
return;
}
bluetooth.println("initialization done.");
Datafile= SD.open("1.TXT"); //Change the file name to the file your using
if (Datafile)
{
bluetooth.println("1.TXT");
while (Datafile.available())
{
bluetooth.write(Datafile.read()); //Reads the file line by line and sending it to the bluetooth device.
}
Datafile.close();
bluetooth.println(millis());
}
else
{
bluetooth.println("error opening DATALOGH.TXT");
}
}