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

Building a LoRa® Device End-to-End with Arduino

In this guide we will walk you through building your own LoRa®-enabled device from end-to-end using an Arduino board and Dragino shield. We are using a moisture sensor in this tutorial, but there are many potential uses for LoRa devices; alternative sensors for your device could include temperature, humidity, motion, air quality, light, accelerometers, and more.

What are LoRa and LoRaWAN®?

LoRa, is an RF modulation technique which allows for extremely low powered wireless communication systems. Since the frequencies used are orders of magnitude smaller than other common wireless communication methods, such as Wi-Fi, the range of transmission is much larger; up to 10 miles or more in rural areas with a clear line of sight. Coupling this long-range transmission with ultra-low power requirements makes LoRa an ideal choice for battery-powered Internet of Things (IoT) devices with applications that need to communicate with widely-distributed systems.

LoRaWAN® is a standard based on an open-source specification. In short, LoRaWAN is an example of a low power wide area network that is based on LoRa radio modulation. This standard allows device built with LoRa chipsets to wirelessly connect to the internet and helps ensure compatibility of devices among manufacturers around the world. It is even possible, as we will outline in this guide, to build your own custom LoRa -enabled end device that can transmit information to other LoRa devices and the internet via a LoRaWAN network server.

LoRaWAN network high level architecture.

The architecture of a LoRaWAN network is shown above. The end devices transmit their payloads in what are known as an uplink messages, to be picked up by a LoRaWAN gateway. A key aspect of LoRaWAN is that a device is not associated with a single gateway. Its payloads may be picked up by any number of LoRaWAN gateways within the device’s range. In theory an entire city could be covered by a just a handful of gateways and messages from devices belonging to any user could be detected anywhere in the city.

The gateway then passes messages to its associated network server, usually carried out over Wi-Fi or Ethernet. However, cellular and satellite gateways are available to enable very remote solutions without relying on an internet connection. There are various options for network servers, described in this guide. Following the instructions in this article you will use the Semtech Network Server, which allows you develop and prototype with up to ten devices and three gateways.

The network server receives the messages from the gateway and checks whether the device is registered on its network; the network server also carries out deduping, since the message may be received and uploaded by multiple gateways. The message is then forwarded to the application server on which the device is registered.

Communication is also possible in the other direction, where a message is sent as a downlink to the device. The downlink message is sent from the application server to the network server. The network server then queues the downlink, and when the device next sends an uplink message, the network server will pass the downlink message to the nearest gateway which received the uplink. The gateway then broadcasts the downlink message for the device to receive.

Common uses for a downlink message are to update a device’s broadcast settings, for example, to trigger updates more or less frequently, or trigger some other action, such as causing a device to open, closing a water valve, or turning an A/C unit on or off.

For a detailed look at LoRa and LoRaWAN, including RF modulation, more information on architecture including the technical detail on how devices join the network using a Join Server, and different classes of devices, refer to our technical paper on 'What are LoRa and LoRaWAN?'

What Will You Build?

This guide is split into three stages:

  1. You will build a LoRa device to measure and communicate the moisture level in soil. This is a great example of the power of LoRa communication, since detecting soil moisture levels is key to many agricultural processes and is often challenging, given the wide geographical areas where wireless monitoring is needed. You will set up a detector device which will connect to a moisture sensor and then send a LoRa payload containing the moisture level in the soil at regular intervals.
  2. You will build a LoRa receiver device which will receive the payload and log the moisture level to the console.

    Schematic of the system for Stages 1 and 2.

    The moisture level is read by the LoRa broadcast device which sends a message. The receiver device receives the message, logging it to the Serial Monitor in the Arduino IDE.

  3. You will then use the LoRaWAN specification and connect your moisture detection device to the Semtech Network Server, where we will be able to see the moisture level of the soil.

    Schematic of the system for stage 3.

    The moisture level is read by the LoRa broadcast device which broadcasts a LoRa uplink. The uplink is received by the LoRaWAN gateway. The gateway sends the message to the Semtech Network Server. The device uplink is then visible in the Semtech Network Server.

If you are limited by time, budget, or hardware availability, it is possible to complete Stage 1 and then either:

Objectives

By the end of this tutorial you will know how to:

  • Build a LoRa device using an Arduino Uno and Dragino's Arduino Shield featuring LoRa.
  • Connect a moisture sensor to the device.
  • Configure the device to take moisture readings at a regular interval.
  • Build a LoRa device to receive and log messages.
  • Connect a LoRa device to the Semtech Network Server via a LoRaWAN gateway.