Semtech, in its commitment to enhance user experience and streamline content, has successfully integrated the LoRa Developer Portal content into Semtech.com. As a result of this consolidation effort, the LoRa® Developer Portal will be discontinued on May 1st. After this date, you will be automatically redirected to Semtech.com.
For any technical support related to LoRa, please feel free to reach out to our experts here. If you have sales inquiries, please contact us here.
documentation

Stage 2: Build a Receiver Device

In this stage, you use another end device to receive messages from your broadcasting device and print the contents out to the Serial Monitor. If you did not purchase a second Arduino and shield, you can skip this step and proceed to Stage 3: Connecting the LoRa Device to a Network Server.

Assemble the Receiver LoRa® Device

  1. Place the Dragino shield next to the Arduino board, so that the both the shield and the Arduino have the same number of pins at the top as each other, and the same number of pins at the bottom.
  2. Without turning the shield, place it directly on top of the Arduino, so that the pins on the shield go into the pin headers on the Arduino. Push firmly down.
  3. Attach the antenna to the shield, screwing it in clockwise.

Configure the LoRa-enabled Receiver Device

  1. Connect the receiver Arduino to the computer’s USB port using the USB-B cable. You will see a power LED illuminate on both the Arduino and the shield.
  2. At the Arduino IDE menu bar, select Tools > Port. Select the port which has the name of the Arduino model next to it. If none of the ports are labeled, disconnect the Arduino board and reopen the menu; the entry that disappears should be your board. Reconnect the board, then select the entry that had disappeared.
  3. Start a new sketch (File > New), delete the boilerplate code, and then paste in the following code:

    #include SPI.h

    #include LoRa.h

    void setup() {

      Serial.begin(9600);

      while (!Serial);

      Serial.println(LoRa Receiver Test);

      // Replace the operating frequency of your shield here.

      // 915E6 (US902-928) / 868E6 (EU863-870) / 433E6 (EU433)

      if (!LoRa.begin(868E6)) {

        Serial.println(Starting LoRa failed!);

        while (1);

      }

    }

    Note

    The reference to the LoRa library is added using the #include LoRa.h line.

    LoRa.begin initializes the LoRa radio on the shield.

    LoRa.beginPacket, LoRa.print and LoRa.endPacket transmits the LoRa packet containing the sensor value.

  4. Update the variable in your code (shown in bold below) to match the variable representing the frequency plan for your region. For frequency plan EU863-870/EU868 this is 868E6, for US902-928/US915: 915E6, for EU433: 433E6.

      Serial.println(LoRa Receiver Test);

      // Replace the operating frequency of your shield here.

      // 915E6 (US902-928) / 868E6 (EU863-870) / 433E6 (EU433)

      if (!LoRa.begin(868E6)) {

        Serial.println(Starting LoRa failed!);

        while (1);

  5. Add the following bolded lines to the bottom of the code to parse any LoRa packets the device receives and to print the packet and and Received Signal Strength Indicator (RSSI) to the Serial Monitor:

        while (1);

      }

    }

    void loop() {

      // see if a packet was received

      int packetSize = LoRa.parsePacket();

      if (packetSize) {

     

        // if a packet size is defined, a packet was received

        Serial.println("");

        Serial.println(Received packet!);

     

        // read the packet

        String message = "";

        while (LoRa.available()) {

          message += (char)LoRa.read();

     

        }
        // print the Packet and RSSI

        Serial.println(message);

        Serial.print(RSSI: );

        Serial.println(LoRa.packetRssi());

       }

    }

    Note

    The loop continually attempts to parse any LoRa packets.

    When a message is received, the packetSize is returned and a message is printed to the Serial Monitor.

    The LoRa.available and LoRa.read methods read each character of the packet, printing them to the Serial Monitor.

    LoRa.packetRssi is used to print the RSSI to the Serial Monitor. RSSI is measured in dBm and is the received signal power in milliwatts. The closer the measurement is to 0, the better, indicating a strong signal.

  6. Verify and upload the code to the Arduino.
  7. Locate the broadcasting device you built in Stage 1.
  8. Connect the 9-volt battery to the battery clip, and the barrel jack into the barrel jack of the broadcasting device. For now, keep the broadcasting device close to the receiving device.

    Left to right, battery clip, 9-volt battery, broadcasting device

    Battery clip connected to 9-volt battery, barrel jack connected to Arduino

  9. Check the Serial Monitor. If all is well, you will see received packets being logged out every 30 seconds. This means the receiving device is receiving the packets from the broadcasting device.

    Arduino Serial Monitor showing received packet values

  10. Move the broadcasting device away from the receiving device. Return to the Serial Monitor and observe the message and the change in RSSI.
  11. See how far you can maintain a signal by moving the devices farther apart. Using a more powerful radio, a much wider range can be achieved, but even with the shield, we can observe the range is much greater than other protocols, such as Wi-Fi.
  12. To preserve battery life, unplug the battery pack from the broadcasting device when you are finished. In a real-world device, you would make use of sleep functionality to minimize battery consumption during broadcasts.

You have now successfully set up the broadcasting device and seen the LoRa packets being received by a second receiving device.

In the next stage of this tutorial you move on to reconfigure the broadcasting device to connect to a network server to demonstrate a full end-to-end solution.