Main Content

Troubleshooting Sensors

Error: Unable to receive data from the target hardware

  1. If you are getting this error:

    1. Clear both the arduino and sensor objects.

    2. 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.

    3. 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:

    1. Replace the I2C library files from this location.

    2. Navigate to ArduinoCore-avr > libraries > Wire > src > utility in the downloaded folder.

    3. 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.CLIRoot, 'data','packages','arduino','hardware','avr','1.8.3','libraries','Wire','src','utility'); 
      >> cd(path) 

    4. 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.

  2. 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 arduino object 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, create the arduino object with the TraceOn parameter set as true and use sensor functions. Note that the TraceOn is not supported for read function.