null

Dragino Water Leak Sensor Helium and Tago Tutorial

Sidebar

Dragino Water Leak Sensor Helium and Tago Tutorial

Posted by Parley Labs ,Nov 21st 2022
Dragino Water Leak Sensor Helium and Tago Tutorial

Adding Water Leak Sensor (LWL02) to the Helium Network

1. Register for a Helium Console Account

We will be using the Helium Network as our LoRaWAN network provider because of their large network coverage and low fee. You can check out more about them here.

In order to receive data from the Helium LoRaWAN network, we will create a Helium Console account here. Once you created the account and logged in, you will see the following page:

https://hackster.imgix.net/uploads/attachments/1445284/capture_34sbS0MB4j.JPG?auto=compress%2Cformat&w=740&h=555&fit=max

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-6895116c-8e39-4048-ba56-c6e0d4effb53' })

2. Adding Data Credit

Every new Helium Console account comes with 10,000 data credit which will provide about 2 months of data. However, if you want to add more, hover over the DC balance on the top right of your screen and click on "DC Balance" which will take you to the following screen. The minimum purchase with credit card is $10 which will give you plenty of data credit to use with the sensor.

https://hackster.imgix.net/uploads/attachments/1445290/capture_HdUXRnqYnI.JPG?auto=compress%2Cformat&w=740&h=555&fit=max

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-e1b47db4-bd24-42fd-9117-f4756ef9f188' })

3. Adding Water Leak Sensor to the Helium Network

Select "Devices" on the left column, then "Add New Device". Enter a name for your device and populate the Dev EUI, APP EUI and App Key. Once completed, proceed to "Save Device".

https://hackster.imgix.net/uploads/attachments/1445305/capture_oZyK7kbyMe.JPG?auto=compress%2Cformat&w=740&h=555&fit=max

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-bb6f4f30-1342-4dcd-bdad-2000677c058e' })

4. Adding Payload Decoder

Select "Functions" on the left column, then "Add New Function". Set all fields the same as seen below.

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-53adbc17-aa5a-4470-863e-898816762b22' })

Copy and paste the following function into the custom script box.

function Decoder(bytes, port) {

// Decode an uplink message from a buffer

// (array) of bytes to an object of fields.

var value = (bytes[0] << 8 | bytes[1]) & 0x3FFF;

var bat = value / 1000;//Battery,units:V

var door_open_status = bytes[0] & 0x80 ? 1 : 0;//1:open,0:close

var water_leak_status = bytes[0] & 0x40 ? 1 : 0;

var mod = bytes[2];

var alarm = bytes[9] & 0x01;

if (mod == 1) {

var open_times = bytes[3] << 16 | bytes[4] << 8 | bytes[5];

var open_duration = bytes[6] << 16 | bytes[7] << 8 | bytes[8];//units:min

if (bytes.length == 10 && 0x07 > bytes[0] < 0x0f)

return {

BAT_V: bat,

MOD: mod,

DOOR_OPEN_STATUS: door_open_status,

DOOR_OPEN_TIMES: open_times,

LAST_DOOR_OPEN_DURATION: open_duration,

ALARM: alarm

};

}

else if (mod == 2) {

var leak_times = bytes[3] << 16 | bytes[4] << 8 | bytes[5];

var leak_duration = bytes[6] << 16 | bytes[7] << 8 | bytes[8];//units:min

if (bytes.length == 10 && 0x07 > bytes[0] < 0x0f)

return {

BAT_V: bat,

MOD: mod,

WATER_LEAK_STATUS: water_leak_status,

WATER_LEAK_TIMES: leak_times,

LAST_WATER_LEAK_DURATION: leak_duration

};

}

else if (mod == 3)

if (bytes.length == 10 && 0x07 > bytes[0] < 0x0f) {

return {

BAT_V: bat,

MOD: mod,

DOOR_OPEN_STATUS: door_open_status,

WATER_LEAK_STATUS: water_leak_status,

ALARM: alarm

};

}

else {

return {

BAT_V: bat,

MOD: mod,

};

}

}

 

Setting Up Tago.IO for Data Visualization

1. Register for a Tago.IO Account

In this guide, we will use Tago.IO to display all data coming from Helium. Register for a free account with Tago and once you are logged in, you will see the following screen.

https://hackster.imgix.net/uploads/attachments/1482115/capture_483Ocx0O1k.JPG?auto=compress%2Cformat&w=740&h=555&fit=max

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-463df400-3eb7-409d-b894-593519774609' })

2. Add New Device to Tago

Select "Devices" on the top left corner, then select "Add Device".

https://hackster.imgix.net/uploads/attachments/1482116/image_M5HgVeExpw.png?auto=compress%2Cformat&w=740&h=555&fit=max

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-7d1d8c5c-2163-4f9d-af08-4a39d12fe9e3' })

Select "LoRaWAN Helium", then select "Custom Helium" as shown below.

https://hackster.imgix.net/uploads/attachments/1482117/image_8EFwscvKhi.png?auto=compress%2Cformat&w=740&h=555&fit=max

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-461fda69-76c1-484c-8677-c864a323b0d3' })

Once you selected "Custom Helium", the following screen will appear. Give your water leak sensor a name and set the "Data Storage Type" to "Device Data Optimized". For data retention, set your desirable timeframe that you want Tago to retain data. In this example, we will set it to one month. Fill in the EUI field with the Dev EUI. Once done, press "Create My Device",

https://hackster.imgix.net/uploads/attachments/1482118/capture_z9iIFMJprB.JPG?auto=compress%2Cformat&w=740&h=555&fit=max

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-84b50bf6-c8ce-43c8-bf82-3714078a28f4' })

3. Add Water Leak Sensors Dashboard to Tago

