Well it is a bit trickier.
Use a call bluetoothclient.receivetext and set th number of bytes to -1, which reads until delimiter byte is received.
Mmake sure you set the delimiter byte - I used '13' which is carriage return... ohh you might find this useful -> http://www.asciitable.com/index/asciifull.gif
What's more, it's seems there is no serial timout implemented yet and the app freezes if it doesn't receive anything. To solve that I set up the app to first send a 1 byte number to the arduino, when arduino receives that it sends its data.
Here is an app I created to receive data from a 1 wire temperature sensor (ds18b20). I think if you upload it into the MIT app inventor you should be able to work this out and modify it.
http://speedy.sh/qscGe/bluetoothforarduino-app-temperaturereadings-1.zip
and arduino code (temperature sensor is connected to digital pin 2)
#include <OneWire.h>
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
//Temperature chip i/o
OneWire ds(DS18S20_Pin); // on digital pin 2
byte serialA;
void setup()
{
// initialize the serial communication:
Serial.begin(19200);
// initialize the ledPin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
if (serialA == 49){float temperature = getTemp();
Serial.println(temperature); serialA = 0;
}
}
float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius
byte data[12];
byte addr[8];
if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -100;
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1000;
}
if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return -1000;
}
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
for (int i = 0; i < 9; i++) {
data[i] = ds.read();
}
ds.reset_search();
byte MSB = data[1];
byte LSB = data[0];
float tempRead = ((MSB << 8) | LSB);
float TemperatureSum = tempRead / 16;
return TemperatureSum;}
void serialEvent(){
serialA = Serial.read();
}
The code is a bit messy I admit but it does work