Introduction
The integration of 4G communication into ESP32-based PLCs opens up endless possibilities for IoT and industrial automation. In a previous blog, "How to Use 4G with the ESP32 PLC", we explained the initial setup for enabling 4G on the ESP32 PLC. This includes preparing the SIM card, configuring the APN, and initializing the NB (Narrowband IoT) library. If you're new to this process, we recommend starting with that post before diving into this guide.
In this article, we will focus on practical applications: sending SMS messages and Telegram notifications directly from the ESP32 PLC. The SMS example discussed here is readily available in the Industrial Shields library under File -> Examples -> Examples for 14 IOs PLC Family -> NB -> SendSMS.
Sending SMS Messages with an ESP32 PLC 14
The ability to send SMS messages is a valuable feature for industrial automation, whether for alarms, notifications, or remote commands. The following example demonstrates how to send SMS messages from the ESP32 PLC 14 using the NB library.
Code Example: SMS Sending
This example is included in the Industrial Shields library under File -> Examples -> Examples for 14 IOs PLC Family -> NB -> SendSMS. Here's the complete code:
arduino_secrets.h (dependency):
SMS Sending Example Code:
With this code, you can easily send SMS messages by entering the recipient's phone number and the desired message via the Serial Monitor.
You can download the example here:
SendSMS
Sending Telegram Messages with Call Me Bot
Although the library does not currently include an example for sending Telegram messages, you can implement this functionality using the Call Me Bot service. Call Me Bot allows you to send Telegram messages without dealing with the complexity of the Telegram API. Before using this example, you must grant permissions to the bot through this authentication page.
Code Example: Telegram Sending
Below is the code for sending Telegram messages using the Call Me Bot service:
arduino_secrets.h (dependency):
Telegram Sending Example Code:
With this code, you can easily send Telegram messages by entering the desired message via the Serial Monitor.
You can download the example here:
SendTelegram
Conclusion
The ESP32 PLC 14 with 4G connectivity proves to be a powerful tool for IoT and industrial automation. Using the built-in library, sending SMS messages is straightforward with the provided SendSMS example. Additionally, with a little customization, you can send Telegram notifications via the Call Me Bot service.
For those looking to explore more about the initial 4G setup, visit our previous guide: "How to Use 4G with the ESP32 PLC".

Sending Messages via SMS or Telegram Using an ESP32 PLC 14 with Integrated 4G