Project showcase
Use Python to Access a SIM Module

Use Python to Access a SIM Module © MIT

This article described a recent Python library that I wrote which can send/receive texts and control phone calls.

  • 6 respects

Components and supplies

SIMCom Wireless Solutions SIM800L GSM Module
Arduino Mini USB serial adapter
US Mobile SIM Card

About this project


I was working on my quant investment project while I came up with this idea. This was a component of my whole project. My need is to being able to send and receive text to my cell phone to notify price changes and investment purchases.

I firstly tried to use Twilio services. My impression with them is good. However, because I do not want to expose my server on public domain and I don't want public access to my machine. I ended up not being able to receive text. Because, in order to receive text, Twilio will need to use webhook to access a link to notify the incoming text. Sure, there are other solutions to this. For me, I would like to use my own sim module to send/receive text.


I bought a SIM800L module online. This module has UART interface so ideally I can use its UART pins directly connecting to my Raspberry Pi. However, if you are using a laptop or a PC, you need something to convert the UART to something else. I finally decided to purchase another CH340 3.3V/5.5V USB To TTL Converter Module.

Regarding SIM card, there are a bunch of tutorials online using Hologram service. However, in my case, I need to send/receive texts and control phone calls. In this particular scenario, Hologram is not my best solution. I ended up using US Mobile SIM card because you can customize your phone plans and the price is very reasonable. Besides, you can get coupon code easily which made my first month bill to only around $5.


Although I am using CH340G USB to UART module similar to the one shown in the picture below, personally, I don't recommend using this one at all. Why? Let me explain it to you.

When I started my project, I was using a SIM7500A LTE module. Something like the image below.

To access it using USB, I am actually using another USB to UART module.

When I connected FT232RL UART to my SIM7500A, everything was working fine until around 3 weeks usage, FT232RL is no longer working. I believe it is broken. Then I have to buy another one in order to continue with my project. Finally I chose the one shown in the first image. Then my nightmare begins.

I spent quite sometime figuring out how to make this CH340G module work with my SIM7500A. It was simply never working. I started to understand the problem when I switched my SIM7500A to SIM800L. When I am using SIM800L with this CH340G module, all my commands sent to the SIM module start working. I thought my SIM7500A died. After sometime, I found SIM7500A is still working. However, the connection between SIM7500A and CH340G module is not working.

The wire connections are:

CH340G SIM800L

TX <--------> RX

RX <--------> TX

3V3 <--------> VCC

GND <--------> GND

SIM Commands

After connecting CH340G to your computer, you will see serial port appeared under /dev if you are using either Linux or Mac. Whichever you use, I prefer using screen linux tool to connect to the CH340G module.

The command for screen is:

screen /dev/<usbtty_file>  <baudrate>

If successful, if you type AT<enter> you will see something like this.


There are many tutorials online where you can get to know how to use these command to talk to the SIM module.

My Python Library

The problem with these AT commands is that they are very low level. Probably you never want to know the detail and just want to be able to send/receive text messages. That's why I made this python library.

There are other C and Python libraries available online. However, I just never find one that can give me something simple. You don't need to understand the low level details. All you need is just make a sub class of SIMModuleBase. Here is one example:

class MySIM(SIMModuleBase):    
    def on_sms(self, number, content):        
        print('Text from: {0}, Content: \"{1}\"'.format(number, content))    
    def on_call(self, number):
        print('Got phone call from {0}'.format(number))
    def on_call_missed(self, number):
        ''' This function is not working for SIM800
        self.sms_send(number, 'Sorry, I missed your call!')


My Github repository
This is the library I made for SIM module control


Similar projects you might like

Python Software for Arduino RFID

Project tutorial by Hamza Khalid

  • 14 respects

ARMin: Simple Robot Arm Controller Using Python

Project tutorial by HyperChiicken

  • 7 respects

LCD with DS3231 Real Time Clock Module

Project showcase by Tan See Youu

  • 40 respects
Add projectSign up / Login