# How to contact uart in pynq‘s ardinuo or PMOD interface?

**URL:** <https://discuss.pynq.io/t/how-to-contact-uart-in-pynq-s-ardinuo-or-pmod-interface/1799>\
**Category:** Support\
**Created:** [September 27, 2020, 3:23am UTC](https://discuss.pynq.io/t/how-to-contact-uart-in-pynq-s-ardinuo-or-pmod-interface/1799 "2020-09-27T03:23:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AllenChenChao](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@AllenChenChao](https://discuss.pynq.io/u/AllenChenChao)\
**Post date:** [September 27, 2020, 3:23am UTC](https://discuss.pynq.io/t/how-to-contact-uart-in-pynq-s-ardinuo-or-pmod-interface/1799/1 "2020-09-27T03:23:38Z")

</div>

Hello, I want to use uart in pynq, it is okey to use uart in rpi interface, but how could we use it in ardunio or pmod?

---

<div class="post-metadata">

**Author:** ![VicerExciser](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/vicerexciser/32/1643_2.png) [@VicerExciser](https://discuss.pynq.io/u/VicerExciser)\
**Post date:** [October 29, 2020, 9:04pm UTC](https://discuss.pynq.io/t/how-to-contact-uart-in-pynq-s-ardinuo-or-pmod-interface/1799/2 "2020-10-29T21:04:51Z")

</div>

For the Arduino interface, you can use the MicroblazeLibrary class to create a wrapper object in Python that exposes the functions implemented in the PYNQ UART API (in ‘uart.c’). Here’s a very basic example of its usage:

> from pynq import Overlay  
> from pynq.lib import MicroblazeLibrary
> 
> UART\_RXD = 0 ## Arduino pin 0 is RXD  
> UART\_TXD = 1 ## Arduino pin 1 is TXD
> 
> base = Overlay(‘base.bit’)  
> lib = MicroblazeLibrary(base.iop\_arduino, [‘uart’])  
> uart = lib.uart\_open(UART\_TXD, UART\_RXD)
> 
> read\_command = [0xDE, 0xAD, 0xBE, 0xEF]  
> uart.write(read\_command, len(read\_command)) ## Write an iterable list of bytes
> 
> response = [0x00] \* 4  
> uart.read(response, 4) ## Request a 4-byte response
> 
> uart.close()

I don’t believe either of the two Pmod PYNQ Microblaze IOPs have an AXI controller for UART, so Pmod UART may not be supported.

---

<div class="post-metadata">

**Author:** ![ldesulme](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/ldesulme/32/3468_2.png) [@ldesulme](https://discuss.pynq.io/u/ldesulme)\
**Post date:** [May 2, 2024, 4:01pm UTC](https://discuss.pynq.io/t/how-to-contact-uart-in-pynq-s-ardinuo-or-pmod-interface/1799/3 "2024-05-02T16:01:53Z")

</div>

Continuing the discussion from [How to contact uart in pynq‘s ardinuo or PMOD interface?](https://discuss.pynq.io/t/how-to-contact-uart-in-pynq-s-ardinuo-or-pmod-interface/1799/2):

Hello all,

Im working with the uart of the iop\_arduino(using pynq-z2). I currently have communication but seems like the uart buffer is limited to 16. Is there anyway to expand that? I need the buffer to be very large as to communicate with an HMI using Modbus.

code example:  
from pynq.overlays.base import BaseOverlay  
from pynq.lib import MicroblazeLibrary  
import time

ol = BaseOverlay(“base.bit”)

UART\_RXD = 0 ## Arduino pin 0  
UART\_TXD = 1 ## Arduino pin 1

uart = lib.uart\_open(UART\_TXD, UART\_RXD)

send\_buff = [x for x in range(21)]

while True:  
uart.write(send\_buff,len(send\_buff)) ## Write an iterable list of bytes  
time.sleep(.3)

Current output:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/3/365e75358aeffa1cb9c60f78bda1befc4212efba.png)
