How to send and receive SMS with Raspberry Pi automation
How to send and receive SMS with Raspberry Pi automation

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

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 Touchberry Pi 10" Panel PC with the SIM7600E 4G Hat module to your mobile phone.

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:

Connections between Raspberry Pi board and 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


Conclusion

If you are interested in deploying SMS automation on a Raspberry Pi using the SIM7600E-H 4G HAT module, follow the steps below; you will be able to seamlessly integrate SMS functionality, enhancing control and communication in your Raspberry Pi-based automation projects.


要查看或添加评论,请登录

社区洞察

其他会员也浏览了