Hi everyone, I know similar threads have popped up on this forum a few times but none seem to provide a simple solution to this problem and I was wondering if someone could help me out.
I need to receive data from an Arduino, the data on the Arduino that I'm sending out via BLE is a double. However, when I receive this data In MIT App Inventor through functions register for bytes and when bytes received I am limited to either 128 signed 256 unsigned. I need these values to reach at least 2000 signed.
When I try use functions in MIT App Inventor like doubles received or shorts received I simply get no data coming through. I've seen other users output multiple bits of data with multiple characteristics from the Arduino but surely there is an easier way.
I'm not sure if my Arduino project is necesary but here is the function which outputs the data:
void outputScale()
{
int t, i, n, T;
n=7;
i=0;
double val, sum, sumsq, mean;
float stddev;
float oldVal;
while (i<n)
{
val = ((scale.read() - scale.get_offset()) / scale.get_scale());
if (val != oldVal)
{
WeightLevelChar.writeValue(val); // and update the battery level characteristic
oldVal = val;
}
sum += val;
i++;
}
mean = sum / n;
if(i>=n){
i=0;
}
Serial.print(val);
Serial.print("\n");
lcd.setCursor (0,1);
lcd.print(" ");
lcd.setCursor (0,1);
lcd.print("weight: ");
lcd.print(mean);
lcd.print("g");
}
Here are screenshots of my bytes received functions. As mentioned when I use the exact same blocks but floats received or shorts received I simply get no data.