1 2 Previous Next 21 Replies Latest reply on Nov 17, 2016 1:11 PM by Intel Corporation

    Unable to configure I2C

    terp41

      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

       

      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

        • 1. Re: Unable to configure I2C
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          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

          1 of 1 people found this helpful
          • 2. Re: Unable to configure I2C
            terp41

            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

            • 3. Re: Unable to configure I2C
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              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/mlx90614.cxx), 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

              • 4. Re: Unable to configure I2C
                Intel Corporation
                This message was posted on behalf of Intel Corporation

                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

                • 5. Re: Unable to configure I2C
                  terp41

                  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

                  • 6. Re: Unable to configure I2C
                    Intel Corporation
                    This message was posted on behalf of Intel Corporation

                    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

                    • 7. Re: Unable to configure I2C
                      ShyamP

                      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?

                      • 8. Re: Unable to configure I2C
                        Intel Corporation
                        This message was posted on behalf of Intel Corporation

                        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 MRAA Library or a Linux package like i2c-tools.

                        Have a nice day.

                        Regards,  
                        -Leonardo

                        • 9. Re: Unable to configure I2C
                          ShyamP

                          Thank you Leonardo...

                          • 10. Re: Unable to configure I2C
                            ShyamP

                            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)

                            • 11. Re: Unable to configure I2C
                              Intel Corporation
                              This message was posted on behalf of Intel Corporation


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

                              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

                              • 12. Re: Unable to configure I2C
                                ShyamP

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

                                • 13. Re: Unable to configure I2C
                                  ShyamP

                                  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;

                                  }

                                  • 14. Re: Unable to configure I2C
                                    Intel Corporation
                                    This message was posted on behalf of Intel Corporation

                                    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

                                    1 2 Previous Next