Nordic nRF9151: Send/Receive UDP Data

Start sending data to a UDP server, and from the server back to the device. For more information about getting started with the Nordic nRF9151, visit this guide.

1. Send Data from Your Device

Create a UDP Socket

AT#XSOCKET=1,2,0

Expected Response: #XSOCKET: 0,2,17

Connect the Socket

Replace YOUR_SERVER_IP and PORT (e.g. 9000) with your server's ip address and port.

AT#XCONNECT="YOUR_SERVER_IP",PORT

Expected response: #XCONNECT:1

Send UDP Payload

Send the message Hello World

AT#XSEND="Hello World"

Expected response: %SOCKETDATA: 1,11

Close the UDP Socket

AT#XSOCKET=0

Expected response: #XSOCKET:0,"closed"

On your server terminal, you should see:

Hello World
circle-check

Since the SIM by default doesn't have a public IP address, we can only send a downlink immediately after receiving an uplink, before the socket is closed. The server responds using the same IP address and port from which the data was received.

To test this, you'll need a UDP server that sends a response. You can use socat with a script that logs incoming data and sends "ACK" as a response:


3. Test Bidirectional Communication

On your device, send data and wait for a response.

Start by opening the UDP port and send data to your UDP server:

circle-info

On your server terminal, you should see:

Receive data over your UDP connection

Expected response:

Close the socket when done:

circle-check

Troubleshooting

  • No data received on server: Check your firewall allows UDP port 9000 (ufw allow 9000/udp)

  • Connection timeout on device: Verify the server IP address is correct

  • No downlink received: Make sure to call AT#XRECV before closing the socket

  • General connectivity issues: Check device logs at hub.monogoto.ioarrow-up-right to verify device registration and connection status

Last updated

Was this helpful?