# Introduction on IIC and GPIO on PYNQ

**URL:** <https://discuss.pynq.io/t/introduction-on-iic-and-gpio-on-pynq/5276>\
**Category:** Support\
**Created:** [February 27, 2023, 3:50pm UTC](https://discuss.pynq.io/t/introduction-on-iic-and-gpio-on-pynq/5276 "2023-02-27T15:50:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ntahoturi5922](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@ntahoturi5922](https://discuss.pynq.io/u/ntahoturi5922)\
**Post date:** [February 27, 2023, 3:50pm UTC](https://discuss.pynq.io/t/introduction-on-iic-and-gpio-on-pynq/5276/1 "2023-02-27T15:50:19Z")

</div>

Greetings Everyone . I am new to pynq and Xilinx systems. I am wondering if anyone has a tutorial on how to use i2c on the PL side and how to read data from a gpio pin that is on the PL side all using pink. System I design has the IIC IP and the AXI GPIO.

I am using KRIA Robatics kit that has zynq ultrascale + as PS.

Many thanks

---

<div class="post-metadata">

**Author:** ![marioruiz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/marioruiz/32/2177_2.png) [@marioruiz](https://discuss.pynq.io/u/marioruiz)\
**Post date:** [February 27, 2023, 4:31pm UTC](https://discuss.pynq.io/t/introduction-on-iic-and-gpio-on-pynq/5276/2 "2023-02-27T16:31:56Z")

</div>

Hi @ntahoturi5922,

Welcome to the PYNQ community.

There’s a small example of IIC here [https://www.adiuvoengineering.com/post/microzed-chronicles-pynq-and-axi-iic](https://www.adiuvoengineering.com/post/microzed-chronicles-pynq-and-axi-iic)

AXI GPIO is well described on the documentation.

[https://pynq.readthedocs.io/en/latest/pynq\_libraries/axigpio.html](https://pynq.readthedocs.io/en/latest/pynq_libraries/axigpio.html)

Mario

---

<div class="post-metadata">

**Author:** ![ntahoturi5922](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@ntahoturi5922](https://discuss.pynq.io/u/ntahoturi5922)\
**Post date:** [March 24, 2023, 8:46pm UTC](https://discuss.pynq.io/t/introduction-on-iic-and-gpio-on-pynq/5276/3 "2023-03-24T20:46:20Z")

</div>

Any update for the spi driver?

---

<div class="post-metadata">

**Author:** ![ntahoturi5922](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@ntahoturi5922](https://discuss.pynq.io/u/ntahoturi5922)\
**Post date:** [October 16, 2023, 7:01pm UTC](https://discuss.pynq.io/t/introduction-on-iic-and-gpio-on-pynq/5276/4 "2023-10-16T19:01:23Z")

</div>

I have been able to use the AXI IIC but the issue I am getting is that all the values I get are zero. I am working with Tempsensor mcp9808, 12 bit 8ch adc module ads7828. I can scan the buss and see the devices as follow:

#scanning for diveces on the i2c bus

for address in range(0x00, 0x80):  
try:  
# Attempt to read 1 byte from the current address  
iic.send(address, [0x00], 1)  
print(f"Found I2C device at address: 0x{address:02X}")  
except Exception:  
# No response from the current address  
pass  
and i get :  
Found I2C device at address: 0x36  
Found I2C device at address: 0x40

and when i do:  
iic.receive(0x40, rx\_data, 2, 0)  
with rx\_data = [0x00,0x00] or rx\_data =   
I get nothing.

any help is appriciated.

---

<div class="post-metadata">

**Author:** ![mizan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/mizan/32/2119_2.png) [@mizan](https://discuss.pynq.io/u/mizan)\
**Post date:** [October 17, 2023, 7:05am UTC](https://discuss.pynq.io/t/introduction-on-iic-and-gpio-on-pynq/5276/5 "2023-10-17T07:05:14Z")

</div>

hi @ntahoturi5922,  
what is the rx\_data here? you should define rx\_data as bytes like rx\_data = bytes(2). I think it will solve your problem.

Mizan

---

<div class="post-metadata">

**Author:** ![ntahoturi5922](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@ntahoturi5922](https://discuss.pynq.io/u/ntahoturi5922)\
**Post date:** [October 18, 2023, 6:22pm UTC](https://discuss.pynq.io/t/introduction-on-iic-and-gpio-on-pynq/5276/6 "2023-10-18T18:22:12Z")

</div>

thanks very much. if anyone ever try this one the code should look as in the picture bellow.

 ![original-BE71550A-2128-482B-B4D4-5C50626C3495.jpeg](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/7/7aa1d7d3b7ebca7ceafb6b51d1f6f0e01c7ad8ee.png)

---

<div class="post-metadata">

**Author:** ![marioruiz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/marioruiz/32/2177_2.png) [@marioruiz](https://discuss.pynq.io/u/marioruiz)\
**Post date:** [October 19, 2023, 9:09am UTC](https://discuss.pynq.io/t/introduction-on-iic-and-gpio-on-pynq/5276/7 "2023-10-19T09:09:49Z")

</div>


