read the tutorial
Blueprint is a pre-configured template on the Blynk IoT platform, that will help you create a fully functional project in a few minutes. It already includes mobile and web dashboard UI, working firmware, and a tutorial to help you connect your device to the Blynk IoT platform and control it from the app!

On this page you can review the blueprint to have an idea of the ready project you are going to get. Sign up for a free account on the Blynk IoT platform to try it out.

Milesight EM300 - Water Leak Detector Blueprint Guide

The Milesight EM300 Water Leak Detector monitors and detects water leaks in various environments, providing real-time alerts to prevent damage. It also monitors battery levels and RSSI for reliable operation. This guide provides step-by-step instructions to set up the sensor, register it with The Things Network (TTN), and integrate it with Blynk IoT for data visualization and control.

Step 1: Unpacking and Initial Setup

1.1 Required Components

  • Milesight EM300 Water Leak Detector
  • LoRaWAN Gateway for connectivity

1.2 Initial Setup

  1. Verify Package Contents: Make sure all components are included and undamaged.
  2. Install the Batteries: Insert the batteries into the sensor, ensuring the correct polarity.
  3. Power On the Sensor: Hold the power button for 3 seconds. The LED will confirm activation.

Step 2: Registering the Sensor on The Things Network (TTN)

2.1 Setting Up the LoRaWAN Gateway if you don't do this before

  1. Log in to the TTN Console: Visit the TTN Console.
  2. Add a Gateway:
    • Navigate to Gateways > Add Gateway.
    • Enter:
      • Gateway EUI
      • Gateway ID
      • Frequency Plan for your region
    • Click Register Gateway.
  3. Configure the Gateway:
    • Follow the manufacturer's instructions to connect the gateway to TTN.
    • Ensure the gateway is online and visible in the TTN Console.
App

2.2 Creating a New Application

  1. Log in to TTN Console.
  2. Create an Application:
    • Navigate to Applications > Add Application.
    • Enter:
      • Application ID
      • Description
      • Handler
    • Click Create Application.
App

Note: To ensure smooth operation, it’s recommended that all devices within a TTN application are of the same sensor type (e.g., EM300). If you’d like to use different types of sensors, consider creating a separate application for each sensor type. This helps maintain better compatibility and performance.

2.3 Setting Up the Payload Formatter in the TTN Application

  1. Open the created application and, from the left-hand menu, select Payload Formatters.
Formater
  1. Select the Uplink tab and choose Custom JavaScript Formatter.
  2. Paste the formatter code (see in the Blynk.Console) and click Save Changes.

2.4 Pairing the Sensor with the TTN Application

  1. Download and install Milesight ToolBox App
  2. Open the Milesight ToolBox App:
    • Pair the sensor via NFC.
    • Navigate to Settings -> LoRaWAN Settings.
App
  1. Configure LoRaWAN Parameters:
    • DevEUI: Use the default value (found on the sensor label).
    • AppEUI: Use the manufacturer’s default value or generate a new one.
    • AppKey: Use the manufacturer’s default or generate a new one.
    • Frequency Plan: Match the frequency plan configured in TTN.
    • RX2 Data Rate: Set to DR3 (SF9, 125 kHz).
    • Spreading Factor: Set to SF10-DR2.
    • Default Application Port: Set to 85.
    • Use the Write button to save these settings via NFC.
Key

2.5 Configuring MQTT Integration in TTN

  1. Clink to the Use The Blueprint
  2. Navigate to TTN Integration Settings:
    • In the TTN Console, open your application and select Integrations.
  3. Select MQTT:
    • Click MQTT from the available integration options.
  4. You’ll need these details to set up the MQTT integration in Blynk:
    • Server Address
    • Port
    • Username
    • Password: Click Generate new API key and copy the generated key. Keep it secure.
Key

Step 3: Integrating TTN with Blynk

3.1 Configuring Blynk Integration via MQTT

  1. Click "Use Blueprint" at the top of the EM300 blueprint page.
  2. Set Up MQTT in Blynk:
    • Navigate to Developer Zone -> Integrations -> The Things Stack -> Add, and choose the template named Milesight EM300 ZLD.
Add intefration
  • Enter the data from Step 2:
    • Hostname: MQTT server address with port 1883 or 8883
    • Username
    • Password: The copied API key
  • Click Connect.

Connect

Step 4: Adding the Sensor as an End Device in TTN console

  1. Open the TTN console, select your application (created in step 2.2) and click Register End Device.
  2. From the LoRaWAN Device Repository:
    • Brand: Milesight
    • Model: EM300-ZLD
    • Hardware/Firmware Version: Use the latest version if unsure
    • Profile/Region: Based on the Frequency Plan table above
End dev
  1. Enter:
    • DevEUI, JoinEUI (AppEUI), and AppKey from Step 2.3
    • A unique End Device ID
  2. Click Register Device
End dev

Step 5: Onboarding the Sensor to Blynk

You can onboard the sensor in two ways:

  1. Automatic Device Creation – Recommended As soon as the sensor sends data to TTN, it will automatically appear on the Blynk Cloud.
dev online
  1. Manual Device Creation – If Something Goes Wrong
    • Navigate to DevicesCreate Device, and select the Milesight-EM300 template.
    • In the Info & Metadata tab, enter the TheThingsNetwork Device field using the device name from TTN.
TTN-dev

TTN-dev

TTN-dev

Step 6: Monitoring and Analyzing Data

Dashboard Overview

The dashboard is preconfigured, providing an intuitive interface for real-time monitoring. Both web and mobile dashboards offer the same functionality.

At the top of the dashboard, users can view the device name, online status, and last known location, with options to add location tags for better organization. A green Online indicator confirms active connectivity. If water is detected, a red alert banner appears and remains visible until the condition is resolved. Beneath the alert, the Water Status History bar provides a timeline, with green indicating dry periods and red marking water detection events.

The dashboard also displays the device’s battery level, with replacement or recharge recommended below 20% to ensure continuous operation. Current humidity and temperature readings are shown to monitor environmental conditions, and historical graphs are available for trend analysis. Users can adjust the displayed timeframe from Live up to one year. Device settings, such as reporting intervals and thresholds, can be modified via the Edit button.

Regularly checking the device’s connection, battery status, and water detection alerts is essential for maintaining reliable performance and timely incident response.

dev online

Step 7: Alerts & Automations

  1. In the Blynk Console, open Automations.
  2. Create triggers based on Device State or Sensor Value.
    • Example: water == 1 → Send notification
    • Example: Temperature < 10 → Update dashboard label

Step 8: Adding Location in Blynk

  1. Navigate to the Location section in Blynk.
  2. Enter the address or drag the map pin to the correct location.
Location
  1. Click Save.
  2. In the device's Info & Metadata, assign the saved location.

Step 9: Error Handling and Troubleshooting

9.1 Common Issues

  • Sensor Not Responding: Check battery orientation and charge. Try a reset.
  • No Connectivity: Recheck gateway setup and frequency plan.
  • Missing Data: Update your Payload Formatter in TTN’s Uplink/Downlink settings.

Next Steps

More pre-built IoT projects

Need an IoT solution for your business?

Contact us for a free consultation with our engineers and IoT business experts