Why can't I read the values from LSM9DS1 on-board sensor on Arduino Nano 33BLE in Simulink?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi there,
I've been trying since weeks now, to read acceleration values in Simulink from the on-board LSM9DS1 sensor of Arduino Nano 33BLE board. I have installed the arduino support packages for both simulink and matlab, and have setup the connection with the board. I tried two approaches and both were unsuccessful:
- Adding LSM9DS1 sensor block from simulink's library for the arduino support package and then connecting it with the scope for visualisation. On building and deploying the model, no errors were reported but the scope shows a flat line for all inputs.
- Adding a MATLAB function block (below) and connecting the outputs to scope, which gives an error: "Matlab code generation is not supported on arduino nano 33ble sense board."
function [x, y, z] = readAccel()
a = arduino();
lsmobj = lsm9ds1(a, "Bus", 1);
[x, y, z] = readAcceleration(lsmobj);
end
Any guidance/help will be much appreciated?
P.s. Sensor and board are working fine. Tested in Arduino IDE!
2 Commenti
Risposte (1)
Avni Agrawal
il 9 Mag 2024
I understand that you are trying to read the values from LSM9DS1 on-board sensor on Arduino Nano 33BLE in Simulink. However, first try to run this command in MATLAB command window:
a = arduino()
When using `arduino()` without specifying parameters, MATLAB tries to automatically connect to an Arduino board, which might not always work as expected, especially if you have multiple devices connected or specific board requirements.
If the above line fails, then try to specify port and correct board type as mentioned below:
a = arduino('Port address', 'Nano33BLE');
Replace `'Port address'` with your board's actual port and `'Nano33BLE'` with the correct board type. This ensures MATLAB connects to the right board.
Please take a look at this documentation for better clarification:https://www.mathworks.com/help/matlab/supportpkg/arduino.html?searchHighlight=arduino%28%29&s_tid=srchtitle_support_results_1_arduino%2528%2529
I hope this helps.
Vedere anche
Categorie
Scopri di più su Modeling in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!