Using Raspberry Pi software i2c bus with MATLAB
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Rafael Gonzalez de los Reyes
le 28 Jan 2020
Commenté : Rafael Gonzalez de los Reyes
le 29 Jan 2020
Hi,
I am running MATLAB 2019a and the MATLAB Support Package for Raspberry Pi HardwareMATLAB Support Package for Raspberry Pi Hardware. I need to use a software i2c bus on the Raspberry Pi 3B+ to connect to an BNO055 IMU, as it requires that clock stretching be supported by i2c to transmit data.
I have activated it by adding:
dtoverlay=i2c-gpio,bus=3,i2c_gpio_sda=23,i2c_gpio_scl=24
in the file /boot/config.txt
After connecting to the Rpi using the raspi command, only hardware bus is available. If a execute an i2c scan from the command line using the system function I have:
>> system(rpi,'/usr/sbin/i2cdetect -y -r 3')
ans =
' 0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- 28 -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
'
When I try to connect to the sensor with address 0x28 y have the following error:
>> imu_bmo055 = i2cdev(rpi,'i2c-3','0x28')
I2C bus i2c-3 is not available. Use AvailableI2CBuses property of the raspi object to see a list of available I2C buses.
Is it possible to add the new i2c bus to the list of AvailableI2CBuses or it only works with hardware i2c buses?
Thank you very much.
1 commentaire
Prasanth Sunkara
le 29 Jan 2020
Hello Rafael,
Please try adding the i2c-3 bus parameters in the below file.
>> edit (fullfile(raspi.internal.getRaspiRoot, 'raspi', 'internal', 'boardInfoRaspberryPi3ModelBPlus'))
After line 30, try adding the third i2c bus like below.
info.Board.I2C(3).Name = 'i2c-3';
info.Board.I2C(3).Number = 1;
info.Board.I2C(3).Pins = [23, 24]; % SDA, SCLK
Let me know if this works.
Thanks,
Prasanth
Réponse acceptée
Rafael Gonzalez de los Reyes
le 29 Jan 2020
2 commentaires
Prasanth Sunkara
le 29 Jan 2020
scanI2CBus - uses "i2cdetect -y <bus number>" command under the hood.
If adding an additonal "r" helped in your case, I would suggest adding the -r flag in "scanI2CBus" method of "raspi.internal.raspiBase" file. (>> edit raspi.internal.raspiBase)
Please let me know the results.
Thanks,
Prasanth
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!