Hi!
It is my understanding that you can connect to Arduino using MATLAB and also through the Arduino IDE. However, when you try to build and deploy a simple Simulink model to Arduino, the process takes a long time and eventually stops, showing the following error:
“Could not automatically set the bootloader COM port for your Arduino Nano 33 IoT board.”
I'm not entirely certain about the exact reason for the error you are encountering, but I came across similar issues and workarounds that might be helpful.
Sometimes this issue arises when MATLAB tries to connect to the Arduino via more than one connection. This can happen if there is an existing "arduino" object in the workspace. Make sure to clear the previous arduino objects before calling the “arduino” function again, or simulating a model on the Arduino. To clear an arduino object "my_arduino":
>> clear my_arduino
Additionally check that other MATLAB instances are not connected to the Arduino.
You can try reinstalling MATLAB and the Simulink Arduino support package. Before reinstalling, make sure to first remove the existing support package, because it might be the case that your previous installation was interrupted by activating Add-On explorer multiple times during the install, which ended with a bad install.
There might also be an issue with the Arduino drivers, as Arduino drivers are not the same for all Arduino boards. You can refer to the following link to see discussions about this potential problem.
You may also consider trying the following steps to see if they help to resolve the issue.
Locate the p-file 'arduinoARMDownload.p' and delete it from its folder. [after saving a backup copy of the 'arduinoARMDownload.m' and 'arduinoARMDownload.p' files at another folder location]
Execute the following commands in the MATLAB Command Window:
clear classes; clear pcode; rehash toolboxcache;
Try connecting to the Arduino board again.
You may also want to refer to the following link, as it provides detailed steps to troubleshoot the exact error you are encountering.
You can try manually resetting the board by long pressing the reset button on the hardware and then deploying the model to see if it helps. If this doesn’t help, then you may need to reflash the firmware/bootloader on the board with an AVR programmer. There are plenty of tutorials online about that.
If this does not resolve the error, please contact MathWorks Technical Support at:
Hope this helps.