フィルターのクリア

Undefined function or variable 'I2Cdev'.

5 ビュー (過去 30 日間)
Kadir Tolga Dogukanli
Kadir Tolga Dogukanli 2018 年 12 月 29 日
コメント済み: linani messaoud 2022 年 2 月 1 日
I am trying do a interface for mpu6050 . I have installed arduino support packages for matlab and simulink but , i have an error says
Undefined function or variable 'I2Cdev'.
Here is my code;
%% setup
hold all
a=arduino;
mpu= I2Cdev (a,'0x68'); %mpu adress is normally 0x68
writeRegister(mpu, hex2dec('B6'), hex2dec('00'), 'int16'); %reset
data=zeros(10000,14,'int8'); %prelocating for the speed
j=1;
a1 = animatedline('Color',[1 0 0]);
a2 = animatedline('Color',[0 1 0]);
a3 = animatedline('Color',[0 0 1]);
legend('Accel_x','Accel_y','Accel_z')
%% loop
while(true)
x=1;
for i=59:72 % 14 Data Registers for Accel,Temp,Gyro
data(j,x)= readRegister(mpu, i, 'int8');
x=x+1;
end
y=swapbytes(typecast(data(j,:), 'int16')) %if your system is big-endian remove the swapbytes function
addpoints(a1,j,double(y(1)));
addpoints(a2,j,double(y(2)));
addpoints(a3,j,double(y(3)));
j=j+1;
drawnow limitrate
end
  2 件のコメント
WAN NOR NAZIRA MUSTAPA KAMAL
WAN NOR NAZIRA MUSTAPA KAMAL 2021 年 1 月 22 日
I am facing with the same problem, did you find the solution?
linani messaoud
linani messaoud 2022 年 2 月 1 日
Change commands:
a=arduino;
mpu= I2Cdev (a,'0x68'); %mpu adress is normally 0x68
to commands:
a = arduino('COM4','Uno','Libraries','I2C');
mpu = device(a,'I2CAddress','0x68')

サインインしてコメントする。

回答 (4 件)

Walter Roberson
Walter Roberson 2021 年 1 月 22 日

madhan ravi
madhan ravi 2018 年 12 月 29 日
https://www.mathworks.com/help/supportpkg/raspberrypiio/ref/i2cdev.i2cdev.html - matlab is case sensitive i2cdev lowercase letters
  1 件のコメント
Walter Roberson
Walter Roberson 2021 年 1 月 22 日
ic2dev used there is for Raspberry Pi, not arduino.

サインインしてコメントする。


Gayatri Menon
Gayatri Menon 2022 年 1 月 6 日
The below link might help you in interfacing mpu6050 connected to arduino:
Thanks
Gayatri

Gokarna Baskota
Gokarna Baskota 2022 年 1 月 26 日
I got the same problem while using R2020a.
But when I use R2018a than problem is solved.
Solution:
Try to run code in MatLab version lower than 2019 Or replace I2Cdev() by mpu6050()

カテゴリ

Help Center および File ExchangeMATLAB Support Package for Arduino Hardware についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by