I am working on a device that will send data from Arduino to Android and not sure what is the best way of doing such task. Is this the right way or there is some better/more efficient approach?
void setup()
{
Serial.begin(115200);
}
void loop()
{
float tachometerValue = analogRead(A0);
float voltageValue = analogRead(A2);
int value1 = 10;
int value2 = 20;
tachometerValue = ((tachometerValue / 10) * 10) * (10.0 / 1023.0);
float vout = (voltageValue * 5.00) / 1024.00;
float voltValue = vout / (1000.00 / (10000.00 + 1000.00));
if(voltValue < 0.09)
{
voltValue = 0.00;
}
char buffer[50];
char voltValue_temp[5];
char tachometerValue_temp[5];
dtostrf(voltValue, 4, 1, voltValue_temp);
dtostrf(tachometerValue, 4, 1, tachometerValue_temp);
sprintf(buffer, "%d;%s;%s;%d", value1, tachometerValue_temp, voltValue_temp, value2);
Serial.print(buffer);
}
I am using Xamarin forms and Bluetooth to receive data on the other end.
I am getting data in this format for some reason sometimes:
;2.17;0.00;06;2.17;0
This is not what has been sent.
Here is what I see in my PC serial otput:
10;9.64;0.00;20
10;9.64;0.00;20
10;9.64;0.00;20
10;9.64;0.00;20
10;9.65;0.00;20
10;9.64;0.00;20