Skip to main content

KSP-N51U-M.2 Send Data

After the KSP-N51U-M.2 is attached to the LTE-M / NB-IoT network and has an IP address, the next step is to send real application data.

This guide walks through a simple MQTT publish workflow:

  1. Confirm that the module already has a data connection.
  2. Configure the MQTT client.
  3. Connect to an MQTT broker.
  4. Publish a message.
  5. Verify that the broker received the message.
  6. Optionally subscribe to a command topic.
  7. Disconnect cleanly.

The KSP-N51U-M.2 is an internal slot-type LTE-M / NB-IoT module. It uses an M.2 2230 Key E connection, a U.FL antenna connector, and 3.3 V DC input from the host board. The module supports UART and I2C, while AT command control is performed over UART.

note

This page is a practical send-data workflow. It is not a full AT command reference. Exact command support may vary depending on the Serial Modem firmware version used by your KSP-N51U-M.2.


Before You Start

This page assumes the KSP-N51U-M.2 is already attached to the cellular network.

Before sending MQTT data, complete KSP-N51U-M.2 Network Attach and confirm the following items.

Check ItemCommand / SourcePass Condition
AT command pathATReturns OK
SIM statusAT+CPIN?SIM is ready
Network registrationAT+CEREG?Registered status
Signal qualityAT+CESQUsable RSRP / RSRQ values
IP addressAT+CGPADDRNon-empty IP address
Host UARTHost board / serial terminalUART path to the module is stable
Broker informationMQTT broker settingsHostname, port, username/password if required
tip

If the module does not have an IP address yet, finish KSP-N51U-M.2 Network Attach first.

caution

KSP-N51U-M.2 is an internal module. Before troubleshooting MQTT, first confirm the M.2 module is seated correctly, the host board supplies stable 3.3 V power, the U.FL antenna is connected, and the host UART path is working.


Send Data Flow

Use the following flow to publish one test message to an MQTT broker.

StepActionCommandExpected Result
1Configure the MQTT clientAT#XMQTTCFGOK
2Connect to the brokerAT#XMQTTCONOK, then #XMQTTEVT: 0,0
3Publish a messageAT#XMQTTPUBOK; for QoS 1/2, check the related #XMQTTEVT acknowledgement and verify the message at the broker
4Verify deliveryExternal MQTT client or cloud consoleMessage appears on the subscribed topic
5DisconnectAT#XMQTTCON=0OK, then #XMQTTEVT: 1,0
caution

Do not treat OK from AT#XMQTTPUB as final proof that the application received the data. OK confirms that the command was accepted by the AT interface. Always verify delivery through the broker, subscriber, cloud dashboard, or related MQTT event.


Step 1 — Configure the MQTT Client

Configure the MQTT client identity before connecting to the broker.

AT#XMQTTCFG="korlinx-ksp-n51u-m2",60,1

OK

The parameters are:

ParameterExampleDescription
Client ID"korlinx-ksp-n51u-m2"MQTT client identifier. It should be unique on the broker.
Keep-alive60MQTT keep-alive interval in seconds.
Clean session11 = clean session, 0 = persistent session.
note

Use a unique MQTT client ID for every device. If two devices connect to the same broker with the same client ID, the broker may disconnect one of them.


Step 2 — Connect to the MQTT Broker

Connect to the MQTT broker.

AT#XMQTTCON=1,"","","broker.example.com",1883

OK
#XMQTTEVT: 0,0

The parameters are:

ParameterExampleDescription
Operation1Connect using IPv4
Username""Empty when the broker does not require authentication
Password""Empty when the broker does not require authentication
Broker hostname"broker.example.com"MQTT broker hostname
Port1883Standard non-TLS MQTT port

The AT#XMQTTCON=1,... command returns OK first. The actual connection result is reported by an MQTT event.

EventMeaning
#XMQTTEVT: 0,0Connection request acknowledged successfully
Negative result valueConnection failed; check broker, port, credentials, TLS, or network path
#XMQTTEVT: 9,0Broker ping response after keep-alive, when reported
note

For TLS, use the TLS MQTT port, commonly 8883, and provide the security tag configured for the broker certificate if your firmware and broker setup require it.


Step 3 — Publish a Message

Publish a simple status message to a topic.

AT#XMQTTPUB="korlinx/ksp-n51u-m2/status","online",0,0

OK

The parameters are:

