MIT CharMaker1 extension ultrasonic sensor data graph

Hello Everyone, I am trying to show a graph of the data that is recorded by the sensor. As of right now, I haven't added how long I want to register or how to start the record and when to stop, but I wish to do that once I figure out why I cannot see the graph.
I attached all the screens I have right now. If anyone finds the heart to help me, I would deeply appreciate it. The Arduino code has been separated since I was testing if the Bluetooth communication worked; at some point, I will want to put them together, probably in a switch case. Regardless any suggestions are again appreciated.

fellow MITappinvetor

Here is an example of sending random number from Arduino to App via Bluetooth HM-10

Remember that there is a delay between sending the message and displaying the data on the app screen, due to the transmission and the code.

You might want to label your data stream with a view as to how hard it will be to separate out the numbers on the receiving end.

Hard:
Distance: 55 cm
(Needs separation at spaces on both sides of the 55)

Easier:
DistanceCM:55
(Separation at the ":" easy with a text split block, item 2 of the resultant list has the 55, item 1 can be checked for identification of the data stream (Distance, humidity, temperature, etc.))

Save your user-friendly formatting for display until you need to display or graph the data.

1 Like

Do you mean in the Arduino code?

Yes.
When one program (or person) speaks to another, they should choose what they say to make it easily understandable to the other.

1 Like

The error I get is this one:
"Argument #7 (edu.mills.appinventor.ChartMaker@55222) to 'edu.mills.appinventor.ChartMaker.DrawLineGraph(java.lang.String,java.lang.String,java.lang.String,com.google.appinventor.components.runtime.util.YailList,com.google.appinventor.components.runtime.util.YailList,com.google.appinventor.components.runtime.WebViewer)' has wrong type (edu.mills.appinventor.ChartMaker) (expected: com.google.appinventor.components.runtime.WebViewer) Note: You will not see another error reported for 5 seconds."

I changed the arduino code to this:
const int pingPin = 6; // Trigger Pin of Ultrasonic Sensor
const int echoPin = 7; // Echo Pin of Ultrasonic Sensor

void setup() {
Serial.begin(9600); // Starting Serial Terminal
}

void loop() {
long duration, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
cm = microsecondsToCentimeters(duration);
Serial.print(cm);
Serial.print("\n");
delay(100);
}

long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}

It seems to me that the problem is elsewhere... I really do not know how to proceed...

Also another thing I noticed is that the first time it writes in the box it gets [1,2,3,4,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] and after I click on testble I get [91,57,49,44,32,53,53,44,32,53,49,44,32,52,52,44,32,51,50,44]

I followed mostly this tutorial (https://appinventor.mit.edu/explore/blogs/karen/2016/08/heart.html) to see if I could get the data to show live as it does here. And my goals is to see a graph like this one when i click on graph (https://www.arduino.cc/en/Tutorial/Genuino101CurieBLEHeartRateMonitor)

Does anyone have had any chance to review it? I think the issue is the type of data on arduino. Or do you have any idea of what datatype does the mit App inventor wants? I tried all the options ble has (bytes, float, integer, short)

You are sending your data with a print command, which sends text.

However, you used a Receive Bytes command to request Bytes, so the input arrives as a list of numbers that you have to look up in the ASII table to decode back into text.

If you send text, request text on the other end.

Thank you for the explenation. Which command does that?
I don't seem to find the correct one in this list (http://iot.appinventor.mit.edu/#/bluetoothle/bluetoothleintro)
Do I have to get another extension to translate the value? Or should I chance to one of the type in here?(https://www.arduino.cc/reference/en/language/functions/communication/serial/print/)

Go back in this thread and read

Review how it sends and receives data.