This guide will show you step by step how to transmit LoRaWAN packets using a longfi-arduino sketch on a Heltec CubeCell Board.
Our Helium community member @suprnrdy has a store set up in the US at https://parleylabs.com/shop/ where you can find multiple variants of the CubeCell boards.
In this guide, you will learn:
How to setup your environment
How to program a basic application that will send packets over the Helium Network
Verify real-time packets sent to the Helium Console via Hotspot that's in range
For this example, you will need the following:
Micro USB Type B Cable - Example
Your board should have come with a U.FL antenna. All you have to do is attache it to the U.FL port as shown in the image at the top of the guide.
Next, lets connect our board to our computer with a USB 2.0 A-Male to Micro B cable.
Download and install the latest version of Arduino IDE for your preferred OS.
The Heltec CubeCell Board requires one Arduino board support package. Follow the instructions below to install.
To install, open your Arduino IDE:
Navigate to (File > Preferences), (Arduino > Preferences) on MacOS.
Find the section at the bottom called Additional Boards Manager URLs:
Add this URL in the text box:
Close the Preferences windows
Next, to install this board support package:
Navigate to (Tools > Boards > Boards Manager...)
Search for CubeCell Dev-boards
Select the newest version and click Install
Some versions of Heltec's runtime libraries have set a default configuration variable to a value that is incompatible with the Helium network, especially when the Heltec device is configured for the North American market. Before attempting to use the libraries it is best to verify the value of the variable.
The location of the file of interest depends on the library installation directory of the IDE you are using, Arduino IDE vs Platformio IDE, as well as the host platform, Windows vs Linux vs Mac. With the Arduino IDE location, the library version number may also be different depending on when you download the package.
For example on a Linux platform the files should be located at:
Arduino IDE library version 1.0.0:
In LoRaWan_APP.cpp look for #define LORAWAN_DEFAULT_DATARATE Depending on the version of the Heltec runtime that is installed this default may be set to DR_0, DR_3, DR_5 or some other value. Note: DR_5 is not valid for US915, the North American market.
The LORAWAN_DEFAULT_DATARATE setting is tied directly to the maximum size of the data packet you are transferring. While other runtime versions may allow programatic overide of this default, the Heltec implementation does not currently support overriding.
NOTE: If you try to transfer a packet that is larger than this setting allows, your device may successfully join the network but the data transmit will fail silently.
Data Rate (DR)
Max Application Payload
DR_5 - 7
Update the LORAWAN_DEFAULT_DATARATE as appropriate for your application needs.
The above values are valid for the US902-928MHz region(North America), the values may differ for other LoRa regions, which you can find here.
Find Directions on Heltec's website here.
If you are using the HTCC-AB02 flavor of Heltec board 1. Select Tools -> Board: ->CubeCell-Board (HTCC-AB02)
If you are using the HTCC-AB02S GPS enabled flavor of Heltec board 1. Select Tools -> Board: ->CubeCell-GPS (HTCC-AB02S)
Select Tools -> LoRaWAN Region: -> REGION_US915
The last step before we upload our sketch is to select the LoRaWAN Uplink Mode, navigate to (Tools > LoRaWAN Uplink Mode: > UNCONFIRMED).
Now that we have the required Arduino board support and library installed, lets program the board with the provided example sketch.
To create a new Arduino sketch, open your Arduino IDE, (File > New). Next, replace the template sketch with the sketch found here, copy and paste the entirety of it.
Next we'll need to fill in the AppEUI(msb), DevEUI(msb), and AppKey(msb), in the sketch, which you can find on the device details page on Console. Be sure to use the formatting buttons to match the endianess and formatting required for the sketch, shown below.
At the top of the sketch, replace the three FILL_ME_IN fields, with the matching field from Console, example shown below.
We're finally ready to upload our sketch to the board. In the Arduino IDE, click the right arrow button, or navigate to (Sketch > Upload), to build and upload your new firmware to the board. You should see something similar to the image below at the bottom of your Arduino IDE, when the upload is successful.
If you are using the HTCC-AB02S board with a sketch that is GPS enabled but find the device is unable to obtain a GPS lock you can try changing the GPS data satellite source via the GPS class Air530.setMode() API. Add the Air530.setmode() to the setup() method of your sketch.
// MODE_GPS - US,// MODE_GPS_BEIDOU - Chinese - This is the default// MODE_GPS_GLONASS - Russian// set what works best for your connectivity, for example:Air530.setmode(MODE_GPS);
When your firmware update completes, the board will reset, and begin by joining the network. Let's use the Serial Monitor in the Arduino IDE to view the output from the board. We first need to select the serial port again, but this time it will be a different port than the one we selected to communicate with the bootloader. Once again, navigate to (Tools > Port: COM#/ttyACM#), but make sure the serial device, either COM# or ttyACM#, is different! Next navigate to (Tools > Serial Monitor), you should begin to see output similar to below.
Now let's head back to Helium Console and look at our device page, you should see something similar to the screenshot below.
Congratulations! You have just transmitted data on the Helium network! The next step is to learn how to use your device data to build applications, visit our Integrations docs here.