# Preferred Python Library for Modem Interaction?

**URL:** <https://community.sixfab.com/t/preferred-python-library-for-modem-interaction/3228>\
**Category:** 3G/4G&LTE Base HAT\
**Created:** [September 1, 2024, 11:29pm UTC](https://community.sixfab.com/t/preferred-python-library-for-modem-interaction/3228 "2024-09-01T23:29:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gamename](https://community.sixfab.com/user_avatar/community.sixfab.com/gamename/32/1801_2.png) [@gamename](https://community.sixfab.com/u/gamename)\
**Post date:** [September 1, 2024, 11:29pm UTC](https://community.sixfab.com/t/preferred-python-library-for-modem-interaction/3228/1 "2024-09-01T23:29:40Z")

</div>

Hi,

Is there a preferred python lib for working 3G/4G&LTE HATs? I’ve configured ECM, but I want to always prefix my script startup with the correct AT commands to make sure everything is usable.

Thanks,  
-T

---

<div class="post-metadata">

**Author:** ![saeed](https://community.sixfab.com/user_avatar/community.sixfab.com/saeed/32/694_2.png) [@saeed](https://community.sixfab.com/u/saeed)\
**Post date:** [September 4, 2024, 2:12pm UTC](https://community.sixfab.com/t/preferred-python-library-for-modem-interaction/3228/2 "2024-09-04T14:12:06Z")

</div>

Hello @gamename ,

The [serial python module](https://pyserial.readthedocs.io/en/latest/pyserial.html#references) can be used to communicate with module over the USB.

Basic example to issue an AT command using the serial python module is as follows:

```auto
import serial

ser = serial.Serial('/dev/ttyUSB2',115200)

def sendCommand(command):
	ser.write(command.encode())

if not ser.is_open:
	ser.open()

if ser.is_open:
	sendCommand("AT")
	ser.close()

```
