Community
cancel
Showing results for 
Search instead for 
Did you mean: 
idata
Community Manager
4,214 Views

Unable to configure I2C

Jump to solution

Hello,

I have been trying for about a week to setup I2C on my Edison with the Arduino breakout.

I am using a brand new Edison and breakout board with the latest firmware (20160606). The issue I am facing has to do with setting up the GPIO pins for the Arduino breakout board. I have been unable to execute many of the the commands from chapter 11.6 - Configure IO18/IO19 for I2C connectivity, in the Edison Kit for Arduino Hardware Guide, Rev. 007.http://www.intel.com/content/dam/support/us/en/documents/edison/sb/edisonarduino_hg_331191007.pdf http://www.intel.com/content/dam/support/us/en/documents/edison/sb/edisonarduino_hg_331191007.pdf

I am able to successfully execute the first two commands but then every time I try to execute:

echo 204 > /sys/class/gpio/export

I get the error:

-sh: echo: write error: Device or resource busy

This error appears for almost all the other commands when i continue past this point. I have tried re-flashing my board multiple times and executing the commands from different levels in the file structure but nothing I do seems to changes the outcome. Im not sure what to do from here to get the I2C pins configured.

Without this setup I have been able to successfully connect I2C devices and read the addresses but none of the sensors have been able to operate correctly and have been unable transmit data to the Edison. Im hoping once I can configure correctly my I2C devises will work correctly. I have tried this in the Arduino IDE as well as compiling and executing executing C and python files directly from the Edison.

How do I find and stop what ever is using the files that I am trying to change to allow the I2C configuration to work? Or is there a way I can manually open and edit the files that need to be changed without having to echo the files?

Any advice would be appreciated,

Alex

0 Kudos
1 Solution
idata
Community Manager
106 Views

Hi Alex,

 

 

The error message: -sh: echo: write error: Device or resource busy. It isn't a error, it only says that the GPIO is already exported. To see the list of GPIOs exported you have to access to the directory /sys/class/gpio/ and use the command: ls and see the list of the ports exported. The directions commands don't show any errors so you could proceed with the guide.

 

 

About the sensors that you are using, Could you tell me which sensors are you using? Because there is a list of supported I2C devices for these boards.

 

 

I hope this information helps you, and I will be waiting for your answer to help you more.

 

 

Regards,

 

-Leonardo

View solution in original post

21 Replies
idata
Community Manager
107 Views

Hi Alex,

 

 

The error message: -sh: echo: write error: Device or resource busy. It isn't a error, it only says that the GPIO is already exported. To see the list of GPIOs exported you have to access to the directory /sys/class/gpio/ and use the command: ls and see the list of the ports exported. The directions commands don't show any errors so you could proceed with the guide.

 

 

About the sensors that you are using, Could you tell me which sensors are you using? Because there is a list of supported I2C devices for these boards.

 

 

I hope this information helps you, and I will be waiting for your answer to help you more.

 

 

Regards,

 

-Leonardo

View solution in original post

idata
Community Manager
106 Views

Thank you Leonardo,

I went ahead and finished the setup and I2C is working as expected with my accelerometer.

I have been using the lsm303 accelerometer and an mlx90614 IR temperature sensor. I believe these sensors are supported as I have been able to find libraries for then in UPM. The mlx90614 is not detectable and I know this is because the max speed for this sensor is 100kHz and Edison is set at 400kHz, but I have not found a way to change the speed on the Edison. I am currently using the Arduino IDE since I already have a working sketch from an Uno and I have been changing settings in the Wire.h library but this does not seem to affect the Edison. I have seen something about having to change this setting in the files flashed onto the Edison but I was wondering if there is a better/simpler way to change the SCL speed?

Thank you,

Alex

idata
Community Manager
106 Views

Hi Alex,

 

 

