Cellular IoT HAT Getting Started with UDP connection

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. You can do it by following Port Forwarding Tutorial. 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
  2.  

  3. Insert the Sim.
    cell_hat_sim
  4.  

  5. 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
  6.  

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

  2.  

  3. Now get into the cloned directory.
    cd Sixfab_RPi_CellularIoT_Library
    cell_hat_sw_2

  4.  

  5. Now install the library
    sudo python3 setup.py install
    Make sure you are installing it with python3.
    cell_hat_sw_3

  6.  

  7. Now goto sample directory
    cd sample/
    cell_hat_sw_4

  8.  

  9. Now open the basicUDP.py script.
    nano basicUDP.py
    cell_hat_sw_5

  10.  

  11. 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

  12.  

  13. Check if the node = cellulariot.CellularIoT() is uncommented.
    cell_hat_sw_7

  14.  

  15. Now save the python script and run with
    python3 basicUDP.py
    cell_hat_sw_8

  16.  

  17. 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

  18.  

  19. 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.

16 thoughts

  1. Hi !
    When I follow this tutorial for the Raspberry Pi Cellular IoT HAT – LTE-M & NB-IoT & eGPRS, the program loop at “AT+CGATT?”. Any idea of what could be wrong with my device ?

  2. Hi Saeed, thank you for your response.

    However it is.. I didn’t modify the band : node.setGSMBand(node.GSM_900)
    node.setCATM1Band(node.LTE_B5)
    node.setNBIoTBand(node.LTE_B20)

    I’m located in Singapore. Could it be the problem ?

  3. OK, I think I understand what you mean. I’ve changed the band to GSM_1800 as I’m using a Sim card operator : M1 and APN: sunsurf.
    I use the GSM_MODE.

    Unfortunately, it still doesn’t work. But thank you for your response, I will research a solution.

    • Hi, Since you are using LTE CAT M1,

      use
      node.setMode(CATM1_MODE)
      node.setCATM1Band(node.LTE_B5) #Make sure B5 supports in your location. If you don’t know your band you can use LTE_CATM1_ANY instead.

  4. Hi again,

    I tried with CATM1_MODE and LTE_CATM1_ANY and it still doesn’t work. Is there other test I could try to find my problem ?

      • Here is the output. I have tried with GSM_MODE but it’s the same result.

        Sixfab Raspberry Pi Cellular IoT Shield Class initialized!
        BG96 module disabled!
        BG96 module enabled!
        BG96 module powered up!
        ATE1
        ATE1
        ATE1
        OK

        AT+CGSN
        AT+CGSN
        866425039281441

        OK

        AT+CGMR
        AT+CGMR
        BG96MAR02A07M1G

        OK

        AT+CGMM
        AT+CGMM
        BG96

        OK

        AT+QCFG=”band”,2,0,0
        AT+QCFG=”band”,2,0,0
        OK

        AT+QCFG=”band”,0,400A0E189F,0
        AT+QCFG=”band”,0,400A0E189F,0
        OK

        AT+QCFG=”band”,0,0,80000
        AT+QCFG=”band”,0,0,80000
        OK

        AT+QCFG=”band”
        AT+QCFG=”band”
        +QCFG: “band”,0x2,0x400a0e189f,0x80000

        OK

        AT+QCFG=”nwscanseq”,02,1
        AT+QCFG=”nwscanseq”,02,1
        OK

        AT+QCFG=”nwscanmode”,3,1
        AT+QCFG=”nwscanmode”,3,1
        OK

        AT+QCFG=”iotopmode”,0,1
        AT+QCFG=”iotopmode”,0,1
        OK

        Modem configuration : CATM1_MODE
        AT+CSQ
        AT+CSQ
        +CSQ: 99,99

        OK

        AT+QNWINFO
        AT+QNWINFO
        +QNWINFO: No Service

        OK

        Trying to connect base station of operator…
        AT+CGATT?
        AT+CGATT?

  5. I have an issue with getting my GPS location with the IoT HAT.

    So I used the Turn on GPS command “turnOnGNSS” it turns with OK,
    next I use the command “getLatitude” it turns with error that means it can’t loc the GPS.

    But when I use the minicom I can see the GPS sending location normally, why ? is it because the cellulariot.py doesn’t have the ttyUSB1 connected ?

  6. I am getting File Not Found Error – No such file or directory: ‘/dev/ttyS0’
    there are no ttyS* devices in /dev directory.

    I have also run the ppp installer tutorial here.
    Any help is appreciated. Thanks

    • How did you enable the serial connection ?

      It should normally be done (as an easy method)
      sudo raspi-config
      Select option 5, Interfacing options,
      then option P6, Serial,
      Select No to Serial Console
      Select Yes to Serial Port.
      Reboot.

      Can you share the output of ls /dev/serial/by-id/?

      • I was getting a similar error.
        I have enabled serial and its at ttyUSB0. Where to apply this setting to change ttyS0?

        ls /dev/serial/by-id
        total 0
        lrwxrwxrwx 1 root root 13 Jul 3 09:55 usb-FTDI_TTL232R-3V3_FTBHKTHS-if00-port0 -> ../../ttyUSB0

Leave a Reply

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