7 Replies Latest reply on Nov 12, 2015 7:06 AM by geotheory

    I2C on different GPIO ports


      Can I use I2C with mraa on the GPIO ports exposed by the SparkFun GPIO Block?

      SparkFun Blocks for Intel® Edison - GPIO Block - learn.sparkfun.com


      The constructor require('mraa').irc(n) seems to take a predefined port number, and I’d like to specify two GPIO ports instead. I suspect that requires a different library, but it would be nice to stay as close to the recommended libraries as possible. Performance doesn’t seem to be very important. I’m trying to connect to the Adafruit ADS1015 12-Bit ADC. I’m using the latest default Yocto software.


      I know that SparkFun also sells I2C and ADC blocks, but shipping to my country is expensive so I prefer to work with the hardware I already have.


      edit: now looking into creating bitbanged I2C hosts, to be continued

      edit2: got that to compile using the Compiling Drivers guide, but results are not promising:

      # insmod ~/git/i2c-gpio-param/i2c-gpio-param.ko busid=8 sda=14 scl=15
      # i2cdetect 8

      doesn’t seem to detect the ADC board. Tried with a different board as well. They still work when connected to an Arduino UNO.

        • 1. Re: I2C on different GPIO ports

          Hi s89,


          I just looked into the creating bitbanged I2C hosts and it says it was designed and tested for Raspberry Pi so it need some changes and this does not guarantee it will work properly on Intel Edison. I suggest you to try building the Intel Edison image using the Yocto image sources and make the changes mentioned in the Kernel by the guide. You might find this document helpful as well as the BSP User Guide. I hope this suggestion helps.



          • 2. Re: I2C on different GPIO ports

            Thanks JPMontero_Intel for looking at the guide and providing these useful links. As far as I could see the only kernel requirement from i2c-gpio-param (the bitbanging module) is that CONFIG_I2c_GPIO is enabled, and that is the case in the default Yocto that came with Edison.


            I was encouraged by the fact that the insmod command indeed created a I2C bus, which it didn’t when I had a GPIO exported on pin 14 before. So it is not completely non-functional, it just doesn’t work yet. :-)


            For now I’m considering these issues:

            1. i2c-gpio-param may indeed require changes itself. Maybe the required changes will become obvious from reading the Yocto image sources.
            2. Perhaps a different variation of udelay / timeout / sda_od / scl_od / scl_oo parameters is needed. I tried a few but not yet systematically.
            3. When configuring the kernel for custom compilation, maybe different port pairs can be marked as I2C as well, so that no bitbanging is needed? Not sure what is the difference between I2C and non-I2C GPIO ports in terms of hardware.
            4. Related, maybe the I2C ports predefined by Intel are the only ones capable of doing I2C, so bitbanging won’t work at all (without additional hardware)?
            • 3. Re: I2C on different GPIO ports

              Hello s89,


              I apologize for big delay in my response. Do you have any updates on this? Alternatively, some users have reported better performance on SPI and I2C with the previous software release. You can get older versions in this site. In case you want to give that a try.



              • 4. Re: I2C on different GPIO ports

                Thanks JPMontero_Intel, I might try that sometime. I haven’t continued with the bitbanging since my last post, and switched to BLE communication with a separate microcontroller (which suits my current project better).

                • 5. Re: I2C on different GPIO ports

                  Hey s89.  Don't suppose you have any further information on this?  I'm looking at connecting the LiPo Fuel Gauge's I2C interface with the GPIO Block if possible.

                  • 6. Re: I2C on different GPIO ports

                    geotheory, no news, I stopped trying. According to Wikipedia the I2C algorithm (in terms of well-timed 1s and 0s) seems pretty simple so you might want to try bit-banging without the kernel module. There may be libraries made for this purpose (perhaps written for Raspberry Pi) or you might want to implement it yourself. For my next project I’d reconsider buying the Sparkfun block first since it probably saves a lot of time.

                    • 7. Re: I2C on different GPIO ports

                      Yes I've just got the I2C board for this. Cheers.