How To : Send SMS on 750-8217 using Python

On a 750-8217 (PFC200 with 4G modem), it is possible to send SMS via the Linux layer. This may be useful if you’re not using CODESYS, but high-level languages such as Python.
To do this, you need to send AT commands via a specific port.

First of all, you need to configure the PIN code in the Web-Based Management (or even the APN if you’re also using a data connection).

The USB port to be used is the ttyUSB2, the baudrate is 115200 baud.

Before moving on to the Python (or other), i’w would advice to test communication with the modem using the minicom utility. This is the ideal tool for testing AT commands before integrating them into the code. For this purpose, I used the Docker image pheonix991/minicom-box-arm, which is arm-compatible.

docker run -it --rm --device=/dev/ttyUSB2:/dev/mydevice pheonix991/minicom-box-arm

If everything is fine, without doing anything, some AT commands are sent, along with the OK response. These are in fact commands sent by the modem manager (which, among other things, enables diagnostics).

If required, you can stop the service to be able to send AT commands yourself (using another SSH session is more convenient).

/etc/init.d/mdmd-ng stop

For example, try the following commands (in order)

ATE (activate echo)
>Hello World 
(Ctrl + Z to send)
(X to quit minicom)

(Remember to reactivate the service that manages the modem)

/etc/init.d/mdmd-ng start

Now it’s time to send AT command from the Python script.
Just remember to associate the host port /dev/ttyUSB2 with the container port and use the right baudrate (115200).

Here you’ll find a small Dockerized Python script to test this :

 docker run --rm --device=/dev/ttyUSB2:/dev/ttyUSB2:rw quenorha/sendsms -r "+336XXXXXXXX" -m "hello world"

List of AT commands for the Quectel EC25 modem: