0
votes

I have an Arduino Uno and I'm trying to connect an I2C sensor to it through my computer in MatLab. I have wired it according to the device's specifications, with the SDA line at pin A4 and the SCL line at pin A5.

Matlab recommends creating an object for the Arduino then scanning for I2C addresses like this:

a=arduino()
addrs=scanI2Cbus(a,0)

Which should return a 1x1 cell array with the I2C addresses. When I run this code however, I get an empty 0x0 cell array. Does anyone know why this might be? Thanks!

1

1 Answers

0
votes

I have never worked with Arduino through MATLAB, but I could make a few suggestions. To help you could tell us which sensor you are using.

  • Does the Arduino have the correct firmware on?
  • Are you sure the Arduino is connected properly (check DeviceManager).
  • Dit you make sure you're sensor is connected correctly (SDA and SCL), and is powered on?
  • How long is the wires between the Arduino and the sensor? I2C wires can't be very long. Better keep it below 200mm.
  • Is there pull-up resistors on your I2C line? This could be done internally by the Arduino.
  • Does both the Arduino and sensor work on the same voltage? 5V or 3.3V?

Round 2:

  • Did you check that the sensor is running by testing the analog output? Quick Start Guide Step 1.
  • Did you the follow all the steps for Arduino and information as shown in the mentioned Guide?
  • The pull-up resistors might be a problem. They are necessary in any I2C setup, but most processors (like the Arduino) has built-in pull-up resistors. A simple check would be to probe the I2C lines with a multimeter and make sure that they are 5V. This will mean that there is a pull-up somewhere on the line.
  • Have you tried running it with the software they supply? The SingleTact Data Acquisition Software. It is seems like this software will chat to the Arduino, which in turn will chat to the sensor.