Helium Network is one of the most popular networks on the planet, and that’s why it is called The People’s Network. It consists of a community network that can be used by anyone, enterprises or people, that want to connect their IoT end nodes. If you are interested in the crypto world, you know that you can install a Helium hotspot and gain money mining its coin HNT. But, did you know that you can use this network similar to how you use the cellular network? You're about to find out!
Helium is a project that uses the LoRaWAN® protocol to connect IoT devices around the world. In this network, everyone who has coverage can use it to send data to the cloud and develop an application that can solve a lot of problems in a specific environment.
This project is doing it really well. They are focused on many IoT industries and its popularity in the cryptocurrency community has helped to create a network in many places of the world. There is even a city in California that is working to be a smart city connected by Helium.
In most of the main cities of the world, there are a lot of Helium Hotspots installed. The bad news is that there are not enough applications developed because this is a relatively new technology. On the other hand, there is a need to create more of these applications is increasing every day and you can develop them easily using WisBlock, so let’s learn how to do it!
What do you need?Or you can buy the items separately:
These items are also available in:
Step by step- Some non-Boring Technical details
- Check coverage
- Configure your Network server
- Develop your application using WisBlock
- Connect your data to an IoT platform (Ubidots)
- What’s Next?
Before we start with the hands-on project, we need to clarify why all the steps are needed. Take a look at Figure 1. The end node is in charge of converting the data from the analog world to the digital world and transmitting it to the gateways. When you are working with Helium Network, you can use the coverage that you have at the site where you need to implement your project. No need for additional hardware because you'll be using someone else's hardware.
The data arrives at these gateways/hotspots and is transmitted to a network server, it depends on the network you are using, in this particular case, Helium provides it. you can send this data to various IoT platforms for visualizations, automatic notifications and analytics., you can select between Ubidots, Qubitro, DataCake, AWS, etc.
Check CoverageTo check if you have coverage, go to https://explorer.helium.com/, and search for your location. If you are in a major city in your country you will have Helium coverage. I am in Bogotá Colombia, and it seems that I have coverage in my area. So, let's try it!
To get started with the Helium network, go to https://console.helium.com/ and sign up if you don't have an account. In the registration process, you will need to add a new organization. Don't worry, you can put any name and continue with the process.
The main page of the Helium console looks like the one shown in Figure 3.
Before adding a new device, let's talk about something important. When you send data from an end device to the cloud using the Helium Network, you have to pay for it. The official currency within the network is not HNT, but the data sent must be paid with DC (Data Credits). You will receive 250 DC to start using the Helium Network. You can purchase more DCs based on your application need. The value of each DC is defined as:
1DC = 24Bytes = USD$0.00001
With this detail in mind, continue adding a new device. To do this, go to Devices and click the Add New Device icon.
Put any name you want in the Name field and click Save Device. The Dev EUI, App EUI, and App Key variables will be generated automatically, so don't change them.
With this, a new device is created. You can check the data in a dashboard when you click the Device Name.
Let's develop a basic project: the reading of atmospheric variables. That is temperature, humidity, pressure and gas resistance.
The first step is to configure the Hardware. For this, you need the following materials: RAK4631, RAK19007 and RAK1906, as you can see in Figure 7.
The connection of the sensor is really simple, Plug it into any of the sensor slots, these are, Slot A, B, C and D, and secure it with the screws. As seen in Figure 8.
Finally, connect the LoRa antenna to the RAK4631 core.
At last, WisBlock is ready to use.
Programming
The programming stage is really simple, you can use the code available on our official GitHub site. Just copy and paste it into your Arduino IDE and that's it.
NOTE: If you haven't used Arduino or WisBlock before this tutorial, we recommend you visit our introductory tutorial here.
Some clarifications:
If this is your first time working with WisBlock, you will need to install two libraries, just click on the link in the first lines of code, and click on install.
#include <Arduino.h>
#include <LoRaWan-RAK4630.h> // Click to install library: http://librarymanager/ALL#SX126x-Arduino
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME680.h> // Click to install library: http://librarymanager/All#Adafruit_BME680
Adafruit_BME680 bme;
This code is useful if you are working in OTAA or ABP activation modes. Helium uses OTAA as you can see in Figure 6, so in the LoRaWAN® parameter settings lines, leave doOTAA as default.
Most of the parameters are ready to go, so there is no need to change them. Except the parameters related to your region. In that case, you need to change the region based on where your project will be deployed, my region uses the AU915 standard, but you can check your region on Helium official site.
bool doOTAA = true; // OTAA is used by default.
#define SCHED_MAX_EVENT_DATA_SIZE APP_TIMER_SCHED_EVENT_DATA_SIZE /**< Maximum size of scheduler events. */
#define SCHED_QUEUE_SIZE 60 /**< Maximum number of events in the scheduler queue. */
#define LORAWAN_DATERATE DR_3 /*LoRaMac datarates definition, from DR_0 to DR_5*/
#define LORAWAN_TX_POWER TX_POWER_0 /*LoRaMac tx power definition, from TX_POWER_0 to TX_POWER_15*/
#define JOINREQ_NBTRIALS 5 /**< Number of trials for the join request. */
DeviceClass_t g_CurrentClass = CLASS_A; /* class definition*/
LoRaMacRegion_t g_CurrentRegion = LORAMAC_REGION_AU915; /* Region:AU915*/
lmh_confirm g_CurrentConfirm = LMH_CONFIRMED_MSG; /* confirm/unconfirm packet definition*/
uint8_t gAppPort = LORAWAN_APP_PORT; /* data port*/
We send data based on events, using trigger functions, you can modify them as you need.
// Foward declaration
static void lorawan_has_joined_handler(void);
void lorawan_join_fail(void);
static void lorawan_rx_handler(lmh_app_data_t *app_data);
static void lorawan_confirm_class_handler(DeviceClass_t Class);
static void send_lora_frame(void);
Change the OTAA keys for those obtained on the Helium platform. The sequence is the same as in the Helium console, just separate them into pairs and add 0x
before each one so the program can understand it as a valid format.
//OTAA keys !!!! KEYS ARE MSB !!!!
uint8_t nodeDeviceEUI[8] = {0x60, 0x81, 0xF9, 0x8B, 0x44, 0x71, 0x68, 0x29};
uint8_t nodeAppEUI[8] = {0x60, 0x81, 0xF9, 0x62, 0xB9, 0x08, 0x55, 0x1E};
uint8_t nodeAppKey[16] = {0x1B, 0x88, 0x59, 0x08, 0x47, 0x80, 0x6A, 0xF5, 0xB8, 0x64, 0xA9, 0xB7, 0xFF, 0x45, 0xB3, 0x5F};
The function loop will be empty because, as I told you before, functions work with events.
void loop()
{
}
In the void bme680_get()
function, the data from the sensor is read, and the payload is also created by multiplying the measurement obtained by 100 and doing a bit shifting. This information will be needed when you perform the integration between Helium and Ubidots.
Now you’re ready to Verify and Upload your program.
If everything works, you are already sending data to Helium.
In Serial Monitor, you will see something like the screenshot shown in Figure 12. WisBlock is connected to LoRaWAN® and reads and sends data every 20 seconds. We recommend that if you want to save the credits that Helium gives you, do not put a short sending interval.
In the Helium Console, you can see the data coming in, but you can see that all the data is displayed in red. It means you don't have an integration. To be more clear: your data arrives at the Helium LNS (LoRaWAN® network server), but it cannot store it. This data will be stored only for 300 seconds, 5 minutes, and then it will disappear. This is why an IoT platform is needed.
There are many IoT platforms or Application Servers, such as Ubidots, Qubitro, Datacake, AWS or MS Azure, you can even set up your own application server. But in this case, we will use Ubidots.
Connect your data to an IoT platform (Ubidots)In this part, you will need a Ubidots account. You have two options to get started, the first is to create a free professional account for one month while you test the platform. The second option is to create a free account limited to educational or research projects, called Ubidots STEM. For this tutorial, we will use the second one.
You can create a new account simply by registering with your email. When you first access Ubidots, you don't have anything configured. So the first step is to create a device. Click Devices and select Plugins.
Select Create Plugin.
In the dialog window, select the option Helium.
Press the blue icon to continue.
In Ubidots STEM you only have the Default Token option, when you are using the professional version you can create more tokens. Select the option Default Token, and click the blue icon to continue.
Add a name and description and finally click the green icon.
Now, you have a new device in Ubidots, you can check it in the next window and with a pop-up indicating that you have created a new plugin.
Before leaving Ubidots, go to your profile icon and select API Credentials:
Click on the Default Token and copy it. It will be useful later
The next step is to create a connection with Helium. Go to the Helium Console and select Integrations.
Click on Add New Integration.
Select Ubidots.
Click on Add Integration
Paste the token that you copied in the previous steps. And Click on Get Webhook URL.
You will see a confirmation message with a link from Ubidots where Helium will redirect the data. Click Continue.
Assign a name for the Integration and Click on Add Integration.
With that, you have already created a new integration between Helium and Ubidots, as you can see in Figure 28.
The next step is to create a function.
NOTE: A function is used to convert data from one format to another. When we programmed our WisBlock, the data was in hexadecimal format, and it will arrive at the web server using this format. But to send this data to an IoT platform, we need to decode this information into a language that the server can understand, such as a JSON format.
To create a function, Click on Add New Function.
Select Custom Function
Give it a name, and then copy and paste the following code into the Custom Script space, as seen in Figure 31.
function Decoder(bytes, port) {
var decoded = {};
decoded.temperature = (bytes[1] << 8 | (bytes[2])) / 100;
decoded.humidity = (bytes[3] << 8 | (bytes[4])) / 100;
decoded.pressure = (bytes[8] | (bytes[7] << 8) | (bytes[6] << 16) | (bytes[5] << 24)) / 100;
decoded.gas = bytes[12] | (bytes[11] << 8) | (bytes[10] << 16) | (bytes[9] << 24);
return decoded;
}
The decoder function is useful if you used the Arduino code from the previous section to create the payload, and it only works if you are using the RAK1906. In case of working with another sensor, or using another way to create the payload, you will need to modify the code. But this is not a big deal, it is written in JavaScript and you have a repository for many payloads created by the Helium community.
You can use the Script validator to verify the operation of your code, as seen in Figure 32.
If you see that everything works, click Save Function.
Now that you've created your device, integration, and decoder function, it's time to put them all together. Go to Flows and click the + icon to add a new node.
Click Devices to add the device, click Functions to add the function created earlier, and click Integrations to add the Ubidots Integration. Simply drag and drop to position it on the screen.
Connect the blocks by clicking on the point of the first box and pull the line to the other block, it's very easy.
And that’s it! you already have your connection ready to work! Just connect your WisBlock and take a look!
Don't worry if your first few packets show orange, it might take a moment to make a full connection.
Now go to the Ubidots platform. Click Devices > Devices and you will find a connected device. Click on it to see the data.
You will find many additional data different from the Gas, Temperature and Humidity data that we configured before, such as the RSSI, port, among others.
To view this data in a more ordered way, go to Data > Dashboard and click Add New Widget.
You will find many Widgets to display your information. I will add a Gauge to show the humidity data.
Click Add Variables.
Click on the device to display the variables and then select the variable you want to display. In this case, humidity, and click Select.
You can change appearance and configuration details. Set the data you want, and click Save.
And now you have your data in a dashboard in an organized way.
You can follow the steps above to add the other variables to your dashboard.
Congratulations!! You did it!! You can explore the tools that Ubidots has to display and process data and continue learning everything you need about the IoT and Helium platforms.
What’s next?Now, you have all the basics to work with IoT using LoRaWAN®. You can now create a P2P communication, you can use RUI3, you can use WiFi and cellular network, and now you are using Helium Network. Therefore, we have planned to create more tutorials with fun developments using our sensors and interfaces or to create professional and complete applications. Tell us, what would you like to see on this platform? how can we help you? Leave us your comments and don't forget to follow us on our official Hackster profile. See you in the next tutorial!
Comments