Send SMS from Raspberry Pi with USB 3G

In Digital Marketing Strategy, email and SMS are the important tools to improve your  customer services. And Raspberry Pi is a good platform to help us to implement sending email or SMS.

In this weekend, I try to send SMS from Raspberry Pi with USB 3G, and i was successful.  I used a Raspberry Pi 2 model B, and a USB 3G (I am in Vietnam, so I bought a Viettel USB 3G).

Send SMS with Raspberry Pi and USB 3G Viettel

Send SMS with Raspberry Pi and USB 3G Viettel

At the first step, plug USB 3G in Raspberry Pi, and restart Pi.
From the terminal, type lsusb command:

And using dmesg command, find ttyUSB:

If you see the output above, it means that USB 3G connection is correct.

Now, we need to install a software to help us connect to serial port ttyUSB. That software is picocom:

After that, try to connect ttyUSB1 with command:

If you see the output has “terminal ready” and you try to type “AT” and receive the response “OK”. It means that your connection is prefect. Now, you type “AT+CMFG=1” to change to “text mode”

And try to send a SMS message with command:

Finally, press Ctrl + a + x to exit picocom terminal.

If you send SMS successfully with picocom. And now, we write a Python script to send SMS message.  You can see the source code below. It is so simple.

To build a high performance SMS sender, we should apply Redis Pub/Sub to push all messages need to send to Queue.

Good luck!

  • hitogami

    hi there i follow your method but when i type AT+CMFG=1 it say command not supported. pls help

  • Tạ Đức

    Hi anh!
    i used Viettel 3g usb too. But when i type AT+CMGF?, ERROR appeared. pls help

  • Hong Tien Le

    Hi friend,
    Tôi định sử dụng USB 3G của VietTel để nhận tin nhắn tự động. Tôi gửi tin nhắn OK, nhưng chưa đọc được tin gửi tới. Bạn có biết bộ lệnh AT của nó không?
    Cảm ơn.
    Lê Hồng Tiến