# UART scripting

**URL:** <https://forum.qoitech.com/t/uart-scripting/440>\
**Category:** Automation Toolbox\
**Created:** [May 18, 2022, 2:21pm UTC](https://forum.qoitech.com/t/uart-scripting/440 "2022-05-18T14:21:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![annecharlotte](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@annecharlotte](https://forum.qoitech.com/u/annecharlotte)\
**Post date:** [May 18, 2022, 2:21pm UTC](https://forum.qoitech.com/t/uart-scripting/440/1 "2022-05-18T14:21:33Z")

</div>

Hello,

I am running automatic tests on the otii device. I can’t find a way to send the AT-command “write\_tx” command. The sent commands appear in the window only after the project is closed.

Could you help me to do this ? Basically the lua script would look like:

setup device + project + choose the good port to display the UART log  
set the supply voltage  
send at-command to the device through tx messages  
receive uart messages through rx  
register both the current values and the log messages

Thanks in advance,  
Anne-Charlotte

---

<div class="post-metadata">

**Author:** ![bjorn.rosqvist](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.qoitech.com/bjorn.rosqvist/32/238_2.png) [@bjorn.rosqvist](https://forum.qoitech.com/u/bjorn.rosqvist)\
**Post date:** [May 20, 2022, 8:16am UTC](https://forum.qoitech.com/t/uart-scripting/440/2 "2022-05-20T08:16:40Z")

</div>

Hi Anne-Charlotte,  
Welcome to the forum!

Since you mention “choose the good port…”, do you want to send UART TX with Otii Arc or a external UART serial device?  
External devices are not supported in scripting, only using Otii Arc.

Make sure that you set the right voltage level and baud rate, also include \r\n in the end of your string.

Quick example below, not complete script, just to show the APIs.  
device:set\_main\_voltage(3.0)  
device:set\_exp\_voltage(1.8)  
device:set\_uart\_baudrate(115200)  
device:enable\_channel(“mc”,true)  
device:enable\_channel(“rx”,true)  
device:write\_tx(“ATI\r\n”)

You can find the API here:  
[https://www.qoitech.com/help/scripting/modules/otii.html](https://www.qoitech.com/help/scripting/modules/otii.html)

Best regards,  
Björn

---

<div class="post-metadata">

**Author:** ![integra](https://avatars.discourse-cdn.com/v4/letter/i/7c8e57/32.png) [@integra](https://forum.qoitech.com/u/integra)\
**Post date:** [May 20, 2022, 8:37am UTC](https://forum.qoitech.com/t/uart-scripting/440/3 "2022-05-20T08:37:19Z")

</div>

Thanks a lot ! I missed the \r\n. It’s perfectly working !
