LoRa clicks with ESP32 PLC
The ESP32 PLC features two communication boards which are optimized to support LoRa clicks, facilitating robust long-range communication across Europe, Asia, and the USA. This setup is ideal for those looking to understand how to use LoRa technology effectively in various international contexts.
There can be used two modules:
- LR Click: Features the RN2483 module which operates at a frequency of 433MHz or 868MHz.
- LR 2 click: Features the RN2903 module which operates at a frequency of 915MHz.
The following table shows the regions supported for each module according to its operational frequencies values. For more information about the frequency plans by country of LoRaWAN check this page.
Module | Frequency (MHz) | Region |
RN2483 | 433 | Europe |
RN2483 | 868 | Asia |
RN2903 | 915 | North America |
Optimizing LoRa connectivity: Essential Hardware setup for ESP32 PLC
To establish effective LoRa communication using the ESP32 PLC, the hardware setup varies slightly depending on whether you're setting up a single device or configuring multiple devices to communicate with each other. Here are the essential components and steps:
- One ESP32 PLC in case of already having another device to communicate with. Otherwise, you can have two ESP32 PLCs to communicate between each other.
- The LoRa click according to your region connected to one of the communication boards of the ESP32 PLC.
- An antenna connected to the LoRa click. Note that in case of the LR click, it has two antenna connectors: RFL for 433MHz and RFH for 868MHz.
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.
Essential Software and test codes for ESP32 PLC
Here are the test codes for the LoRa on the ESP32 PLC depending on the expansor being used for the LoRa click:
This codes uses two libraries:
- The SC16IS752 library, which is utilized to create an object used as a serial port to communicate with the LoRa 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 LoRa module
- A message received from the LoRa module, which is then printed in the serial port.
Step-by-step guide to testing LoRa communication with ESP32 PLC
To test the LoRa communication between two devices follow this steps:
- Open the port on both devices with the same baudrate (in the code it is initialized at 57600).
- Set the frequency according to your location writing radio set freq <frequency>. For instance, for Europe it would be: radio set freq 868000000.
- Write the string mac pause on both devices. The serial monitor should display a number.
- On one device, write radio rx 0. For 15 seconds, this device will be listening for possible incoming data.
- On the other one, write radio tx AB. This one will send the message AB.
- On the first device, the string AB should be displayed on the screen.
For all the previous 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".
For more information about all the possible commands on the RN2483 and RN2903 modules check:
Mastering LoRa Connectivity with ESP32 PLC
Learning how to use LoRa with ESP32 PLC is key for maximizing long-range connectivity. It is crucial to select the appropriate module—RN2483 or RN2903—based on the operating region. Proper hardware and software configuration ensures effective communication. Follow our streamlined guide to easily set up and test LoRa communication between ESP32 PLC devices, ensuring efficient implementation in any industrial setting.
How to use LoRa with ESP32 PLC Family