ParameterExampleDescription
Topic"korlinx/ksp-n51u-m2/status"MQTT topic to publish to
Payload"online"Message payload
QoS0MQTT QoS value
Retain00 = do not retain, 1 = broker retains the message

:::note Payload size The maximum payload size depends on the Serial Modem firmware version. In Nordic nRF Connect SDK 3.x documentation, the non-empty AT#XMQTTPUB payload size is up to 1024 bytes. Check the command reference for the exact firmware version used by your KSP-N51U-M.2. :::

QoS and Publish Acknowledgement

The QoS parameter uses MQTT QoS values 0, 1, or 2.

QoSTypical MeaningWhat to Check
0No publish acknowledgement requiredOK, then verify at the subscriber or broker side
1Broker acknowledgement expected#XMQTTEVT: 3,0
2QoS 2 publish flow#XMQTTEVT: 4,0, then #XMQTTEVT: 6,0
caution

The Serial Modem MQTT client uses MQTT QoS values, but it does not keep internal publish/subscribe state for retransmission or guaranteed packet delivery according to MQTT v3.1.1 QoS classes. For reliable application behavior, verify delivery at the broker or application layer.


Step 4 — Verify the Message Arrived

Use an external MQTT client, cloud dashboard, or broker console to subscribe to the same topic.

Example using mosquitto_sub:

mosquitto_sub -h broker.example.com -t "korlinx/ksp-n51u-m2/status"

Expected received message:

online
tip

Use an external subscriber during first testing. This confirms that the message reached the broker, not only that the AT command returned OK.


Step 5 — Receive a Message on the KSP-N51U-M.2

To receive a message on the KSP-N51U-M.2, subscribe to a command topic.

AT#XMQTTSUB="korlinx/ksp-n51u-m2/cmd",0

OK
#XMQTTEVT: 7,0

When a message is published to the subscribed topic, the module reports an incoming message notification.

#XMQTTMSG: 23,6
korlinx/ksp-n51u-m2/cmd
reboot
#XMQTTEVT: 2,0

The notification contains:

FieldMeaning
Topic lengthLength of the received topic
Message lengthLength of the received payload
TopicTopic that received the message
PayloadReceived message content
note

The sample topic korlinx/ksp-n51u-m2/cmd has 23 characters, and the sample payload reboot has 6 characters.


Step 6 — Disconnect from the Broker

Disconnect cleanly when the test is complete.

AT#XMQTTCON=0

OK
#XMQTTEVT: 1,0
EventMeaning
#XMQTTEVT: 1,0MQTT client disconnected successfully

Full Example

The sequence below shows a minimal end-to-end MQTT publish test.

AT
OK

AT#XMQTTCFG="korlinx-ksp-n51u-m2",60,1
OK

AT#XMQTTCON=1,"","","broker.example.com",1883
OK
#XMQTTEVT: 0,0

AT#XMQTTPUB="korlinx/ksp-n51u-m2/status","online",0,0
OK

AT#XMQTTCON=0
OK
#XMQTTEVT: 1,0

Host Board Cross-check

Because KSP-N51U-M.2 is an internal slot-type module, send-data issues may be related to the host board integration. Use this checklist together with the AT command results.

AreaWhat to CheckRelated Command / Source
PowerStable 3.3 V power from the M.2 socketHost board schematic / measurement
Module seatingModule is inserted and secured correctlyVisual / mechanical check
AntennaLTE antenna is connected to the U.FL connectorHardware check
UART pathHost UART is routed to the module correctlyAT
RegistrationModule is registered on LTE-M / NB-IoTAT+CEREG?
SignalCellular signal is usableAT+CESQ
IP addressData context is activeAT+CGPADDR
MQTT sessionBroker connection is activeAT#XMQTTCON and #XMQTTEVT
Application deliveryPayload reaches the broker or subscriberExternal MQTT client / cloud console

Verify the Checkpoints

CheckpointCommand / ToolPass Condition
Data connection is readyAT+CGPADDRNon-empty IP address
MQTT broker is connectedAT#XMQTTCON=1,...#XMQTTEVT: 0,0
Message command is acceptedAT#XMQTTPUBOK
Message is deliveredExternal MQTT subscriber / broker consolePayload appears on the target topic
Host board integration looks normalHost board checkStable power, UART routing, and antenna connection
MQTT client disconnects cleanlyAT#XMQTTCON=0#XMQTTEVT: 1,0

🎉 You're Ready!

Your KSP-N51U-M.2 has sent data successfully

You've completed the send-data flow from M.2 host integration to MQTT publish verification.

