Before we test anything with the SARA module, we must first install Industrial Shield's librpiplc library by following the instructions in this link. We recommend you clone the repository inside of your home directory, as it is where we've cloned it for this blog. When cloning the repository, replace <tagname> with v3.0.0 to select the correct librpiplc version.
After succesfully installing librpiplc, we have to copy one of the compiled files into a different folder. If you installed a librpiplc version older than v3.0.0 you can skip this part. To copy the file, use the following commands:
(Replace [PLC_Version] and [PLC_Model] with your RPIPLC's version and model, like you did when installing librpiplc)
Now we must make sure that the config.txt file is set up correctly. To do this, first open /boot/config.txt with your preferred text editor, in this case we use nano:
Use your arrow keys to reach the bottom of the file, and make sure you have these lines set up like this:
You can now close the text editor. If you opened the file using nano, you can close it by pressing Ctrl+X. If nano asks you for confirmation before closing, type Y to confirm and then press Enter to keep the same filename.
Now we can work with the SARA-R412M module. Depending on where the module is installed, the following steps will be a bit different. The module can either be installed in slot 1 or slot 2, with slot 1 being the closest to the ethernet port.
If the module is installed in the slot 1, execute file setup-gprs.sh which can be found here, using these commands:
If the module is installed in the slot 2, you will have to do some extra steps. First download the setup file with:
Now open the setup-gprs.sh and replace all occurences of ttySC0 to ttySC1 and EXP1_RST to EXP1_RST_2. You can use nano:
To replace all occurences do this:
1.Press the Alt + R key combination to enter the find and replace mode.
2. Write ttySC0 and press enter.
3. Write ttySC1 and press enter.
4. Press A to replace all occurences.
Repeat steps 1 to 4 to replace EXP1_RST with EXP2_RST, or replace it with EXP1_RST_2 if you are using a librpiplc version older than v3.0.0.
Now we can give proper permissions to the file and execute it:
If you followed the steps for your corresponding slot, the executed script will now be asking for APN credentials and AT (Radio Access Technology): LTE Cat M1(4G), NB-IoT (Narrow Band) or GPRS/eGPRS. It will also create a service called pppd located in /lib/systemd/system/pppd.service, which executes a python file created in /usr/src/network-setup.py every time the Raspberry PLC boots.
About 50-120 seconds after executing setup-gprs.sh, interface ppp0 should be created. The process can be followed with:
or
You can check that the interface has been created with:
To ensure everything has gone flawless, you can ping to 8.8.8.8 like so:
To stop and disable the service, use the commands:
Finally, try to execute the created script newtork-setup.py with the desired RAT:
(replace [RAT] with either gprs, nb-iot or lte-m)
SARA-R412M on Raspberry Pi