Skip to main content

sim-modem

Easy library for interfacing with mobile modems. Tested with Simcom SIM7600G-H on Raspberry PI Zero W. The commands could be different for other modems.

Installation

pip install sim-modem

Usage

from sim_modem import Modem

modem = Modem('/dev/ttyUSB2')

signal_quality = modem.get_signal_quality()
print(signal_quality)

modem.send_sms('+393383928434', 'Hello World!')

API

Modem (Class)

Main class for interfacing with the modem. Each method raise an exception if the modem returns an error. If the command is successful, the function returns the response from the modem.

Modem(        
    address, # Address of the device tty (e.g. "/dev/ttyUSB2")
    baudrate=460800, # Baudrate of the device. Default: 460800
    timeout=5, # Timeout for the serial connection. Default: 5
    at_cmd_delay=0.1, # Delay between AT commands. Default: 0.1
    debug=False # Log commands and responses from modem, test command support before executing them. Default: False
)
Method Description
reconnect() -> str Reconnect to serial
close() -> str Close the serial connection
Hardware related methods
get_model_identification() -> str Get the model identification
get_manufacturer_identification() -> str Get the manufacturer identification
get_serial_number() -> str Get the serial number
get_firmware_version() -> str Get the firmware version
get_volume() -> str Get the volume. The volume range is between 0 and 5
set_volume(index: int) # 0-5 Set the volume. The volume must be between 0 and 5
improve_tdd() -> str Decrease TDD Noise effect
enable_echo_suppression() -> str Enable echo suppression
disable_echo_suppression() -> str Disable echo suppression
Network related methods
get_network_registration_status() -> str Get the network registration status
get_network_mode() -> NetworkMode Get the network mode
get_network_name() -> str Get the network name
get_network_operator() -> str Get the network operator
get_signal_quality() -> str Get the signal quality
get_signal_quality_db() -> int Get the signal quality in dB
get_signal_quality_range() -> SignalQuality Get the signal quality as a range (see SignalQuality)
get_phone_number() -> str Get the phone number
get_sim_status() -> str Get the SIM status
set_network_mode(mode: NetworkMode) -> str Set the network mode
Calls related methods
call(number: str) -> str Call a number
answer() -> str Answer a call
hangup() -> str Hangup a call
SMS related methods
get_sms_list() -> list Get the list of SMS
empty_sms() -> str Empty the SMS storage
send_sms(number: str, message: str) -> str Send an SMS
get_sms(index: int) -> dict Get an SMS by ID
delete_sms(index: int) -> str Delete an SMS by ID
GPS related methods
get_gps_status() -> str Get the GPS status
start_gps() -> str Start the GPS
stop_gps() -> str Stop the GPS
get_gps_coordinates() -> dict Get the GPS coordinates

SignalQuality (enum)

Signal quality expressed as ranges

Key Description
SignalQuality.LOW Signal is under 7
SignalQuality.FAIR Signal is between 7 and 15
SignalQuality.GOOD Signal is between 15 and 20
SignalQuality.EXCELLENT Signal is over 20

NetworkMode (enum)

Network mode of the modem (get/set)

Key Description
NetworkMode.AUTOMATIC Automatic
NetworkMode.GSM_ONLY GSM only
NetworkMode.LTE_ONLY LTE only
NetworkMode.ANY_BUT_LTE Any but LTE

License

MIT

Release files for sim-modem 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sim-modem 1.0.3
File Size Uploaded
sim-modem-1.0.3.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sim-modem 1.0.3
File Interpreter ABI Platform
sim_modem-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size:13.6 kB

Release files / sim-modem-1.0.3.tar.gz

Download URL sim-modem-1.0.3.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7099ca4c860be756096db17248803a7b07ef587dfc6521084a16828a4fc9c3e1
BLAKE2b-256 checksum
How to use checksums
eaa8a5a2cc543a88679a61ef44a2052e79def06fdf5e00e584e47b2ea8796c6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.15

Release files / sim_modem-1.0.3-py3-none-any.whl

Download URL sim_modem-1.0.3-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54f989ce56a21bda7ff5c5f427be6693c89a1298e4b778198f4e70d9b80fb7a2
BLAKE2b-256 checksum
How to use checksums
6c95e464685c00c2144f03df00d146784e0bbe53619dcafce02e88cb546955dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.15

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page