From module installation to broker-side confirmation — your KSP-N51U-M.2 is now ready for slot-type product integration.

Here's what you accomplished:
  • ✅ Confirmed that the M.2 module is powered by the host board
  • ✅ Verified UART communication with the module
  • ✅ Confirmed LTE-M / NB-IoT network attach
  • ✅ Confirmed that the module has an IP address
  • ✅ Connected to an MQTT broker
  • ✅ Published and verified a test message

What's next?

📡

Send Telemetry

Replace the test payload with real device, sensor, or system status data.

🧩

Host Board Integration

Move the tested AT command flow into your host board firmware.

☁️

Cloud Integration

Connect the MQTT topic structure to your cloud service or IoT dashboard.

🔧

Production Validation

Validate power stability, antenna placement, UART routing, and long-running MQTT sessions.

Your KSP-N51U-M.2 module is now sending data over LTE-M / NB-IoT. You can continue with host board integration, cloud connection, and production validation.


Troubleshooting

SymptomLikely CauseRecommended Action
No AT responseHost UART routing, serial settings, power, or M.2 seating issueCheck module seating, stable 3.3 V power, UART routing, TX/RX direction, and serial terminal settings
No IP from AT+CGPADDRModule is not attached or PDP context is not readyComplete KSP-N51U-M.2 Network Attach first
AT#XMQTTCON returns OK but no success eventBroker unreachable, DNS issue, blocked port, wrong credentials, or TLS issueCheck broker hostname, port, credentials, TLS settings, and network path
Connects, then disconnectsDuplicate client ID, keep-alive issue, broker policy, or unstable networkUse a unique client ID and verify keep-alive / broker settings
Publish returns ERRORInvalid topic, payload format, command syntax, or MQTT not connectedCheck command syntax and confirm MQTT connection status
Publish returns OK, but subscriber sees nothingTopic mismatch, broker ACL, wrong broker, or QoS/event issueVerify topic, broker, subscriber, QoS events, and broker permissions
TLS connection failsMissing or incorrect certificate/security tagProvision the correct CA certificate and use the correct security tag
Incoming message is not receivedNot subscribed, wrong topic, or broker permission issueCheck AT#XMQTTSUB, topic name, and broker ACL
Unstable MQTT sessionWeak signal, antenna issue, or unstable host powerCheck AT+CESQ, antenna connection, and host board power stability
note

Keep this page focused on MQTT send-data checks. Use KSP-N51U-M.2 Network Attach for registration, signal, APN, and IP-related issues.


Examples Data

The korlinx-at-examples repository provides runnable AT command examples for KORLINX LTE-M products.

Use this repository when you want to test the same send-data flow from a real host environment instead of typing every AT command manually in a serial terminal.

ExamplePurposeWhen to Use
helloOpen the serial port, send AT, and check for OKFirst communication test
attach_networkConfirm or trigger network attach, then check registration, signal, and IP addressBefore sending data
mqtt_publishConnect to an MQTT broker and publish a messageMain send-data test
mqtt_subscribeSubscribe to an MQTT topic and receive messagesCommand / downlink test
http_getFetch a URL over HTTPHTTP data test
tcp_socketOpen a raw TCP socket and exchange dataCustom TCP workflow
coap_clientMake a CoAP request over UDPCoAP workflow
gnss_fixAcquire a GNSS position fixLocation-related workflow

Quick Python Test

The fastest path is to start from the Python examples on a PC.

git clone https://github.com/KORLINX/korlinx-at-examples.git
cd korlinx-at-examples/python
pip install -r requirements.txt

Run the basic communication test first:

python hello.py --port /dev/ttyUSB0

On Windows, the port may look like this:

python hello.py --port COM5

On macOS, the port may look like this:

python hello.py --port /dev/cu.usbserial-0001

Other Protocols and Services

The product platform supports more than MQTT, depending on the firmware build and project configuration.

Protocol / ServiceUse ForSuggested Future Page
HTTPCalling a REST / web APIHTTP send-data guide
TCP / UDP socketRaw or custom transportSocket guide
CoAPConstrained REST over UDPCoAP guide
LwM2MDevice management / carrier workflowLwM2M guide
GNSSPosition acquisitionGNSS guide
note

This page intentionally focuses on MQTT send-data because it is a common telemetry workflow for cellular IoT. Add separate task pages for HTTP, sockets, CoAP, LwM2M, and GNSS when those workflows are ready.