Basic UDP Communication Tutorial for Sixfab RPi Cellular IoT Application Shield

Our previous tutorial was about observing data from the available sensors on the Sixfab R.Pi Cellular IoT Application Shield. Since our shield is capable of combined LTE technologies Cat.M1, Cat.NB1 (NB-IoT) and eGPRS we will be demonstrating transmitting data over UDP.

Before we start with the Raspberry Pi Cellular IoT Shield, we will need to make some setup for our router. The steps are as follows:

1. Login to you routers configurations, by going to 192.168.1.1(generally this is the address for router configurations, might change for some router) from your Internet browser and login with your own credentials.

2

2. Now scroll down at Basic Status page to find your IP address of your connection (which is mentioned as dsl_internet in our case). We will need it later.

3a

3. Now click on Forwarding form the option list and then click Virtual Server.

4. Then click on Add New, which will take you to the following screen. Now fill up Service Port(as desired, in our case it is 5000), IP Address(It is IP Address of your Computer/Laptop. Check the note below if you don’t know how to obtain your IP Address) and select Protocol(as UDP). Click Save.

5a

** Note: Open your terminal and run ifconfig command to obtain your IP Address. This is applicable for linux users. Windows user can type ipconfig in cmd command.

5. Now insert your SIM card to Sixfab Raspberry Pi Cellular IoT Application Shield and plug the antenna to LTE port.

rpi_ciot_img46. Now attach the Shield to your Raspberry Pi and turn ON your Raspberry Pi. Make sure your I2C and Serial interfaces are enabled from raspi-config.

7. Now clone our github Repo to your Raspberry Pi to install our library(If you have already done it, you may skip to step 10).

git clone https://github.com/sixfab/Sixfab_RPi_CellularIoT_Library.git

rpi_ciot_code1

8. Once the repo is cloned get into the Sixfab_Rpi_CellularIoT_Library

cd Sixfab_Rpi_CellularIoT_Library

rpi_ciot_code2

9. Now install the library by

sudo python3 setup.py install

rpi_ciot_code3

The library is written with python3 so we will be writing and running every script in python3.

*** Alternate method of installing the library is using pip3. Simply run the following command.

sudo pip3 install sixfab-cellulariot

once after installation you will need the scripts from github repo.

10. Once it is installed you may get into sample directory where you will find examples for the shield.

cd sample

rpi_ciot_code4

11. Here we will need basicUDP.py script for this tutorial. Before running the script, we will need to make some changes in the script. Type

nano basicUDP.py

rpi_ciot_code5

12. Now find the following lines

your_ip = "xx.xx.xx.xx"
your_port = "xxxx"

and replace xx.xx.xx.xx with your Router’s IP and xxxx with your defined port. Then save the script with the changes.

rpi_ciot_code6

13. Before you run the script, open a terminal to listen the data sent over UDP. Type the following command to listen the data. Here 5000 is my port address that I set at step 4.

netcat -ul -p5000

rpi_ciot_code8

14. Once you have changed and saved your changes run the following command to run your script.

python3 basicUDP.py

rpi_ciot_code7

15. Once you run the script you will be able to see the SEND OK at the end.

rpi_ciot_code9

16. On the other terminal where you were listening to UDP data you will be able to see the received data as follows

rpi_ciot_code10

In this way, you will be able to send data over UDP using your Sixfab R.Pi Cellular IoT Application Shield.

21 thoughts

    • Hey,
      Carrier having any of B1/ B2/ B3/ B4/ B5/ B8/ B12/ B13/ B18/ B19/ B20/ B26/ B28 and B39 will work with M1.
      AT&T, Boost Mobile, FreedomPop, Mint Mobile, Sprint, US Cellular, Verizon Wireless, Cricket Wireless, MetroPCS works with M1 chipset.

  1. I’m using a Project Fi Data only card and I’m getting ATE1 repeating after following all the instructions. Is there a way to set the APN? I have the Sprint network also and I believe they need to add the IMEI number to their network, has anyone got this to work on Sprint? Has anyone one in the US got this to work and if so, what network?

  2. For full disclosure, I installed Raspbian and all updates but did not get the TTYS0 but instead TTYAMA0. I added a SYMLINK so that TTYS0 would connect to the serial TTYAMA0 port. I’m not sure why I could not get the TTYS0 that is shown in this tutorial. I installed Raspbian a number of times.

  3. Why do I need to create a host IP forwarding virtual server?? I am going to use only one port!!
    what if someone can’t access the router’s configuration menu?

  4. I keep getting a response of “AT+CGATT?” over and over again. I don’t know what it means or what could be going wrong.

    I am using a Hologram SIM card in the US

    • You will need to send AT+QICSGP in order to set APN.
      For example,
      AT+QICSGP=1,1,”hologram”,””,””,1 // Set APN network to hologram

      Thank you for mentioning it. We will add this to our library.

  5. Hi Saeed, I’ve followed your tutorial and was able to get “send ok” , But on the receiver side, how do i receive it? Tried netcat -ul -p[port] doesn’t work. Thanks

  6. Hi Saeed I was trying to send SMS to my phone and I replaced the xxx with my number still did not get any SMS on my phone. Please help me

  7. Hi,

    In which variable is stored AT commands response? How can I store AT commands responses into a variable?

    Best regards

    • Hi,
      Carrier having any of B1/ B2/ B3/ B4/ B5/ B8/ B12/ B13/ B18/ B19/ B20/ B26/ B28 and B39 will work with M1.

  8. – SuperSIM is registered and paid for
    – PPP installer run
    – Port forwarded on the router to wifi i/f of Raspi4
    – python3 basicUDP.py ran

    I keep hanging here:

    Modem configuration : GSM_MODE
    Trying to connect base station of operator…

Leave a Reply

Your email address will not be published. Required fields are marked *