Plotting live data from Arduino in Matlab
이전 댓글 표시
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);
}
답변 (1개)
Madhu Govindarajan
2016년 2월 3일
0 개 추천
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
Madhu Govindarajan
2016년 2월 3일
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
2016년 2월 4일
편집: Daniel Green
2016년 2월 5일
anil simsek
2020년 5월 6일
I have Arduino code, I want to draw it instantly in matlab. Can you help me
카테고리
도움말 센터 및 File Exchange에서 Instrument Control Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!