Skip to Content

LoRa (Long Range) is a wireless communication technology designed for long-distance, low-power communication, primarily used in Internet of Things (IoT) applications. LoRa operates on unlicensed radio frequency bands and allows devices to send small amounts of data over distances of several kilometers while consuming minimal energy.

This pages focuses on plain LoRa communication, and the necessary steps to properly use it on the Arduino based PLCs. If you are looking for an example on how to use LoRaWAN, check How to work with LoRaWAN and a PLC controller.

LoRa is an optional communication. Only the M-Duino and Ardbox PLCs with the additional communication board can use it.

Hardware

The Arduino based PLCs from Industrial Shields support LoRa for Europe, Asia and North America, featuring a RFM9X5W board. The supported bands are 868MHz and 915MHz, used in Europe and America respectively.

In order to use the LoRa, the DIP switches need to be properly configured.

DIP Switches

Remember to properly power the PLC with a 12-24V power supply.

Software

The LoRa in the Arduino PLCs can be used with the "LoRa" library. To properly configure it, follow the steps:

  1. Select the corresponding LoRa board: Tools > Board > Industrial Shields AVR Boards > Ardbox/M-duino LoRa family.
  2. Select your model on Tools > Model
  3. Select the port used at Tools > Port.​
  4. Open the LoRa examples found on File > Examples > LoRa. 

There are 2 basic examples available:

  • The Receive example sets up a LoRa module for wireless communication at 868.0MHz. It initializes the module and continuously listens for incoming data packets. When a packet is received, it prints the received value to the serial monitor for debugging purposes.
  • The Send example sets up a LoRa module for wireless communication at 868.0MHz. It initializes the module and then continuously sends a counter value as a data packet every 5 seconds. After sending each packet, it increments the counter and prints debug messages to the serial monitor.
API Reference

Description:

Initializes the LoRa module.

Syntax:

LoRa.begin();

Parameters:

None

Return Values:

Returns true if the initialization was successful; otherwise, returns false.

Description:

Sets the working frequency of the LoRa module.

Syntax:

LoRa.setFrequency(frequency);

Parameters:

  • frequency: The frequency to set for the LoRa module, in MHz.

Return Values:

Returns true if the frequency was set successfully; otherwise, returns false.

Description:

Checks if there is an incoming packet available.

Syntax:

LoRa.available();

Parameters:

None.

Return Values:

Returns true if there is an incoming packet available; otherwise, returns false.

Description:

Receives a packet and stores the payload in the provided buffer.

Syntax:

LoRa.recv(buf, len);

Parameters:

  • buf: Pointer to the buffer where the payload will be stored.
  • len: Pointer to the length of the buffer. This will be updated with the actual length of the received payload.

Return Values:

Returns true if the packet was received successfully; otherwise, returns false.

Description:

Sends a packet with the provided payload.

Syntax:

LoRa.send(buf, len);

Parameters:

  • buf: Pointer to the buffer containing the payload to be sent.
  • len: Length of the payload to be sent.

Return Values:

Nothing.

Description:

Waits until the packet is completely sent.

Syntax:

LoRa.waitPacketSent();

Parameters:

None.

Return Values:

Nothing.

Rating
0 0

There are no comments for now.

to be the first to leave a comment.