Properly send multiple values over Bluetooth

I have assembled simple analog reader on Arduino UNO platform and sending data through the Bluetooth to Android phone. I am facing strange problem with values not getting into Android phone. I have created an application on Xamarin Forms. On another phone I have downloaded Serial Bluetooth Terminal and it seems to be working without problems so far. So first question I would like to ask, am I sending data the right way from Arduino?

I am using BTserial.begin(115200);

Here is my Arduino code part:

void loop()
{
  int tachometerValue = analogRead(A0);
  int fuelValue = analogRead(A1);

  sensors.requestTemperatures();
  float airTemperatureValue = sensors.getTempCByIndex(0);
  
  tachometerValue = ((tachometerValue / 10) * 10) * (10.0 / 1023.0);
  int airTemperature = (airTemperatureValue / 10) * 10;

  String outputToBT = String(tachometerValue)+","+String(airTemperature);

  BTserial.print(outputToBT);
  //Serial.print(outputToBT);
  //Serial.print('\n');

  delay(300);
}

Here is a record of my Xamarin app on Android phone, I am sending three values here separated by comma:
jumpingvalues

IMO, no, because you're using String for no very good reason.

How it should be then? I might have integers or floats to send, anyway numerical data.

Why not simply use BTserial.print? (Or println)

I think I am already using BTserial.print, but my question is how to combine and send two values or more values in a proper way?

You are, but not simply.

Maybe the newline that println sends would help you.
Or use a unique delimiter of your choice.

Take a look at Serial Input Basics tutorial.

On another phone I have downloaded Serial Bluetooth Terminal and it seems to be working without problems so far

If the terminal can read your messages but your custom app can not, then I would be focusing on how you are reading what BT sends. I don't think that format of the transmission is the root cause of your issue.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.