1

I'm trying to start an I2c communication with my Raspberry Pi using the pigpio library. It works fine for me with SPI, but I really do struggle with I2C.

When I use

if (gpioInitialize() < 0) printf("Coudn't initialize gpio");
i2c_handle = i2cOpen(0, 0b1100000, 0);

I always get back -74 as handle, which stands for PI_BAD_I2C_BUS.

Can somebody explain that to me? The bus number I give to the function is 0, that should be totaly valid. But I also tried some different numbers and I always get this same error...

  • What model Pi are you using? What happens if you try this i2c_handle = i2cOpen(1, 0b1100000, 0); – Steve Robillard Aug 1 '17 at 10:45
  • I use a Raspberry Pi 3. No matter what bus number I use, there is always the same return. – jusaca Aug 1 '17 at 10:49
  • did you enable i2c in raspi-config? – crasic Aug 1 '17 at 23:14
  • Ok, that actually was the problem. Embarrassing. But I don't understand, I didn't enable SPI either, and that worked just fine from the beginning. Can I somehow mark your comment as solution, despite it's not an answer? – jusaca Aug 2 '17 at 8:46
  • @crasic, hi, I would like to invite you to post that solution as an answer. Thanks. – Ghanima Oct 16 '18 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.