How to display temparature, pressure and altitude of the BMP 280 using Arduino (uno) on Matlab?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have been using the code:
a=serial('COM3','BaudRate',9600);
%create the coordinate axis
plotTitle='Test';
xLabel = 'Elapsed Time (s)'; % x-axis label
yLabel = 'Temperature (C)';
legend1='Temperature';
legend2='Pressure';
legend3='alitude';
yMax=40 ;
yMin=0;
min = 0;
max = 40;
delay=.01;
%function variables
time=0;
data1=0;
data2=0;
data3=0;
count=0;
%plot set up
plotGraph=plot(time,data1,'-r' );
hold on
plotGraph1=plot(time,data2,'-b')
plotGraph2=plot(time, data3,'-g' )
title(plotTitle,'FontSize',15);
xlabel(xLabel,'FontSize',15);
ylabel(yLabel,'FontSize',15);
plotGrid = 'on';
legend(legend1,legend2,legend3);
axis([yMin yMax min max]);
grid(plotGrid);
tic
%loop
while ishandle(plotGraph) %when plot is active will run until plot is closed
dat1=readTemperature();%unkown pin
dat2=pressure;%unkown pin
dat3=altitude;%unkown pin
count=count+1;
time(count)=toc;
data1(count)=dat(1);
data2(count)=dat(2);
data3(count)=dat(3);
set(plotGraph,'XData',time,'YData',data);
set(plotGraph1,'XData',time,'YData',data1);
set(plotGraph2,'XData',time,'YData',data2);
axis([0 time(count) min max]);
%Update the graph
pause(delay);
end
delete(a);
BUT I get an error:
"Error in try2 (line 35)
dat1=readTemperature();%unkown pin"
I dont know if we have to use simulink or if we must run Arduino software at the same time.
Please help me.
Thank you.
0 comentarios
Respuestas (1)
Vimal Rathod
el 26 de Abr. de 2020
Hi,
You have to establish an I2C channel connection after connecting the arduino and the required parameters like temperature, pressure and altitude should be read and write in that channel itself.
Refer to the following link which describes the example for temperature reading from arduino. You can modify your code appropriately to suit your needs.
0 comentarios
Ver también
Categorías
Más información sobre Arduino Hardware en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!