Use the following link to automatically install the water leak sensor dashboard to your Tago account. Select "Install Template" when prompted as shown below.

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-b5d9a530-7e1f-4634-a6c4-c7bb934765c8' })

Select the device name that you added earlier from the drop-down menu. Select "Confirm associations" once you are done.

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-dca8bab7-a579-45cc-8de9-cd5f90f27360' })

4. Adding Tago Authorization to Helium Console

At this point, you will see the newly created dashboard on your homepage. However, the dashboard should be empty since you have not gotten any data yet due to the fact that we have not link the Tago account to our Helium Console account. To do this, select your profile name on the top right corner, then select "My account"

https://hackster.imgix.net/uploads/attachments/1482121/image_OG9qxl90y7.png?auto=compress%2Cformat&w=740&h=555&fit=max

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-c6a01972-8b18-4a04-b6b2-8c768a4d2cef' })

Select your profile name on the left, then click on "Token", set permission to "full", and to never expire, then "Generate Token". In order to copy your token, click on the copy symbol as show below.

https://hackster.imgix.net/uploads/attachments/1482122/image_TQpR2L6sTa.png?auto=compress%2Cformat&w=740&h=555&fit=max

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-f5eed53c-f819-4096-92be-77a3a73a242f' })

Now log back into your Helium Console account, click on "Integrations" on the left column then add TagoIO.

https://hackster.imgix.net/uploads/attachments/1482123/image_3fgYWks6Qn.png?auto=compress%2Cformat&w=740&h=555&fit=max

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-fffda75b-6daf-486f-bc2d-06e47cfb4bc2' })

Paste your newly created Tago token in the Step 2 box below.

https://hackster.imgix.net/uploads/attachments/1482124/capture_x6A9aMjQJh.JPG?auto=compress%2Cformat&w=740&h=555&fit=max

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-49035543-0c7c-445f-bc19-7a1a9cc016f8' })

5. Flow Diagram

Finally, we are on the last step. This step will tie everything that we did previously together and allow you to see all data output on Tago.IO.

While in Helium Console, click on "Flows", then add the following items and connect them together. In our case, we will add the water leak sensor, water leak decoder function and the TagoIO authorization.

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-e668ceba-07bc-46a9-ad44-c5e301c07b92' })

TagoIO Dashboard Visualization

Congratulation, you are now done! Go back to your Tago dashboard and see all the data fields getting populated as more data come through!

window.SHOGUN_IMAGE_ELEMENTS = window.SHOGUN_IMAGE_ELEMENTS || new Array(); window.SHOGUN_IMAGE_ELEMENTS.push({ hoverImage: '', uuid: 's-34586aa3-f9d1-4e14-b72b-f90115a6c9ea' })

window.__shgProductInits = window.__shgProductInits || new Array(); window.__shgProductCallbacks = window.__shgProductCallbacks || {}; window.__shgProductComponent = window.__shgProductComponent || {}; window.__shgProductCallbacks["s-be30fe98-ceea-4055-95cd-315fc86057dd"] = new Array();

window.__shgProductCallbacks["s-be30fe98-ceea-4055-95cd-315fc86057dd"].push({ cb: "image", data: { uuid: "s-02b00a3f-26e2-4d65-b540-126e645329ce", imageOffsetTop: 9542, LAZY_LOAD_OFFSET_TOP: 750, LAZY_LOAD_ENABLED: true } });

window.__shgProductCallbacks["s-be30fe98-ceea-4055-95cd-315fc86057dd"].push({ cb: "title", data: { uuid: "s-4d7754b3-b455-41f0-abac-98c8cb1623d7" } });

Sold out window.__shgProductCallbacks["s-be30fe98-ceea-4055-95cd-315fc86057dd"].push({ cb: "price", data: { uuid: "s-dbbe03be-8dc6-4730-b227-5f6ac9c80b26", hasComparePrice: false } });

The Dragino LWL02 is a LoRaWAN Water Sensor. When there is water between the two metal probes, LWL02 indicates a water leak event and uplink to IoT server via LoRaWAN network.

window.__shgProductCallbacks["s-be30fe98-ceea-4055-95cd-315fc86057dd"].push({ cb: "addToCart", data: { uuid: "s-aa391b97-b1fb-4e1e-a2e8-7f11eeeaad18", siteId: "01077ce8-4669-41fa-9572-866c0017717c", pageId: "637534ae68760900d6cec34a", pageVersionId: "637bd799e6d64d0112d1abc1", parentGroupUuid: "s-be30fe98-ceea-4055-95cd-315fc86057dd", action: "/cart.php", behavior: "go", buttonText: "ADD TO CART", successText: "Added to your cart", soldOutText: "Sold out", unavailableText: "Unavailable" } });

window.__shgProductInits.push({ uuid: "s-be30fe98-ceea-4055-95cd-315fc86057dd", platform: "big_commerce", currency: "USD", moneyFormat: {"USD":{"currency":"USD","currency_symbol":"$","currency_symbol_location":"left","decimal_places":2,"decimal_separator":".","thousands_separator":","}}, productUrl: "https://getshogun.com/api/products", authToken: "eyJhbGciOiJIUzI1NiJ9.eyJzaXRlX2lkIjoiMDEwNzdjZTgtNDY2OS00MWZhLTk1NzItODY2YzAwMTc3MTdjIiwicHJvZHVjdF9pZCI6IjE4NSJ9.CY3OOHLaw-SJHpuQSD_Mn2EGgw7LSIdtdQ7PIC37TOQ", productHandle: "lwl02-lorawan-water-leak-us915/", productVariantId: 177 });

window.__shgProductCallbacks["s-be30fe98-ceea-4055-95cd-315fc86057dd"].push({ cb: "box", data: { uuid: "s-be30fe98-ceea-4055-95cd-315fc86057dd" } });