I have randomly generated 4 values in the Arduino with ESP32. Now i want to map the incoming 4 values (via bluetooth) in a graph. I can able to receive the values in my app but i cannot able to draw a line graph for it.
MIT data recieve|690x162
This is the one I have done. I am getting 4 values now i need to seperate the 4 values and draw line based on that random values.
can anyone please help me with that.
There are numerous ways to create simple graphs. Here are some ideas from the old AI2 Forum.
What you do depends on what the four values you receive look like. How about providing an example of the data received from you Bluetooth. If we knew that, someone could provide specific advice.
The simple way would be to use a Canvas and plot points on it.
The 4 sensor values i need to plot in the below canvas. i can able to receive the data but i dont how to plot the incoming values seperately
Kindly help me regarding this, I have gone through the FAQ but i am not getting a precise solution for it. How can i draw the graph for those incoming sensor values.
You will not find a precise solution and will have to work out the details.
Here is possibility to plot the results of ONE sensor [Dynamic Graph] pdrepared by Juan Antonio (https://groups.google.com/forum/#!searchin/mitappinventortest/dynamic$20graph|sort:date/mitappinventortest/q-DGa_PVo_o/9yW89uL-BwAJ) You could try it out plotting just Sensor1.
You want the result from FOUR sensors simultaneously. That is more difficult. I am not sure how you would do that using the example.
Your data can be represented in a csv file like:
1,11,29,39 , These are the values of Sensor1, Sensor2,Sensor3,Sensor4 at one instant.
Later, these values might be
7, 15, 22,45 or something like that. These two instants of Data can be represented in a List of csv files.
Each value can be referred to as an index in the List . Values from Sensor1 would be index 1 in the List; Sensor2 would be index 2 etc. and each parsed from the csv to be plotted (perhaps in different colors).
Plotting in real time is more difficult than plotting from a List. Capturing a series of values on your Android and saved as a List and plotted using the List is an easier option.
I don’t have a Bluetooth/Arduino so I have no idea how you would do this. The link shows how you could do it with one sensor.
What have you tried?
new_try (1).aia (7.9 KB)
We are trying to read CSV file and get the values to plot the graph. But when we tried reading file it says, “Runtime time error: The operation list to csv row cannot accept the arguments: , [“Sensor_1 = 3,Sensor_2 = 10,Sensor_3 = 29,Sensor_4 = 38Sensor_1 = 3,Sensor_2 = 10,Sensor_3 = 29,Sensor_4 = 38”]”.
Kindly help .
Here is an example using google visualization charts(html)
You will need to organise your data so that it is formatted as shown in the html, then pass this to your html file using the webviewstring
To be able to graph all four sensors, you are going to need the data in a form like this:
rather than (Sensor_1 = 3,Sensor_2 = 10,Sensor_3 = 29,Sensor_4 = 38Sensor_1 = 3,Sensor_2 = 10,Sensor_3 = 29,Sensor_4 = 38) otherwise you will have to strip out the Sensor_1…Sensor_2 references. (When you use data like this Sensor_4 = 38Sensor_1 = 3 without a data separator between packets, you will have issues . This form works fine for a single data stream. Your app is supposed to have four data streams. The packets need to have a separator between each packet.
When you have a List, the first item is known to be sensor1 data, the second, sensor2 etc. Th text id’s are a distraction. You will have to remove them to be able to plot the data on your graph.
Here are several Bluetooth tutorials (in Spanish) which show probably how you should capture your sensor data stream) Use them as a guide.
Once you get the data stream from the Bluetooth in the ‘correct’ form into the Android,it will allow you to use the graphing method shown by Tim or one using a Canvas like this that uses a Canvas plot:
Exactly what you should do to graph depends on getting the data correctly into a csv file or List that streams from the Bluetooth.
new_try (3).aia (4.7 KB)
I have uploaded the aia file HTML file. What i have done is, i am getting the values from sensor as data(check in the image), and trying to plot it in the graph. i am able to plot it. but the problem is everytime the value is loaded the webviewer is getting refreshed and plotting the only value which is recieved at that time from arduino.
Kindly help me to plot all the values displaying in the app.
kindly anyone help me in the above problem.
Here are some corrections for you …
Also, your transmitted data format is neither csv nor JSON.
I have highlighted the non-csv part of the transmission code …
So i should not save it in js file, but the webpage created is based on the “savedfile.js” will that not affect my part of the program?
@ABG @SteveJG @TIMAI2 you are asking me send the data from arduino in csv part, but in the html file where i am getting the data part value is saved in the Js format. so if i change that to csv format it will not accept my incoming data and will not create graph. creating graph with csv part is difficult I feel. I tried by what you said. but i am not receiving the graph.
Kindly help me with this.
Another possibility would be to draw the data directly as they arrive. In this example, only one channel is drawn.
@ABG @TIMAI2 @SteveJG @Juan_Antonio yeah I saw this, but I am almost created the graph, the only struggle with that was the graph is refreshing again and again. I saw this method also, If i want to do this i have start from the beginning. Kindly please go through the part which i have done and kindly help me with that.
@ABG @TIMAI2 @SteveJG @Juan_Antonio I am trying to read the CSV using XMLHttpRequest(), which works fine when load the html in a server which I have tested in PC (Image 2). But the same is not loaded when the file is accessed using file protocol due to CORS policy (Image 3). I think the same CORS policy problem is occurring in the MIT AppInventor’s webviewer.(Check Image 4 only the alert(1) is popped up and alert(response) is not popping.
Please assist me to resolve the CORS policy problem in APP
Kindly help me regarding the above issue!
your phone is not supported