Sending SMS with a controller NJ/NX using a CIF connected to a GSM modem

Modified on Fri, 15 Aug, 2025 at 4:23 PM

Send_SMS_NXCIF Library Documentation

The library Send_SMS_NXCIF initializes a standard modem and sends dedicated messages using Hayes commands.

When activated, the function block sends the following initialization sequence:

CommandDescription
ATE0Echo OFF
&D0DTR ignored
+IPR=9600Speed 9600Bps
+ICF=3,4Format 8,N,1
+IFC=0,0No RTS/CTS control

Then request for the SIM status: AT+CPIN?<Cr><Lf>

If the response contains SIM PIN, it sends the PIN code: AT+CPIN=PINcode<Cr><Lf>

If the response contains READY, the FB requests the signal level: AT+CSQ<Cr><Lf>

The value is output to the variable SignalQuality.

Wiring:

Example with the Westermo GDW-11

Setup

With an option NX1W-CIF, No-Protocol should be selected

The location information of the CIF Node Location Port is obtained with a right click on the CIF Option or CIF Unit in the I/O Map

Input variables:

NameTypeValueDescription
EnableBOOLON, OFF
OptionLocationInfo
or
UnitLocationInfo
_sOPTBOARD_ID
or
_sNXUNIT_ID
---Location information of NXC1W-CIF or NX-CIF Unit
PortNoUSINT1, 2Serial port number
PINcodeSTRING[5]---PIN code of SIM card
Check_SignalBOOLON, OFFRequest to read signal level
Tel_NumberSTRING[14]---Telephone number
MessageSTRING[159]---Message to send
Send_SMSBOOLON, OFFCommand to send SMS

Output variables:

NameTypeValueDescription
ENOBOOLOFF, ONFB activated
Init_FailBOOLOFF, ONThe initialization sequence failed
PINcode_FailBOOLOFF, ONPIN code rejected
SignalQualitySTRING[6]---Signal level
Send_FailBOOLOFF, ONFail sending the SMS
ErrorBOOLOFF, ONError flag. If ErrorID=0: modem error
ErrorIDWORD0-FFFFAn instruction execution failed (input error code at support-omron.fr)
Msg_SentBOOLOFF, ONMessage sent

Example of communications between a NX1P and a Westermo (WEST) modem

Initialization:

[10:55:30.355] NX1P: ATE0;&D0;+IPR=9600;+ICF=3,4;+IFC=0,0<Cr><Lf>

[10:55:30.480] WEST: <Cr><Lf>OK<Cr><Lf>

[10:55:30.820] NX1P: AT+CPIN?<Cr><Lf>

[10:55:30.879] WEST: <Cr><Lf>+CPIN: SIM PIN<Cr><Lf>

[10:55:31.285] NX1P: AT+CPIN=0000<Cr><Lf>

[10:55:32.152] WEST: <Cr><Lf>OK<Cr><Lf>

[10:55:33.355] NX1P: AT+CSQ<Cr><Lf>

[10:55:33.414] WEST: <Cr><Lf>+CSQ: 31,0<Cr><Lf><Cr><Lf>OK<Cr><Lf>

Sending My TEST:

[10:59:03.004] NX1P: AT+CMGS="+336xxxxxxxx"<Cr><Lf>

[10:59:03.094] WEST: <Cr><Lf>>

[10:59:04.063] NX1P: My TEST<26>

[10:59:06.539] WEST: <Cr><Lf>+CMGS: 23<Cr><Lf><Cr><Lf>OK<Cr><Lf>

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article