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,0Expected 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",PORTExpected 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=0Expected response: #XSOCKET:0,"closed"
On your server terminal, you should see:
Hello World2. Enable Downlink (Server → Device)
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:
Receive data over your UDP connection
Expected response:
Close the socket when done:
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#XRECVbefore closing the socketGeneral connectivity issues: Check device logs at hub.monogoto.io to verify device registration and connection status
Last updated
Was this helpful?