Skip to content

GateBerry - Expansion Boards

The GateBerry PLC has 1 slot for additional communication. Check the pinout in the block diagram.

4G (LTE CAT M1 / NB-IoT)

4G LTE CAT M1/NB-IoT are cellular communication technologies designed for the Internet of Things (IoT). They provide low-power, wide-coverage, and cost-efficient connectivity, ideal for devices that transmit small amounts of data such as sensors, smart meters, and trackers.

Module

The module used to provide LTE CAT M1 and NB IoT communication is the U-blox SARA range, specifically the modules:

  • SARA-R412M
  • SARA-R422M8S

Here are some of their manuals:

Hardware Setup

When purchasing a GateBerry equipped with the cellular communication expansion module, an additional output is provided for external antennas through female SMA coaxial connectors, which are directly linked to the communication module.

The hardware assembly should appear as shown in the following image:


The device includes a SIM card slot, located as shown in the image below:


SIM recommendation

The module only supports Micro SIM cards. If you have a Nano SIM, please use a Micro SIM adapter to ensure proper fit and to prevent connector damage.

It is recommended to use precision tweezers when inserting or removing the SIM card to protect both the connector and the card.

Software Setup

This setup allows us to configure the connection with the module. It only needs to be done once.

  1. Check if dtoverlay=uart3 or dtoverlay=uart2 (Depending on the Raspberry PI version) in /boot/firmware/config.txt

    sudo nano /boot/firmware/config.txt
    

    Look for these configuration lines:

    dtoverlay=uart3
    
    dtoverlay=uart2
    

    If it does not exist, it should be added, and then reboot the device to make the changes effective.

    sudo reboot now
    
  2. Copy or Download the setup

    Warning

    If your SIM needs to be unlocked using a PIN number, this script will not work for it.

    Check it here: setup-sara.sh

    nano setup-sara.sh
    

    or, if you have an internet connection, download this file as follows

    wget https://apps.industrialshields.com/main/rpi/gateberry/setup-sara.sh
    

    To make the script executable, run the following command:

    chmod +x setup-sara.sh
    

    Next, execute the script with administrative privileges:

    sudo ./setup-sara.sh
    

    During execution, the script will prompt you to enter your connection credentials, as shown below.

    Once the process is complete, two system services will be created:

    • pppd.service: responsible for creating the ppp0 interface to simplify the connection process.
    • check-ppp0.service: ensures that the interface and connection are functioning correctly.

Working Test & Troubleshooting

  1. Check service status

    Run the following commands to verify that the services are active:

    sudo systemctl status check-ppp0.service
    sudo systemctl status pppd.service
    

  2. Stop the services

    Before executing the communication test script, stop the services to prevent communication conflicts with the module:

    sudo systemctl stop check-ppp0.service
    sudo systemctl stop pppd.service
    

  3. Run the test script

    To test communication with the module, execute the configuration script in NB mode. This step is only intended to confirm that communication is working correctly.

    /usr/bin/python3 /usr/local/bin/network-setup.py nb-iot
    

  4. Verify network interface

    If the script completes successfully, list the network interfaces with:

    ip a
    
    You should see the ppp0 interface. To verify network access, run:
    ping -I ppp0 8.8.8.8
    

  5. Restart the services

    After completing the test, restart the services using:

    sudo systemctl start check-ppp0.service
    sudo systemctl start pppd.service
    
    6. Restore system state

    Finally, reboot the system to return to its normal operating state:

    sudo reboot
    


CAN

CAN (Controller Area Network) is a robust communication protocol designed for real-time data exchange between electronic control units (ECUs) in vehicles and industrial systems. It enables reliable, high-speed, and error-resistant communication without requiring a central computer, making it ideal for automotive, industrial, and automation applications.

Module

The selected module for enabling GateBerry PLC to communicate via the CAN protocol is the MCP2515, connected to the PLC through SPI. It allows configuring a 120 Ω termination resistor (selectable at the time of PLC purchase).

Important features and values ​​to consider

Interface typeCAN Bus
Communication speed (baud rate)Configurable
Connectors and wiringM3 adapter connector (H (CAN High) and L (CAN Low))
Termination resistor120 ohms (selectable at the time of PLC purchase)

Hardware setup

CAN Bus Connection

The PLC can be connected to the CAN bus as shown in the image below:


Termination resistor configuration

