Search
  • Medium One

Connect LoRa-Based Network to the Medium One Cloud

Updated: May 16

This tutorial uses the Feather HUZZAH ESP8266 WiFi device with Adafruit RFM9x LoRa device to form a node. That node then transmits data through a gateway that is actually another set of the Feather HUZZAH ESP8266 WiFi device and Adafruit RFM9x LORA device. The gateway then transfers the data to connect with Medium One cloud.


LoRa is a spread-spectrum modulation technique which allows sending data at extremely low data-rates to extremely long ranges for wireless, battery-operated devices. Gateways are connected to the network server via standard IP connections while end-devices use single-hop wireless communication to one or many gateways. All endpoint communication is bi-directional and supports multicast, enabling software upgrades over the air.


Here, the Adafruit RFM9x LoRa device is working from a node as well as a gateway. The node will transmit some data and the gateway will receive the data and pass that to the Medium One cloud.


In this Quick Start Guide, you will:

  1. Program the Node and Gateway

  2. View incoming data on the Medium One dashboard


Here's what you need to get started:

  1. Medium One Prototyping Sandbox Account + 2 Adafruit Feather HUZZAH ESP8266  [Buy]

  2. 2 Adafruit RFM9x LoRa devices

  3. 2 Antennas

  4. 7 multicolored pins – 2 set

  5. 2 Bread Boards

  6. MacOS or Windows OS. (Note: This tutorial is based on MacOS.)

  7. Arduino IDE [Download]

  8. 2 Micro USB cables

  9. CP2104 USB Driver [Download]

  10. 2.4GHz Wifi Internet access

  11. PuTTY [Download] (Windows only)

  12. Medium One LoRa Library [Download]


Step 1. Setup Arduino Environment

Open Arduino. A new sketch will open.

Open Preferences to make some changes in the Arduino settings.

Mac: On the taskbar, go to Arduino -> Preferences.

Windows: On the taskbar, go to File -> Preferences.

Paste http://arduino.esp8266.com/stable/package_esp8266com_index.json in the Additional Board Manager URLs section (under Settings).


Press OK.

Select Tools -> Board -> Boards Manager.

Search for esp8266 and install the board.

Go to Tools -> Board -> select Adafruit Feather Huzzah ESP8266.

Go to Sketch -> Include Library -> Manage Libraries.

Install the PubSubClient and ESP8266WiFi libraries.

Step 2. Add SX1276 Library to the Arduino Environment


From the downloaded Medium One LoRa library, copy the SX1276 library folder containing .cpp and .h file and paste it as follows:

  • For mac: Go to Documents -> Arduino -> Library and paste SX1276 library folder inside that.

  • For windows: Go to drive C -> Documents -> Arduino -> Libraries and paste SX1276 library folder inside that.


This library will be used in firmware for the LoRa gateway and node.


Step 3. Set up Feather Huzzah ESP8266 WiFi Device with Adafruit RFM9x LoRa Device

Connect Feather Huzzah ESP8266 WiFi device with Adafruit RFM9x LoRa device through multi colored pins (using multi colored pins makes the connection distinguishable), as follows:

Set up both the sets (gateway and node) as shownabove.

Connect antennas to both Adafruit RFM9x LoRa devices.

Step 4. Connect Node to Arduino Environment

First connect one of your sets of Feather Huzzah ESP8266 WiFi devices via micro USB cable to your computer.

Go to Tools -> Port.

For mac: Select dev/cu.SLAB_USBtoUART port.

For windows:

Open Device Manager -> Ports.

Remember the COM port number.

Open PuTTY

Select Connection Type as Serial. Enter the COM# port under Serial line and speed as 9600 (this is the baud rate). 

Back to Arduino, select Tools -> Port -> COM#.

Step 5. Program Node

From the downloaded Medium One LoRa library, copy the ESPLoraNode and ESPLoraGW folders and paste them as follows:


  • For mac: Go to Documents -> Arduino , and paste the firmware folder inside that.

  • For windows: Go to drive C -> Documents -> Arduino, and paste the firmware folders inside that.

Select File -> Open -> Arduino -> ESPLoraNode -> ESPLoraNode.io.

Compile the code by selecting the tick on top left corner.

You will observe the following after successful compilation.

After successful compilation, click on the upload arrow (next to the compilation tick) to upload the code.

You will see the blinking blue led and solid red led while uploading the firmware on the device. Solid red led represents the power status of the device.

After uploading is done, you can see the solid red led only on the device while it transmits the data.

After successful uploading, go to Tools -> Serial Monitor.

First you may see some garbage data, then you can see statements like those below:

Unplug the USB from the computer.


Step 6. Program Gateway

Connect your other set of Feather Huzzah ESP8266 WiFi device and Adafruit RFM9x LoRa device as gateway via micro USB cable to your computer.

Select File -> Open -> Arduino -> ESPLoraGW.io.

Change Project_MQTT_ID, USER_MQTT_ID, USER_PASSWORD and API_Key in the code. Read the MQTT Documentation to learn how to find this information on your Medium One account.

Change WIFI_SSID and WIFI_PASSWORD with your WiFi credentials.

Save the project code.

Select the device in Arudino just like you did in Step 4 for the Node.

Compile the code the same as you did in Step 5 for the Node.

You will notice the blinking blue led and solid red led while uploading the firmware on the device.

After successful compilation, upload the code.

After successful uploading, go to Tools -> Serial Monitor.


First you may observe some garbage data, then you will see statements like the following:

Unplug the USB from the computer.


Step 7. Connect node and gateway to Medium One

Connect the node to power.

Connect the gateway to power and press reset.

You can now observe the data coming from the node and the gateway on the serial monitor.

Switch to your Medium One dashboard. Under widgets, click "Real Time Events Stream. In the top right corner of the widget, select the username you input in the Gateway code in the previous step.

You will observe the connect message first.

After that you will observe the data coming from the node as well.

Congratulations! You have successfully connected the LoRa network with Medium One cloud. 


Want to learn more about what Medium One can do?

Check out our documentation and tutorials & get started on your next IoT project!

© 2018 Medium One   All Rights Reserved

4633 Old Ironsides Dr. #280, Santa Clara, CA  95054                

info@mediumone.com

|

  • YouTube - White Circle