The SCL speed can be set in the code, I tried to follow the UPM library example to see the way that it can be done (Example: https://github.com/intel-iot-devkit/upm/blob/e7394217b1b537f7b55ace8371981cd93c0982e3/src/mlx90614/m...), the example uses the mraa/i2c.hpp and it has a function that sets the frequency on Standard Mode (100 KHz).

 

 

On the Arduino IDE you said that you couldn't do it with the Wire.h library, you can try to use this library http://playground.arduino.cc/Main/SoftwareI2CLibrary, but maybe it can't be supported by the Edison.

 

 

I hope this information helps you, and I will be waiting for your answer to help you more.

 

 

Regards,

 

-Leonardo
idata
Community Manager
106 Views

Hi Alex,

Was the information useful? Did you change the I2C frequency correctly?

Don't doubt to ask us if you have another issue.

Regards,

 

-Leonardo
idata
Community Manager
106 Views

Hi Leonardo,

Nothing appears to work in the Arduino IDE to control the I2C frequency. I will be just transitioning my project over to using C++ in a separate IDE and compiling on the Edison instead of working with Arduino. It would be nice if Edison and the Arduino IDE had a better relationship and was fully operational since a large part of the market seems to begin with Edison using the Arduino IDE.

Thank you for your help,

Alex

idata
Community Manager
106 Views

Hi Alex,

 

 

Yes you are totally right, but unfortunately the Intel Edison is not fully compatible with the Arduino boards, and each board has different features. In those cases the best suggestion is to use another IDE and compiling on the Edison, right like you are going to do it, and it is not so difficult because there are a lot of programming languages like Python, Javascript and C/C++ that can be used.

 

 

If you find something helpful for this problem, please post it here to help another users with the same problem. And remember that we are here to help you with your issues.

 

 

Thank you for remaining so positive.

 

 

Regards,

 

-Leonardo
idata
Community Manager
106 Views

Hello,

Is there any other solution that came up to use Edison with Arduino IDE, so that I2C can be configured? Because when i use Edison with Arduino board and using Arduino IDE i am not able to communicate with I2C devices. Even the I2C scanner program shows "No I2C device found".

Can anyone help me on this?

idata
Community Manager
106 Views

Hi ShyamP,

 

 

I didn't find another solution using Arduino IDE. There are some libraries of the Arduino IDE that are not supported by Edison, and it limits the I2C capabilities.

 

 

However this is not the only way Edison can use its I2C capabilities. If you use the Edison's Linux side you can find other options apart from the Arduino library.

 

 

You can use the http://iotdk.intel.com/docs/master/mraa/classmraa_1_1_i2c.html MRAA Library or a Linux package like https://github.com/groeck/i2c-tools i2c-tools.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo
idata
Community Manager
106 Views

Thank you Leonardo...

idata
Community Manager
106 Views

Hi Leonardo,

Now i started using Intel system studio IoT edition for writing my program to communicate with I2C, but when i try to connect to Edison it gives me the following error

Also can i program Edison without internet connection?

Can i use USB cable for programming Edison using the above said IDE?

If not, can you tell me how to program Edison without internet connection and which IDE to be used? (other than Arduino IDE)

idata
Community Manager
106 Views

 

Hi ShyamP,

 

 

That's weird, are you entering the right IP Address? Are you connected to the same Wi-Fi network?

 

 

About your questions, you can't program your Edison with Intel System Studio IoT without a Wi-Fi connection. You can't use an USB cable neither (Check this thread: https://communities.intel.com/thread/107636 https://communities.intel.com/thread/107636).

 

 

About your last question, I recommend you to use Intel System Studio IoT to write your code without errors, once you have written it you can pass it manually into the Edison using any terminal and compile the code there.

 

 

I hope you find this useful.

 

 

Regards,

 

-Leonardo
idata
Community Manager
106 Views

Hello Leonardo,

Now i am able to connect to Edison thru Wifi and able to download the firmware to it.

I am using ISS-IoT and C programming.

I am using Murata pressure sensor http://www.murata.com/en-sg/products/productdetail.aspx?cate=cgsubpressureSensors&partno=ZPA2326-031... ZPA2326-0311A-R which has i2c interfaced with Intel edison with arduino on A4 and A5 lines.

When i execute the command i2cdetect -r 6, i am not able to see any device connected, it shows all addresses as -- --.

Could you please help me on troubleshooting the problem?

I already tried different threads in this community, but still i dont see any response.

Also please help me how to read and write into the registers of the pressure sensor, because even i am not able to read a read register of this pressure sensor bu using i2cget command. It returns me an error: Read failed.

Request your support on this.

idata
Community Manager
106 Views

Hello Leonardo,

Adding to my previous reply this is the simple code i used to read from a register with address 0x04 which gives the status variable ouput as -1.

int main() {

int status;

/* initialize MRAA */

mraa_init();

/* create an MRAA I2C context */

mraa_i2c_context m_i2c;

/* initialize I2C on bus 1 */

m_i2c = mraa_i2c_init_raw(6);

status = mraa_i2c_frequency(m_i2c, MRAA_I2C_STD); I am able to change the frequency and verified this in oscilloscope

mraa_i2c_address(m_i2c, 0x44);

for (;;) {

status = mraa_i2c_read_byte_data(m_i2c, 0x04);

sleep(1);

}

return 0;

}

idata
Community Manager
106 Views

Hi ShyamP,

 

 

That's weird, remember that you have to configure the I2C port, try to use the guide provided at the beginning.

 

 

About the sensor, well it depends of the registers that it uses, I didn't find information related.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo
idata
Community Manager
106 Views

Hi Leonardo,

I configured I2C port as mentioned in hardware guide and changed the frequency of I2C communication from 400KHz to 100KHz.

But when it comes to reading any register of sensor attached i am getting read error as "Read failed". Also i am able to see that there is a voltage shift on SCL and SDA lines and it swings from 1.3V to 3.3V instead of 0 to 3.3V.

My sensors have internal pull ups of 1Kohm on SCL and SDA lines.

Based on the above info, can you suggest how i can perform a simple read and write operation?

Please let me know if any additional information required?

Thanks

Shyam

idata
Community Manager
106 Views

Hi leonardo,

Adding to the above points sometimes i get these errors when i try to configure i2c. What is meant by device or resource busy?

And i dont have any sensors connected to any of the shield pins on board. I am configuring with everything disconnected on shield pins.

idata
Community Manager
106 Views

Hi ShyamP,

 

 

In the answer of this case I said that the error message: -sh: echo: write error: Device or resource busy isn't an error, it only says that the GPIO is already exported.

 

 

Do you have more information of the sensor? Maybe the address that you are entering is not a right address for this sensor. Try with different addresses according to its information about the registers.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo
idata
Community Manager
106 Views

Hi Leonardo,

I configured I2C port as mentioned in hardware guide and changed the frequency of I2C communication from 400KHz to 100KHz.

Please find the snapshot of registers addresses as requested.

Based on the above, when i run i2cdetect -y -r 6, i am able to see address 0x44 detected.

Based on above, when i try to read a simple RW register using the command

i2cget 6 0x44 0x04, i get an error: "Read failed".

Also i tried the same read operation on different registers in the snapshot, but always i get read failed.

Thanks

Shyam

idata
Community Manager
106 Views

Hi ShyamP,

 

 

I don't know why you can't read the registers, but check this link: https://m2aglabs.com/2015/04/10/i2c-interfacing-on-intel-edison/

 

 

I think that it can be useful for you, and give it a try to the command i2cdump to take a look to your sensor registers.

 

 

I hope you find this helpful.

 

 

Regards,

 

-Leonardo

 

idata
Community Manager
19 Views

hi Leonardo,

I already tried all the commands mentioned in above link....I am able to succed till i2dump command, but when it comes to i2cget and i2cset i always get an error saying "Read failed" when i perform a read using i2cget 6 0x44 0x04 and "write failed" when i perform a write using i2cset 6 0x44 0x04 0x10.

Can you tell me what other possibilities do i have for this read and write failure?

Regards,

Shyam

Reply