Sending large string via serial

I have an Atmega328 connected to a HC-05 Bluetooth module which acts as a serial device and easily lets you transmit and receive data to and from my computer. Connected to the microcontroller is also an LCD which displays all output received by the bluetooth module.

I have paired my computer with the HC-05 module and I can send strings of data through a serial prompt which is received by the Bluetooth module and displayed onto the LCD.

This is the section of my code that reads the bluetooth module data and displays it through the LCD.

while(BTSerial.available()) {

lcd.print(BTSerial.read());

}

This works great however soon as I send say an 80 character string then only around 64 characters make it to the other side and the rest are not displayed are found through BTSerial. I think this may have something to do with buffer size being 64 bytes but I'm unsure.

The problem is in the rest of your code so POST IT!

Mark

Serial data is send from my computer through the HC-05 Bluetooth module which just acts as a serial device and connection to the computer is initialised and maintained by the module without talking to the Arduino.

I've sent serial data though the Arduino serial prompt and various other serial applications to the Bluetooth module and they all worked fine however I couldn't send large strings e.g. 80 characters

#include <LiquidCrystal.h>
#include <SoftwareSerial.h>

SoftwareSerial BTSerial(7, 8); // RX | TX

//Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(A4, A3, A2, A1, A0, 13);

char dataChar;

void setup() {

//Setup LCD
lcd.begin(20, 4);
lcd.setCursor(0, 0);

//Initialize Beeper
pinMode(9, OUTPUT);

//Set defualt back light
analogWrite(11, 200);

//Setup serial
Serial.begin(9600);
BTSerial.begin(9600);

}

void loop() {

while(BTSerial.available()) {

dataChar = BTSerial.read();

lcd.print(dataChar);

}

}

What happens if you change the line

while(BTSerial.available()) {

to

if (BTSerial.available() > 0) {

...R

It's probably because the Serial input buffer can contain only 64 characters, and you don't extract them fast enough so it overflows. Instead of doing an lcd.print for each character as it arrives, store them in a big array and print that when the transmission is finished.

I think the Serial buffer size is 64 bytes...odd coincidence? Try increasing its size and see what happens.