# EM05 SMS Library
A Python library for communicating with Quectel EM05 cellular modules via AT commands, specifically designed for SMS operations.
## Features
- Send SMS messages via cellular network
- List and read SMS messages
- Delete SMS messages
- Support for UCS2 encoding for international characters
- Debug logging for troubleshooting
- Factory reset functionality
## Requirements
- Python 3.7+
- pyserial
- Quectel EM05 module connected via USB/serial
## Installation
```bash
pip install pyserial
```
## Quick Start
```python
import em05
# Initialize the EM05 module
dev = em05.EM05(port='/dev/ttyUSB2', debug=True)
# List all SMS messages
messages = dev.sms_list_all()
print(f"Found {len(messages)} SMS messages")
# Send an SMS
response = dev.sms_send(phone_number='10086', text='Hello World!')
print(f"SMS sent: {response.status}")
# Delete all SMS messages
dev.sms_delete_all()
# Close the connection
dev.close()
```
## API Reference
### EM05 Class
#### Constructor
```python
EM05(port='/dev/ttyUSB2', baudrate=115200, timeout=1, debug=False)
```
- `port`: Serial port path (default: '/dev/ttyUSB2')
- `baudrate`: Communication speed (default: 115200)
- `timeout`: Response timeout in seconds (default: 1)
- `debug`: Enable debug logging (default: False)
#### Methods
##### SMS Operations
- `sms_list_all()` → `List[SMSMessage]`
- Returns all SMS messages from the module
- Each message includes: store_index, status, sender, timestamp, text
- `sms_send(phone_number: str, text: str)` → `EM05Resp`
- Sends an SMS message
- Supports international characters via UCS2 encoding
- `sms_delete_all()` → `EM05Resp`
- Deletes all SMS messages from storage
##### AT Commands
- `at_write(command: str, params: list)` → `EM05Resp`
- Execute AT command with parameters
- `at_read(command: str)` → `EM05Resp`
- Query AT command value
- `at_exe(command: str)` → `EM05Resp`
- Execute AT command without parameters
##### Utility
- `info()` → `EM05Resp`
- Get module information
- `reset()` → `List[EM05Resp]`
- Reset module to factory defaults
- `close()`
- Close serial connection
### Data Classes
#### SMSMessage
```python
@dataclass
class SMSMessage:
store_index: int # Message index in storage
status: str # Message status (e.g., "REC UNREAD")
sender: str # Sender phone number
timestamp: datetime # Message timestamp with timezone
text: str # Message content
```
#### EM05Resp
```python
@dataclass
class EM05Resp:
status: str # Response status ("OK", "ERROR", or "")
raw: str # Raw response from module
lines: list[str] # Parsed response lines
```
## AT Commands Reference
This library uses standard AT commands for SMS operations:
- `AT+CMGF=1` - Set SMS text mode
- `AT+CSCS="UCS2"` - Set character set to UCS2
- `AT+CMGL="ALL"` - List all SMS messages
- `AT+CMGS` - Send SMS message
- `AT+CMGD` - Delete SMS messages
For detailed AT command documentation, refer to the [Quectel EM05 AT Commands Manual](https://forums.quectel.com/uploads/short-url/cBnrTmjnCg7OGnqRsk8dIpbHuVX.pdf).
## Configuration
The module automatically configures itself on initialization:
- Sets factory defaults (`AT&F`)
- Enables text mode (`AT+CMGF=1`)
- Disables echo (`ATE0`)
- Sets UCS2 character encoding (`AT+CSCS="UCS2"`)
## Error Handling
The library includes comprehensive error handling:
- Serial communication timeouts
- UCS2 encoding/decoding errors
- AT command response parsing
- Debug logging for troubleshooting
## Example Usage
See `main.py` for a complete example of listing and sending SMS messages.
## License
This project is open source. Please refer to the license file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/rikki/em05-sms",
"name": "em05",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "sms, cellular, quectel, em05, at-commands",
"author": "Rikki",
"author_email": "Rikki <i@rikki.moe>",
"download_url": "https://files.pythonhosted.org/packages/45/c9/a8088f7e0b3287a145792ed055822c05fb0a70fbde6ecf4c25752c24326f/em05-0.1.0.tar.gz",
"platform": null,
"description": "# EM05 SMS Library\n\nA Python library for communicating with Quectel EM05 cellular modules via AT commands, specifically designed for SMS operations.\n\n## Features\n\n- Send SMS messages via cellular network\n- List and read SMS messages\n- Delete SMS messages\n- Support for UCS2 encoding for international characters\n- Debug logging for troubleshooting\n- Factory reset functionality\n\n## Requirements\n\n- Python 3.7+\n- pyserial\n- Quectel EM05 module connected via USB/serial\n\n## Installation\n\n```bash\npip install pyserial\n```\n\n## Quick Start\n\n```python\nimport em05\n\n# Initialize the EM05 module\ndev = em05.EM05(port='/dev/ttyUSB2', debug=True)\n\n# List all SMS messages\nmessages = dev.sms_list_all()\nprint(f\"Found {len(messages)} SMS messages\")\n\n# Send an SMS\nresponse = dev.sms_send(phone_number='10086', text='Hello World!')\nprint(f\"SMS sent: {response.status}\")\n\n# Delete all SMS messages\ndev.sms_delete_all()\n\n# Close the connection\ndev.close()\n```\n\n## API Reference\n\n### EM05 Class\n\n#### Constructor\n```python\nEM05(port='/dev/ttyUSB2', baudrate=115200, timeout=1, debug=False)\n```\n\n- `port`: Serial port path (default: '/dev/ttyUSB2')\n- `baudrate`: Communication speed (default: 115200)\n- `timeout`: Response timeout in seconds (default: 1)\n- `debug`: Enable debug logging (default: False)\n\n#### Methods\n\n##### SMS Operations\n\n- `sms_list_all()` \u2192 `List[SMSMessage]`\n - Returns all SMS messages from the module\n - Each message includes: store_index, status, sender, timestamp, text\n\n- `sms_send(phone_number: str, text: str)` \u2192 `EM05Resp`\n - Sends an SMS message\n - Supports international characters via UCS2 encoding\n\n- `sms_delete_all()` \u2192 `EM05Resp`\n - Deletes all SMS messages from storage\n\n##### AT Commands\n\n- `at_write(command: str, params: list)` \u2192 `EM05Resp`\n - Execute AT command with parameters\n \n- `at_read(command: str)` \u2192 `EM05Resp`\n - Query AT command value\n \n- `at_exe(command: str)` \u2192 `EM05Resp`\n - Execute AT command without parameters\n\n##### Utility\n\n- `info()` \u2192 `EM05Resp`\n - Get module information\n \n- `reset()` \u2192 `List[EM05Resp]`\n - Reset module to factory defaults\n \n- `close()`\n - Close serial connection\n\n### Data Classes\n\n#### SMSMessage\n```python\n@dataclass\nclass SMSMessage:\n store_index: int # Message index in storage\n status: str # Message status (e.g., \"REC UNREAD\")\n sender: str # Sender phone number\n timestamp: datetime # Message timestamp with timezone\n text: str # Message content\n```\n\n#### EM05Resp\n```python\n@dataclass\nclass EM05Resp:\n status: str # Response status (\"OK\", \"ERROR\", or \"\")\n raw: str # Raw response from module\n lines: list[str] # Parsed response lines\n```\n\n## AT Commands Reference\n\nThis library uses standard AT commands for SMS operations:\n\n- `AT+CMGF=1` - Set SMS text mode\n- `AT+CSCS=\"UCS2\"` - Set character set to UCS2\n- `AT+CMGL=\"ALL\"` - List all SMS messages\n- `AT+CMGS` - Send SMS message\n- `AT+CMGD` - Delete SMS messages\n\nFor detailed AT command documentation, refer to the [Quectel EM05 AT Commands Manual](https://forums.quectel.com/uploads/short-url/cBnrTmjnCg7OGnqRsk8dIpbHuVX.pdf).\n\n## Configuration\n\nThe module automatically configures itself on initialization:\n- Sets factory defaults (`AT&F`)\n- Enables text mode (`AT+CMGF=1`)\n- Disables echo (`ATE0`)\n- Sets UCS2 character encoding (`AT+CSCS=\"UCS2\"`)\n\n## Error Handling\n\nThe library includes comprehensive error handling:\n- Serial communication timeouts\n- UCS2 encoding/decoding errors\n- AT command response parsing\n- Debug logging for troubleshooting\n\n## Example Usage\n\nSee `main.py` for a complete example of listing and sending SMS messages.\n\n## License\n\nThis project is open source. Please refer to the license file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python library for Quectel EM05 cellular module SMS operations",
"version": "0.1.0",
"project_urls": {
"Bug Reports": "https://github.com/rikki/em05-sms/issues",
"Homepage": "https://github.com/rikki/em05-sms",
"Source": "https://github.com/rikki/em05-sms"
},
"split_keywords": [
"sms",
" cellular",
" quectel",
" em05",
" at-commands"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d2a16d5046bfd5ea9874a47f4ff8116c1416169a47d828b15249495cd417f6cb",
"md5": "7d91b4028695744e97f9473eb5b63a57",
"sha256": "97f7d87e72c343cf3e76868ccda6872f4d16a3e2ac07061b986dae6d2aa2d71d"
},
"downloads": -1,
"filename": "em05-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7d91b4028695744e97f9473eb5b63a57",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 6818,
"upload_time": "2025-07-08T10:18:28",
"upload_time_iso_8601": "2025-07-08T10:18:28.154525Z",
"url": "https://files.pythonhosted.org/packages/d2/a1/6d5046bfd5ea9874a47f4ff8116c1416169a47d828b15249495cd417f6cb/em05-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "45c9a8088f7e0b3287a145792ed055822c05fb0a70fbde6ecf4c25752c24326f",
"md5": "dd40dbd82dfcc272e9c1fbe103f0234c",
"sha256": "e5eb6df9e7bbbcaaefb4864b1686b9d5c1975fb467331e62678879064f513296"
},
"downloads": -1,
"filename": "em05-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "dd40dbd82dfcc272e9c1fbe103f0234c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 6894,
"upload_time": "2025-07-08T10:18:29",
"upload_time_iso_8601": "2025-07-08T10:18:29.738628Z",
"url": "https://files.pythonhosted.org/packages/45/c9/a8088f7e0b3287a145792ed055822c05fb0a70fbde6ecf4c25752c24326f/em05-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-08 10:18:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "rikki",
"github_project": "em05-sms",
"github_not_found": true,
"lcname": "em05"
}