GPRS and Narrowband with ESP32 PLC Family

Basic tutorial on the usage of LTE IoT clicks with ESP32 PLC family
May 23, 2024 by
GPRS and Narrowband with ESP32 PLC Family
Boot & Work Corp. S.L., Martí Schnabel

Integration of SARA-R4 Modules with ESP32 PLC for LTE IoT and NB-IoT

The integration of SARA-R4 modules with the ESP32 PLC family opens new possibilities in the realm of the Internet of Things (IoT). The SARA-R4 modules, specifically designed to support LTE IoT, provide advanced communication capabilities for applications requiring reliable and low-power connections. The ESP32 PLC family, with its versatility and power, becomes the ideal platform to implement these modules and fully leverage the LTE Cat M1, NB-IoT, and EGPRS technologies.


The ESP32 features two communication boards that support LTE IoT modules:


  • LTE IoT 6 Click: This board features the SARA-R412M module which supports LTE Cat M1, LTE Cat NB1 and EGPRS modes.
  • LTE IoT 7 Click: This board features the SARA-R422M8S module, which supports LTE-M, NB-IoT and EGPRS modes.

What are the Hardware requirements to integrate LTE Io​T modules with the ESP32 PLC family?

To get the most out of integrating LTE IoT modules with the ESP32 PLC family, it is crucial to have the right hardware. In this section, we detail the necessary components and specific configurations that will ensure efficient and reliable communication. The hardware requirements are:

  • A Raspberry PLC from the ESP32 PLC family.
  • An LTE IoT connected to one of the communication boards of the ESP32 PLC.
  • A SIM card and an antenna for the LTE IoT click.

In case of using the Expansor 2 of the ESP32 PLC (The one closer to the ethernet port), the switches 2 and 4 of the communication board must be ON. Check ESP32 PLC Technical Features for more information.

Software Guide and Test Code for SARA-R4 Modules on ESP32 PLC

To ensure successful implementation of the SARA-R4 modules with the ESP32 PLC, it is essential to have the correct test codes for the specific expansor being used. Below, we provide detailed test codes tailored for each expansor, which facilitate the connection and communication between the LTE IoT click and the ESP32 PLC. These codes are crucial for initializing the modules and verifying their functionality, ensuring that your setup works seamlessly.


Test code for expansor 1


Test code for expansor 2

This codes uses two libraries:

  • The SC16IS752 library, which is utilized to create an object used as a serial port to communicate with the SARA-R4 module.
  • The Adafruit_MCP23008 library, used to access some pins of the expansion board, and the auxiliary header.

After all the initializations in the setup() function, the program enters the loop() function where awaits either:

  • A command from the serial port to transmit it to the SARA-R4 module
  • A message received from the SARA-R4 module, which is then printed in the serial port.

What do you need to perform a basic test?

To perform a basic test on the module communication, just write AT on the Serial Port of the Arduino IDE. The response from the Serial Port should be OK if everything went fine.

For all the sent commands it is needed to end them with "\r\n". You can avoid writing it on every command by setting the Serial Port of the Arduino IDE the option "both NL & CR".

The AT command used for testing is just the simplest one between all the SARA-R4 possible commands. You can check them on SARA-R4 AT Commands Manual.


GPRS & Narrowband with Rapsberry PLC


Efficient integration of LTE IoT and NB-IoT with ESP32 PLC: Conclusions and Benefits


The integration of LTE IoT and NB-IoT technologies with the ESP32 PLC family provides a powerful and versatile solution for IoT applications requiring efficient and reliable communications. Utilizing these advanced technologies, robust IoT networks can be implemented with low power consumption and wide coverage. With the appropriate hardware and software requirements, including code examples and essential libraries, this guide provides the necessary tools to maximize the potential of your IoT solutions. Conducting basic communication tests ensures the proper functioning of the LTE IoT modules, facilitating their implementation in real projects and guaranteeing high-quality connectivity and reliable performance.


​Search in our Blog

GPRS and Narrowband with ESP32 PLC Family
Boot & Work Corp. S.L., Martí Schnabel May 23, 2024
Share this post

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>