Error: Unable to receive data from the target hardware
If you are getting this error:
Clear both the
arduinoand sensor objects.
Ensure that the connections to the sensor are intact. It is recommended to use a bread board shield(prototype shield) or solder the sensor to the Arduino® board to prevent loose contact while moving the board.
Recreate the objects and try again.
If you continue to face the issue with IMU sensors, it is likely that it is due to the loose connections between the sensor and Arduino board. This causes the code to get stuck while performing the I2C operation.
On AVR based Arduino boards, you can avoid this by doing the following:
Replace the I2C library files from this location.
Navigate to ArduinoCore-avr > libraries > Wire > src > utility in the downloaded folder.
Copy the “twi.c’ and ‘twi.h’ and replace the files in the folder which opens up after executing the following commands in MATLAB® command prompt:
>> path = fullfile(arduinoio.IDERoot,'hardware','arduino','avr','libraries','Wire','src','utility'); >> cd(path)
Reflash the Arduino server using the command:
a = arduino(‘com4’,’Uno’,'ForceBuild',true)
Use the sensor functions again. This will refrain the hardware from getting stuck due to a loose connection and will throw appropriate error if there is any.
Avoid using multiple add-on libraries with Arduino Uno when using sensor functions. Arduino Uno and other ATmega328P based boards have limited RAM memory(2KiB.) You may get this error when you use sensor objects with multiple add-on libraries on Arduino Uno. To verify this create an
arduinoobject with minimum libraries required and try again. For more details, see Lost Connection and Data Issues.
Unexpected response from IMU sensor
Trace messages can be used to view the commands which are being executed on the
hardware board when you are using sensor functions. To view the trace messages,
arduino object with
TraceOn parameter set as
true and use
sensor functions. Note that the
TraceOn is not supported for