Cellular IoT HAT Getting Started with UDP connection

Saeed • 1 Mar 2019
General
cell hat featured min scaled

Related Blog Post

Subscribe to our newsletter

Sixfab came up with Raspberry Pi Cellular IoT HAT. This time it is a Hat rather than a shield. To be more specific this HAT is lighter version of our previous Raspberry Pi Cellular IoT Application Shield, where both uses Quectel BG96 module. The major difference is the peripheral sensors, the HAT doesn’t contain any sensors on it.


What is the feature of this HAT?
This HAT contains Quectel BG96 which has combined LTE technologies Cat.M1, Cat.NB1 and eGPRS.
It also supports GPS.

Preconfiguration

Before we start working with the HAT, let us setup our router settings and Raspberry pi.
Your router needs port forwarding for UDP connection.  Note down the IP address of your router and UDP port number.
The Serial port hardware of your Raspberry Pi should be enabled and Login shell to be accessible over serial should be disabled. This can be done from raspi-config.

Hardware Setup

    1. Attach the Cellular IoT HAT to your Raspberry Pi.
      cell_hat_hw
    1. Insert the Sim.
      cell_hat_sim
    1. Plug the antenna. You will need one LTE antenna with u.FL for this tutorial. Here, I am using LTE Full Band PCB Antenna.
      cell_hat_Antenna

Software Setup

Now we are ready to start.

    1. Download/clone the library from github
      git clone https://github.com/sixfab/Sixfab_RPi_CellularIoT_App_Shield.git
      cell_hat_sw_1
    1. Now get into the cloned directory.
      cd Sixfab_RPi_CellularIoT_Library
      cell_hat_sw_2
    1. Now install the library
      sudo python3 setup.py install
      Make sure you are installing it with python3.
      cell_hat_sw_3
    1. Now goto sample directory
      cd sample/
      cell_hat_sw_4
    1. Now open the basicUDP.py script.
      nano basicUDP.py
      cell_hat_sw_5
    1. Here, you will see following two lines.
      your_ip = "xx.xx.xx.xx"; 
      your_port = "xxxx"; 

      You have to replace these information with your own which have set in the preconfiguration step that is the routers IP and the UDP port address.
      cell_hat_sw_6

    1. Check if the node = cellulariot.CellularIoT() is uncommented.
      cell_hat_sw_7
    1. Now save the python script and run with
      python3 basicUDP.py
      cell_hat_sw_8
    1. Just before running the script open a new terminal in your laptop and type
      netcat -ul -p5000
      Here 5000 is my port number. Replace it with your port number. (This is to be done in the Device where you have directed the UDP port during the preconfiguration step)
      cell_shield_udp_sw_8
  1. Here you can see the Data that has been sent over UDP.
    cell_shield_udp_sw_10

Hence, We are done with the tutorial here. Please write suggestions, questions and feedback in the comment section below.