# Access to I2C addresses

**URL:** <https://mangoh.discourse.group/t/access-to-i2c-addresses/2967>\
**Category:** mangOH Yellow\
**Created:** [October 6, 2019, 11:27am UTC](https://mangoh.discourse.group/t/access-to-i2c-addresses/2967 "2019-10-06T11:27:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheGod](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/thegod/32/504_2.png) [@TheGod](https://mangoh.discourse.group/u/TheGod)\
**Post date:** [October 6, 2019, 11:27am UTC](https://mangoh.discourse.group/t/access-to-i2c-addresses/2967/1 "2019-10-06T11:27:54Z")

</div>

Hi,  
How can I get access to I2C addresses (I need access to 0x3F to change CARD\_DETECT)

U200 EEPROM: 0x50  
U508 ACCE/GYRO: 0x18/68  
U507 BME680: 0x76  
U502 BMM150: 0x10/0x11  
U503 IO EXP: 0x3E  
U506 OPT3002: 0x44  
U505 TCA9546: 0x71 (same as 'red)  
U700 NT3H2211: 0x55 (default - can be changed)  
U701 PCF85063: 0x51  
U1000 BQ25601: 0x6B  
U1002 BQ27426: 0x55  
U703 USB3503A: 08h

Only 0x76 is available:

 ![i2c](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/1X/895c8bab16206deeccace50d684182fcb5dd4130.png)

On mangOH red everything is clear:  
 ![I2CRed](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/1X/fdeca8f6afdbfc011d615b94ea0b8599f53d9f58.png)

---

<div class="post-metadata">

**Author:** ![awneil](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/awneil/32/486_2.png) [@awneil](https://mangoh.discourse.group/u/awneil)\
**Post date:** [October 7, 2019, 10:28am UTC](https://mangoh.discourse.group/t/access-to-i2c-addresses/2967/2 "2019-10-07T10:28:14Z")

</div>

IS that showing the actual 7-bit address, or giving an 8-bit value - including the R/W bit … ?

> **[Solved: Help with Fleury's i2cmaster for Attiny841 and HIH9000 sensor](https://www.avrfreaks.net/comment/2126096#comment-2126096)**
>
> Since the ATtiny841's hardware TWI is can only be a slave, I am using Fleury's i2cmaster to communicate to the humidicon sensor, the slave.

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [October 7, 2019, 8:21pm UTC](https://mangoh.discourse.group/t/access-to-i2c-addresses/2967/3 "2019-10-07T20:21:43Z")

</div>

What is on address 0x3F? The `card_detect` gpio is on the SX1509 GPIO expander at I2C address 0x3E. Can you explain what you’re trying to accomplish?

---

<div class="post-metadata">

**Author:** ![TheGod](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/thegod/32/504_2.png) [@TheGod](https://mangoh.discourse.group/u/TheGod)\
**Post date:** [October 7, 2019, 8:42pm UTC](https://mangoh.discourse.group/t/access-to-i2c-addresses/2967/4 "2019-10-07T20:42:43Z")

</div>

Sorry 0x3E. i need to set up **card\_detect** gpio. As you can see above I do not have the address. I have got only 0x76. Addresses 0x53 and 0x6C are from my IoT card.

![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/1X/faad81931ccee04185536cdbb29dc53eb153d0cb.png)

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [October 7, 2019, 9:27pm UTC](https://mangoh.discourse.group/t/access-to-i2c-addresses/2967/5 "2019-10-07T21:27:00Z")

</div>

I2C bus 4 is the primary I2C bus. Bus 5, 6, 7, 8 correspond to ports 0, 1, 2, 3 of the I2C switch. The GPIO expander will show up as `UU` if you scan bus 8. The reason it shows up as `UU` instead of `3E` is because there is already a linux kernel driver associated with the address.

---

<div class="post-metadata">

**Author:** ![TheGod](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/thegod/32/504_2.png) [@TheGod](https://mangoh.discourse.group/u/TheGod)\
**Post date:** [October 7, 2019, 11:11pm UTC](https://mangoh.discourse.group/t/access-to-i2c-addresses/2967/6 "2019-10-07T23:11:03Z")

</div>

I know, addresses are unavailable. Original question still remains “How can I get access to I2C addresses?” Do I have to stop one of the service? My mangOH yellow is connected to Octave, so maybe, I should stop Octave integration somehow?

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [October 8, 2019, 4:17pm UTC](https://mangoh.discourse.group/t/access-to-i2c-addresses/2967/7 "2019-10-08T16:17:21Z")

</div>

Sorry, I still don’t understand what “get access to i2c addresses” means? Do you meant that you want to write code from userspace to access the GPIO expander at address 0x3E? If that’s the case, then you will need to ensure that no kernel driver is bound to that device. The driver is bound to that device in the mangOH kernel module. If you just want to configure the properties of the card detect GPIO from userspace, you should look at `/sys/class/gpio/v2/`. There should be a gpiochip in there corresponding to the sx1509. On my device it is `gpiochip793`. Since card\_detect is pin 8, the gpio should be 793 + 8 = 801. So run `echo 801 > /sys/class/gpio/v2/export` and then there will be a `/sys/class/gpio/v2/gpio801/` folder inside which you will find various files for controlling the GPIO.

---

<div class="post-metadata">

**Author:** ![TheGod](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/thegod/32/504_2.png) [@TheGod](https://mangoh.discourse.group/u/TheGod)\
**Post date:** [October 9, 2019, 8:33am UTC](https://mangoh.discourse.group/t/access-to-i2c-addresses/2967/8 "2019-10-09T08:33:28Z")

</div>

I used, i2cget on console and I got ‘Device or resource busy’ (no access / unavailable ), so I assumed, when I wrote a function I would have the same problem. But when I wrote a function ( I used bus 8 ) and on address 0x3E used function 0x10 and value 0x01, system changed IoT address from 0x53 to 0x52. So it is ok.

![image_2019_10_08T22_13_50_039Z](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/1X/242a841363afe188ad7bafc32a9a2cfa703c1137.png)

By the way. Where did you find info about the gpios ( gpiochip793 )? I also tried your solution. /sys/class/gpio/v2/gpio801 was created, but I could not change the gpio value from console.
