How to use ESP32 with LoRaBEE as a node in LoRAWAN

How to use ESP32 with LoRaBEE as a node in LoRAWAN

What is LoraWAN?

LoRaWAN is a media access control (MAC) protocol for wide area networks. It is designed to allow low-powered devices to communicate with Internet-connected applications over long-range wireless connections.

LoRaWAN can be mapped to the second and third layers of the OSI model. It is implemented on top of LoRa or FSK modulation in industrial, scientific, and medical (ISM) radio bands. The LoRaWAN protocols are defined by the LoRa Alliance and formalized in the LoRaWAN Specification which can be downloaded on the LoRa Alliance website

Material Required is as follows:



3. Gateway

4.The Things Network Account

Circuit Diagram

Pin Details



physical pin

ESP32 Pin































Step 1: Installing ESP32 Add-on in Arduino IDE

  1. To install the ESP32 board in your Arduino IDE, follow below steps.
  2. In your Arduino IDE, go to File > Preferences.

  1. Enter into the “Additional Board Manager URLs” field as shown in the figure below. Then, click the “OK” button.

  1. Go to Tools > Board > Boards Manager.

  1. Search ESP32 and Click on the install button.

  1. The installation may take a while depending on your network performance. Once done, close the board manager

Step 2: Setup the Things Network Console Server

To setup up the TTN Console, please check the steps given in the blog: <TODO: add link to Rpi lorawan blog>

Step 3: Code and Library

 Download as Zip file of Arduino-lmic Library refer below link

Installing library

In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library.

 At the top of the drop-down list, select the option to "Add. ZIP Library''.

        Code: here we are using example sketch ttn-abp

navigate to ttn-abp example

Example sketch: File > Sketchbook > Examples > IBM LMIC framework>ttn-abp

Step 4: Pin Number Modification in Code

Change the pin numbers as shown in the code below

Step 5: Copy your Network Session Key, App Session Key and Device Address from TTN console into your code

You can find all Keys in your TTN console, go to Application > Devices > Your Devices

Make sure Network Session Key and App Session Key are copied in big-endian (MSB) format. To reverse the order, click on the reverse button to the left of the field.

Copy these details to the following lines in the code:

Step 6: Uploading code  

  1. In your Arduino IDE, go to Tools > Board>ESP32 Arduino

  1. Select the Port

  1. Click on the Upload button in the Arduino IDE
  2. After uploading code open Arduino Serial monitor

  1. After this go to the TTN console > Application > Device > Data
  2. Here uplink, downlink, and acknowledgment packets will be shown 

Step 7: Scheduling Downlink

  1. Go to TTN console > Application > Device > Overview
  2. In Downlink section enter your payload in hex format
  3. Ensure that the “Confirmed” option is selected.
  4. Click on send
  5. Once the packet is received, you can see the downlink message in your Arduino Serial monitor
  6. After the downlink packet is received, you can see acknowledgment notification in the TTN console.


After uploading code if you get the Failure error on the Serial monitor

C:\Users\ShivCapoor\Pictures\lora temp.jpg

Check your connections to make sure they are correct and not loose. Also, check if all pin numbers are correct.

Components and Supplies

    You may also like to read

    Frequently Asked Questions

    Back to blog

    Leave a comment

    Please note, comments need to be approved before they are published.

    Components and Supplies

      You may also like to read