Go Down

Topic: Divide blueToothSerial Response (Read 600 times) previous topic - next topic


Please help.

I am righting an app for the Arduino Mega 2560. I want to read parts of the recvData which is char type. How do I do this. I'm new to C.

void blueToothGetData(){
  //convert char to string
  //char *chr = "this is a char";
  //string str = chr; 
  char recvData =' ';
  if(blueToothSerial.available()){//check if there's any data sent from the remote bluetooth shield
    recvData = blueToothSerial.read();

Thanks in advance guys.



"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


Bluetooth works over serial, so keep reading in the chars and store them in a array. You will need a terminating char like a period.

char DATA_Array[20];
int count =0;

In your loop()

if(Serial.available()) {
char DATA = Serial.read();
  if(DATA == '.') {
  // display data then clear it for new data
  // set count back to zero
  else {
      Data_Array[count++] = DATA;
My GitHub:


Thanks Guys for your responses.

However I forgot to mention For Sending and Receiving from the bluetooth I am using SoftwareSerial.H Here In lies my problem. It appears that A char variable as in my example above, appears to read the whole of the buffer.

For example a char in this case readData lwhen used with readData = bluetoothSerial.read() returns the entire buffer.

to test this I used the following code with out a loop, just a single call:

    readData = blueToothSerial.read();

Printed in the Monitor was an entire string.

So how can I strip readData apart.

Thanks for all your efforts in replying I appreciate it.



It's about time to post your whole program, don't you think ?

For instance, what data type is readData in your latest example and how/where is bluetoothSerial defined ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.


For example a char in this case readData lwhen used with readData = bluetoothSerial.read() returns the entire buffer.

Only when there is only one character in the buffer, which is probably most of the time, considering that serial data arrival is orders of magnitude slower than the Arduino can read it.
The art of getting good answers lies in asking good questions.

Go Up