Community
cancel
Showing results for 
Search instead for 
Did you mean: 
JSmit51
Beginner
1,784 Views

I2C Connection Issues (Intel Edison with Arduino Breakout Board)

Hi, so I have Intel Edison with Arduino Breakout board. Basically, I can't seem to get i2c connection via Yocto OS to work. Whenever I run: i2cdetect -y -r 1, I always get the following:

For for 2, 4, 6:

For 3, Edison crashes and I need to do a restart:

The sensor I am using is "Adafruit Sensiron SHT31-D Temperature & Humidity Sensor Breakout" I know my connection is correct because I am able to use it via arduino ide.

Any help will be appreciated. I am trying to learn more about embedded programming through linux.

0 Kudos
16 Replies
Andriy_S_Intel
Employee
277 Views

The only busses available for user are # 1 and # 6 (for main CPU) and # 8 (for SCU/MCU). For bus # 1 you see GPIO expanders connected (Edison/Arduino variant very likely). So, if you connect your device to bus # 6 you need to be sure that pins are in proper mode (i.e. mode 1) to be visible for OS. Otherwise they are muxed to I2C8 or bus # 8 (SCU/MCU peripheral host controller).

idata
Community Manager
277 Views

Hello jsmith123,

 

 

Thanks for reaching out!

 

 

What Oandriy said is true, you should take it into consideration before trying to use the I2C bus manually. I would also like to tell you that before you can use the I2C bus, you have to set it up in order to be accessible through the GPIOs on the expansion board. You can do so with the following script:

 

 

# !/bin/sh

 

echo 28 > /sys/class/gpio/export

 

echo 27 > /sys/class/gpio/export

 

echo 204 > /sys/class/gpio/export

 

echo 205 > /sys/class/gpio/export

 

echo 236 > /sys/class/gpio/export

 

echo 237 > /sys/class/gpio/export

 

echo 14 > /sys/class/gpio/export

 

echo 165 > /sys/class/gpio/export

 

echo 212 > /sys/class/gpio/export

 

echo 213 > /sys/class/gpio/export

 

echo 214 > /sys/class/gpio/export

 

echo low > /sys/class/gpio/gpio214/direction

 

echo high > /sys/class/gpio/gpio204/direction

 

echo high > /sys/class/gpio/gpio205/direction

 

echo in > /sys/class/gpio/gpio14/direction

 

echo in > /sys/class/gpio/gpio165/direction

 

echo low > /sys/class/gpio/gpio236/direction

 

echo low > /sys/class/gpio/gpio237/direction

 

echo in > /sys/class/gpio/gpio212/direction

 

echo in > /sys/class/gpio/gpio213/direction

 

echo mode1 > /sys/kernel/debug/gpio_debug/gpio28/current_pinmux

 

echo mode1 > /sys/kernel/debug/gpio_debug/gpio27/current_pinmux

 

echo high > /sys/class/gpio/gpio214/direction

 

 

I hope this information helps you,

 

Pedro M.
idata
Community Manager
277 Views

Hello jsmith123,

 

 

Do you have any updates about this?

 

 

Pedro M.
JSmit51
Beginner
277 Views

Hi Pedro M,

Sorry for the late reply. I ran the script. However, the results were the same as posted above.

Result of script:

I'm not sure what the issue is. My wiring configuration is as follows for the sensor and the Arduino Breakout Board:

SHT31-D | Arduino Breakout Board

5V <--> Vin

GND <--> GND

SDA <--> A4

SCL <--> A5

idata
Community Manager
277 Views

Don't worry those messages are expected, what they mean is that those GPIOs have already been exported. However, we don't know if that's always going to be the case, so, those lines have to be included in the script.

 

 