When purchasing the PLC you must select whether you will use the PLC at one end of the line or in the middle of the bus.

  • If you use it at one end, select the default option, where this resistor is built in.
  • Otherwise, select the option that eliminates this termination resistor.

Software setup

To configure the CAN module and establish communication with the PLC, follow these steps:

Edit the firmware configuration file /boot/firmware/config.txt:

sudo nano /boot/firmware/config.txt

Add the following overlay:

dtoverlay=mcp2515,spi0-0,oscillator=10000000,interrupt=21,speed=125000
Parameters explanation:

  • spi0-0: MCP2515 connected to SPI bus with CS on gpio 8.
  • oscillator=10000000: 10 MHz oscillator.
  • interrupt=21: interrupt pin.
  • speed=125000: default baud rate 125 kbps.

Save and exit with Ctrl+S and Ctrl+X.

Reboot the PLC to apply changes:

sudo reboot

Verify correct module initialization, with the command:

dmesg | grep mcp
You can also check with:ifconfig can0 or ip a

If CAN doesn't appear as UP, use this command to change its status:

sudo ip link set can0 up type can bitrate 125000

Working Test & Troubleshooting

To ensure the module works correctly, use the tools provided by the can-utils library. Install can-utils

sudo apt install can-utils

candump can0
If the bus is configured correctly, this command will display data transmitted over the CAN bus.

cansend can0 111#FF
  • 111: CAN message identifier.
  • FF: data sent in hexadecimal.

This command allows testing communication by sending test messages on the CAN network and verifying reception on other connected nodes.


LoRa

LoRa is a low-power, long-range wireless communication technology designed for the Internet of Things (IoT). It enables long-distance data transmission with minimal energy consumption, making it ideal for battery-powered devices such as sensors, trackers, and smart city applications. It operates on unlicensed radio frequencies, reducing deployment costs and increasing flexibility.

Modules

The selected modules to enable LoRa communication on GateBerry are:

  • Europe & Asia: RN2483A
  • America: RN2903A

Hardware Setup

When purchasing a GateBerry equipped with the LoRa communication expansion module, an additional output is provided for external antennas through female SMA coaxial connectors, which are directly linked to the communication module.

The hardware assembly should appear as shown in the following image:


Software setup

Both modules communicate via serial interface. On GateBerry, the assigned serial port is: /dev/exp_serial

First we have to set the serial port baud rate to 57600:

stty 57600 -F /dev/exp_serial raw -echo
Then reset the module via the GateBerry digital output:
sudo ~/test/GATEBERRY_V9/GATEBERRY/set-digital-output EXP_RST 1

Working Test & Troubleshooting

Here we share the command manual to fully configure your LoRa module.

These are the basic commands we can use to check that there is communication with the LoRa module.

In this way we will see what the LoRa module responds to us, while we send commands using another terminal.

cat /dev/exp_serial

echo -e "sys get ver\r" > /dev/exp_serial

Info

After resetting the module with: sudo ~/test/GATEBERRY_V9/GATEBERRY/set-digital-output EXP_RST 1, while monitoring the serial port, the module will automatically send version and model information.

Similar to:

RN2483 1.0.5 Oct 31 2018 15:06:52

Similar to:

RN2903 1.0.5 Nov 06 2018 10:45:27

Warning

Frequency must be set according to the operating region. Before setting your LoRa module's frequency, check the authorized ISM bands in your country. Each region of the world has different allocations, so using an unauthorized frequency can cause interference with critical services (such as telecommunications, defense, or aviation) and may be subject to legal penalties.

  • Asia:
    echo -e "radio set freq 433000000\r" > /dev/exp_serial
    
  • Europe:
    echo -e "radio set freq 868000000\r" > /dev/exp_serial
    
  • America:
    echo -e "radio set freq 915000000\r" > /dev/exp_serial
    
ok
echo -e "mac pause\r" > /dev/exp_serial

Value like:

4294967245

echo -e "radio tx AA\r" > /dev/exp_serial
ok

radio_tx_ok
echo -e "radio rx 0\r" > /dev/exp_serial 
ok

radio_rx [Byte value received in hexadecimal]

Note

If a new command is issued to the LoRa module while it is in a message-reception state, the module will respond with a busy status message.

If no response is received within 15 seconds, the system will generate a radio_err notification indicating a timeout or communication failure.

In some cases the module can return this message: invalid_param

Make sure the baud rate is correct and that you end the commands with a: \r