Plotting live data from Arduino in Matlab
Afficher commentaires plus anciens
Hi all,
Apologies if this has already been covered - I couldn't find any information and I am new to Matlab and Arduino! I want to plot water level data obtained from my Arduino Uno plugged into a Milone eTape water depth sensor. I've got the code running successfully in a freeware software called SerialPlot but I want to plot this data into Matlab. The code I am using on the Arduino is below. How do I go about plotting the data in real time on Matlab?
Thanks so much in advance!
Dan
// the value of the 'other' resistor
#define SERIESRESISTOR 560
// What pin to connect the sensor to
#define SENSORPIN A0
void setup(void) {
Serial.begin(38400);
}
void loop(void) {
float Reading;
float level;
float Reading2;
float mapped;
Reading = analogRead(SENSORPIN);
// Serial.print("Analog reading ");
// Serial.println(Reading);
//convert the value to resistance
Reading2 = (1023 / Reading) - 1;
Reading2 = SERIESRESISTOR / Reading2;
//Serial.print("Sensor resistance ");
//Serial.println(Reading2);
mapped = map(Reading2, 658.89, 1695.43 , 150, 0);
// map (Reading2, Highest Depth Resistance, Lowest Depth Resistance, Depth Difference, Lowest Depth)
// Serial.print("");
Serial.println(mapped);
delay(10);
}
Réponses (1)
Madhu Govindarajan
le 3 Fév 2016
0 votes
have you tried animatedline function in MATLAB? I doubt you can do 100% real-time with Arduino but I think this is what you are looking for.
3 commentaires
Madhu Govindarajan
le 3 Fév 2016
I meant try using this for the plotter and using MATLAB Support package to bring in the data to MATLAB from Arduino - www.mathworks.com/hardware-support/arduino-matlab.html
Daniel Green
le 4 Fév 2016
Modifié(e) : Daniel Green
le 5 Fév 2016
anil simsek
le 6 Mai 2020
I have Arduino code, I want to draw it instantly in matlab. Can you help me
Catégories
En savoir plus sur Instrument Control Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!