Android app can't read all bytes from Arduino HC-05

I am having an issue, while the android app is asking data from Arduino. The connection is successful and Arduino reads the data from android normally. Then, upon the request, the Arduino generates the sensor’s values and sends them to the android. Though, the android gets the message it always is missing the last byte. Here is the code for Arduino.

The idea is to wake up Arduino every 15 minutes and get the values. That’s why there is a transistorFlag which tells deepSleep() if it should kill the power on HC-05.

if (rs == "hello" || rs =="dt")
  Serial.println("Setting transistorFlag");
  transistorFlag = 1;
  getSensorValue(); // generates a value to global N_AVERAGE
  int battery = getBatteryLevels();
  char buffer[256]; // could be less
  Serial.print(buffer); // debug buffer
  delay(1000); // wait for transmition to end.
  rs = "-";
  deepSleep(); // kill HC-05 for 15 minutes

On the other hand, on the android still doing the requests manually, though, with Worker class, it should work the schedule part, the code is the following:

public void run() {
    Log.i(TAG, "BEGIN mConnectedThread");
    byte[] buffer = new byte[256];
    int bytes;
    String print = "";
    // Keep listening to the InputStream while connected
    while (mState == STATE_CONNECTED) {
        try {
            if (mmInStream.available() > 0) {

                // Read from the InputStream
                bytes =;
                for (int i = 0; i < buffer.length; i++) print += " " + buffer[i];
                System.out.println("Buffer (size=" + buffer.length + " content:" + print);
                // Send the obtained bytes to the UI Activity
                mHandler.obtainMessage(Constants.MESSAGE_READ, bytes, -1, buffer)
            } else
        } catch (IOException e) {
            Log.e(TAG, "disconnected", e);

In a thread, read the data and send them to UI with the Handler. Though the result is the following.

Arduino is supposed to send this dt:-300,125 and the android app is getting this dt:-300,12. Also, the debug with the buffer content: 100 116 58 45 51 48 48 44 49 50 0 0 0 …

Any ideas?

Also, in order to reduce the power consumption while device is waiting, except delay and powering off the HC-05 module, do you have to suggest anything else?

I make it that its missing the last two bytes. There's a newline in your sprintf string.

Have you tried waiting longer, sending more newlines, that sort of thing, and is it always missing the
same number of characters? You know about availableForWrite() which can monitor the outgoing serial buffer?