Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria
Node-RED Tutorial: How to send AT commands with Raspberry PLC
Send and receive SMS using Raspberry based PLC
GSM (Global System for Global Communications) is the communication system most widely used in mobile phones, and its first functionality is the voice transmission. However, it also allows data transmission like SMS or Internet, at a very low speed.
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.
In this blog, you will learn how to send AT commands, specially how to send SMS from your Industrial GPRS family PLC Raspberry to your mobile phone.
In this blog, we are going to develop a Node-RED flow to send SMS messages from the GSM module of Raspberry PLC to our mobile phone. The AT commands that we are going to use are the same as we used in this blog.
First of all, check the following from your Raspberry PLC:
SSH is enabled
Node-RED is installed in your Raspberry PLC
If you go to minicom using:
sudo minicom -D /dev/ttyS0 -b 115200
and type AT, you receive OK.
And once everything is ready, let's go with the Node-RED application!
Go to your favourite browser, type the IP address from your Raspberry PLC and start your App.
As we mentioned before, we are going to send the following to our /dev/ttyS0 port to get the response.
So the first thing that we are going to do it to add five inject nodes to set the msg.payload to the String messages like this:
As we can see in the picture above, after every message we must add an Enter character (\n), and also a Ctrl + Z right between the "Hello" message and \n.
So we are going to wire these five inject nodes to a function node, where we will add those characters in hexadecimal.
To add the \n after the AT commands, add the \n parsed in hexadecimal to a function node as shown:
msg.payload += Buffer.from("0D", "hex");
Note that there the symbol is += to append the \n after the AT commands.
Now, we have to add a Ctrl + Z character between the Hello message that we want to send, and the \n. The Ctrl + Z is represented by 1a in hexadecimal. So add the following to a function node and wire it between the inject node the the function node with \n.
msg.payload += Buffer.from("1a", "hex"); return msg;
Then, look for the serial out node and configure it as you want. We left the default values and configured the following:
Data Bits: 8
Stop Bits: 1
Add a serial in node wired to a debug node, where you will get the responses from the same port.
Finally, click on the buttons of the inject nodes, and see the results!