In fact, these lines are those explained in the Arduino Expansion board hardware guide ( http://download.intel.com/support/edison/sb/edisonarduino_hg_331191007.pdf) in section 11.6 to configure the I2C pins. The only difference is that I made them a script for ease of use.

 

 

Did you try to check the I2C bus after running the script?

 

 

Pedro M.
JSmit51
Beginner
277 Views

I checked the I2C bus after running the script and I got the following:

i2cdetect for bus 1:

i2cdetect for bus 2, 4-6

i2cdetect for bus 3 (crashes and I have to reset the board)

Is there a particular setting/setup I have to change on the board?

I am able to access the sensor through Arduino IDE. However, I can't detect the sensor via Linux.

idata
Community Manager
277 Views

As Oandriy mentioned and as you can check in section 4.2 of the module's hardware guide ( http://download.intel.com/support/edison/sb/edisonmodule_hg_331189004.pdf), Edison has only two I2C interfaces available, I2C1 and I2C6. This is true to the module, however, it is different in the expansion board. You can see it in a graphic mode in Figure 2 of the expansion board's hardware guide ( http://download.intel.com/support/edison/sb/edisonarduino_hg_331191007.pdf), you can see two I2C interfaces coming out from the module but one of them is four expander ports, leaving only one interface available to the user. This last I2C interface goes from the module to a multiplexer and then to the physical output. This interface is I2C6.

 

 

What I explained above if the reason why you see something detected in the I2C1 interface. Try running again the script and them enter the command i2cdetect -y -r 6 with your device connected and let us know what happens.

 

 

Pedro M.
JSmit51
Beginner
277 Views

I still can't seem to get the connection to work...

Step 1.

The Senor is connected as follows:

SHT31-D | Arduino Breakout Board

5V <--> Vin

GND <--> GND

SDA <--> A4

SCL <--> A5

Step 2.

Step 3:

idata
Community Manager
277 Views

Thanks a lot for sharing this information with us. Please let us analyze it to see if we can determine what might be happening. If we are able to find anything useful, we'll make sure to share it with you in this thread.

 

 

Pedro M.
idata
Community Manager
277 Views

I recommend you to use the MRAA library just to see if the sensor is detected. MRAA should configure the interface automatically and we might see a different result. You would have to write a simple code for this test or find an example code for the sensor he is using. You can find the examples in https://github.com/intel-iot-devkit/mraa/tree/master/examples

 

 

I would like to ask you if when you refer to the Arduino IDE, if you actually used an Arduino UNO or the Edison programmed through the Arduino IDE.

 

 

Pedro M.
FerryT
Valued Contributor I
277 Views

You should see:

root@edison:~# i2cdetect -y -r 1

 

0 1 2 3 4 5 6 7 8 9 a b c d e f

 

00: -- -- -- -- -- -- -- -- -- -- -- -- --

 

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

 

20: UU UU UU UU -- -- -- -- -- -- -- -- -- -- -- --

 

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

 

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

 

50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

 

60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

 

70: -- -- -- -- -- -- -- --

 

 

This show 4 muxes detected. I have seen '-- UU UU UU' sometimes and needed to disconnect power for a cold boot to get it back working.

But I believe that with mux not detected, you won't be able to run the script properly.

JSmit51
Beginner
277 Views

Hi Pedro,

I used the MRAA library and wrote some code to pull data from the specified address of my sensor. This seems to have done the trick!

I was able to pull data from the sensor and I am also now able to detect the sensor as well!

However, the script provided in the examples seems to change the configuration such that it doesn't appear anymore:

Do you have any idea why running some code using the MRAA library fixes the issue?

  • When using the Arduino IDE, I selected the Intel Edison board.
idata
Community Manager
277 Views

I'm not sure what might be happening as you can see in section 11.6 of http://download.intel.com/support/edison/sb/edisonarduino_hg_331191007.pdf, the script I shared uses the same commands that are in the hardware guide. My only guess is that you might be using a different image, what is your output when enter the command cat /etc/version.

 

 

Pedro M.
JSmit51
Beginner
277 Views

I have the following version.

idata
Community Manager
277 Views

I see, you are using the latest image, it is very strange that I2C is working with the Arduino IDE, mraa but not with the manual set up stated in the hardware guide.

 

 

Please me check what might be happening, I'll try to get back to you as soon as possible.

 

 

Pedro M.
idata
Community Manager
277 Views

Hello jsmith123,

 

 

The reason the sensor works with the MRAA library is because it takes care of the multiplexing for you.

 

 

Could you please try following this script? It is a bit different from the one found in the guide.

 

 

echo 28 > /sys/class/gpio/export  echo 27 > /sys/class/gpio/export  echo 204 > /sys/class/gpio/export  echo 205 > /sys/class/gpio/export  echo 236 > /sys/class/gpio/export  echo 237 > /sys/class/gpio/export  echo 14 > /sys/class/gpio/export  echo 165 > /sys/class/gpio/export  echo 212 > /sys/class/gpio/export  echo 213 > /sys/class/gpio/export  echo 214 > /sys/class/gpio/export  echo low > /sys/class/gpio/gpio214/direction  echo low > /sys/class/gpio/gpio204/direction  echo low > /sys/class/gpio/gpio205/direction  echo in > /sys/class/gpio/gpio14/direction  echo in > /sys/class/gpio/gpio165/direction  echo low > /sys/class/gpio/gpio236/direction  echo low > /sys/class/gpio/gpio237/direction  echo in > /sys/class/gpio/gpio212/direction  echo in > /sys/class/gpio/gpio213/direction  echo mode1 > /sys/kernel/debug/gpio_debug/gpio28/current_pinmux  echo mode1 > /sys/kernel/debug/gpio_debug/gpio27/current_pinmux  echo high > /sys/class/gpio/gpio214/direction

 

 

If you have another update or question, don't hesitate to contact us.

 

 

Have a nice day.

 

 

Regards,

 

Andres V.
Reply