How to send and receive SMS with Raspberry Pi automation

SMS between GSM module and mobile phone, working with SIM7600E 4G HAT module and a Raspberry Pi Board
May 19, 2021 by
How to send and receive SMS with Raspberry Pi automation
Boot & Work Corp. S.L., Fernandez Queralt Martinez

Introduction

In this post, you will learn more about SIM7600E-H 4G HAT for industrial Raspberry Pi PLC controller, LTE Cat-4 4G / 3G / 2G, GNSS, for Europe, Southeast Asia, West Asia and Africa, and you are going to test it.

For the testing, you will send an SMS from your Toucherry Pi 10" Panel PC monitoring for industrial automation with the SIM7600E 4G Hat module to your mobile phone. 

Related links

How to

Connect industrial Raspberry PLC to Wi-Fi

Read 

Raspberry PLC

Family products

See 

How to

Program Raspberry PLC Interrupt inputs with Python

Read 

Basics about

Raspberry Pi based PLC Analog Outputs

Read 

Touchberry Pi

Family products

See 

How to

Find your perfect industrial PLC

Read 


Connections between Raspberry Pi board and SIM7600E-H 4G Hat module

In this case, you can see a Raspberry Pi 4  from an open source PLC Raspberry Pi connected to the SIM7600E-H 4G Hat module through the USB port as shown:

Raspberry Pi 4 connected to the SIM7600E-H 4G Hat module

SIM7600E-H 4G HAT

GPRS (General Packet Radio Service) is an extension of GSM based on packet transmission that offers a more efficient service for data communications, especially in the case of Internet access.

GSM (Global System for global Communications) is the communication system most widely used in mobile phones, and its first functionality is voice transmission. However, it also allows data transmission like SMS or the internet, at a deficient speed.

The SIM7600E-H 4G HAT is a multi-band LTE-TDD/LTE-FDD/HSPA+ and GSM/GPRS/EDGE module solution in an SMT type that supports LTE CAT1 up to 10Mbps for downlink data transfer. It has strong extension capability with rich interfaces including UART, USB2.0, I2C, GPIO, etc. With abundant application capabilities like TCP/UDP/FTP/FTPS/HTTP/HTTPS/DNS, the module provides much flexibility and ease of integration for customers' applications, such as open source projects.


Sending SMS

The AT+CMGF command is used to instruct the GSM / GPRS modem to operate in SMS text mode. So, insert your SIM Card and into the SIM7600X board and let's start!

First, ensure that the hardware is right connected. So, connect open up a terminal window and type "sudo raspi-config" > Go to Interface Options > Serial Port > Reject the login shell to be accessible over serial > Accept the serial port hardware to be enabled.

Now, open the Serial Port by installing the screening tool:
sudo apt update
sudo apt install screen
screen /dev/ttyUSB2 115200 (you can use USB0, USB1 or USB2)



Once in the Serial Port, let's send some AT commands:

AT                              The device recognizes the SIM7600E module
OK                              Response  
AT+CFUN=1             Set phone functionality
OK                              Response  
AT+CMGF=1            Set the GSM modem in SMS Text Mode
OK                             Response  
AT+CMGS="+34666XXXX66"    <--    Add a phone number
> Type here your text message   <-- (Do not finish it with an Enter, but with Ctrl + Z)
OK                             Response
  

 Know more about AT commands  here >

Receiving SMS

The AT + CMGL command lists messages received on the GSM / GPRS modem. It can be used to get all received messages, all unread messages, or all read messages.

Finally, let's set the GSM modem to Text Mode SMS and read all received messages:

AT+CMGF=1                    Set the GSM modem in SMS Text Mode
OK                                 Response  
AT+CMGL="ALL"           <-- List all received messages
+ CMGL: 0, "REC READ", "+346XXXXXXX6", "", "21/05/21,12:32:09+08"
HIGH Temperature
OK                                     Response


Want to know more and learn how to work with the GPRS on Raspberry Pi industrial PLC?

Read the following post.

​Search in our Blog

How to send and receive SMS with Raspberry Pi automation
Boot & Work Corp. S.L., Fernandez Queralt Martinez May 19, 2021
Share this post

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>