# Write/Read variables of UR3 with a Python Script

**URL:** <https://forum.universal-robots.com/t/write-read-variables-of-ur3-with-a-python-script/33730>\
**Category:** Robot Communication\
**Created:** [April 16, 2024, 2:50pm UTC](https://forum.universal-robots.com/t/write-read-variables-of-ur3-with-a-python-script/33730 "2024-04-16T14:50:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![leonardo.leao](https://avatars.discourse-cdn.com/v4/letter/l/d6d6ee/32.png) [@leonardo.leao](https://forum.universal-robots.com/u/leonardo.leao)\
**Post date:** [April 16, 2024, 2:50pm UTC](https://forum.universal-robots.com/t/write-read-variables-of-ur3-with-a-python-script/33730/1 "2024-04-16T14:50:47Z")

</div>

Hi, there!  
I’m developing a Python Script which through computer vision (OpenCV) and machine Learning (Tensorflow) is able to define the best possbile move that UR3 robot will make in a Tic-Tac-Toe game.  
So, I need to comunicate with UR3 robot, through Socket TCP or ModBus to read and write global variables in real time. I read about RTDE and another ports that are used to robot communication but I don’t find any topic that contains an easily way of read/write variables with Python.  
Example: a need a variable that stores the position where the robot will mark a “X” with a pen. How can I develop a Python code that writes an integer value in this variable into UR3.  
Could you help me?

---

<div class="post-metadata">

**Author:** ![Robpod](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/robpod/32/5837_2.png) [@Robpod](https://forum.universal-robots.com/u/Robpod)\
**Post date:** [April 16, 2024, 6:13pm UTC](https://forum.universal-robots.com/t/write-read-variables-of-ur3-with-a-python-script/33730/2 "2024-04-16T18:13:37Z")

</div>

Hi @leonardo.leao,  
you could share data using sockets:

 ![immagine](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/c/cd54c2e1cfa666128d03e7b6b14019aafc6363c2.png)

Also using XMLRPC is a viable way.
