WIFI Rain Level Sensor

Developers Manual

Version: 1.1.0

Product Description

The water sensor clamp measures the flow and temperature in a water pipe using a "Time of Flight" measurement method and transmits the data wirelessly. By analyzing the flow internally, water leaks and other anomalies are detected, and the owner is alerted.

The device is clamped onto the outside of the water pipe without interrupting the water supply. Its flexible design and innovative software allow it to be used on water pipes between 16 and 50 mm, with all currently available materials on the market such as PEX, PEX AL, copper, PE, or steel. It meets all requirements of the European Community's Measuring Instruments Directive (MID). With only 60 mm of space required above the water pipe and a length of 110 mm, the device is very flat and short, making it easy to install.

The device can be powered either via USB-C or two AA alkaline cells. Whenever an external power source is available, it is used independently of the inserted batteries.

The system communicates via Wi-Fi and is controlled by an app on a mobile phone. Additionally, data can be sent to an MQTT server or an HTTP 'webhook' to be integrated into a smart home system.

JSON Cloud Interface

By default, the devices communicate directly with the Aqua-Scope Cloud via an IP connection. The data is encoded as a JSON object and then encrypted using the XXTEA encryption algorithm with a private key stored in the device. The encrypted data is transmitted as ASCII hexadecimal values in the POST field of an HTTP request. In the data field of the HTTP request, the downlink data is also sent as a JSON object and encrypted using XXTEA.

The very same JSON encoding is used for the MQTT and the JSON Webservice interface. The following downlink commands are understood by the devices as JSON objects:

Downlink Command: 'conf': {a:b,c:d}

Changing configuration parameter 'a' resp. 'c' to the value of 'b' resp 'd'. A maximum of 32 parameters can be changed simultaneously. The parameters are modified in the order they are specified. For the explanation of the parameters and its values please refer to the section 'Configuration parameters' in this manual.

Downlink Command: 'system': x

System commands are:

Downlink Command: 'shell': 'aaa'

Execute a command on the serial shell. The commands are described in the BLE interface. Note that if a command requires a space, use the underscore character ('_').

Downlink Command: 'ota': 'xxx'

Firmware Update Over the Air. XXX represents a transaction number used to request the required firmware from the OTA server.

Downlink Command: 'webs': { 'enable': '1', 'url': 'https://io.aqua-scope.com/be3/test.php', 'token': '12345', 'raw': 1, 'xxtea': 1 }

The 'webs' object configures the use of a JSON Web Service. When enabled (enable = 1), all JSON reports are encoded and transmitted in the POST field of an HTTP request. Optionally, a private token can be provided, which is appended to the URL as a GET parameter. With 'raw' set to 1, detailed raw data is also sent to this service when the device collects such data. The 'xxtea' switch allows the JSON object to be encrypted with the device's private key. More information on this is available in the JSON Web Services section of this manual.

Downlink Command: 'clear': x

Clears an alarm of type X in the device. Using X = 0 will clear all alarms in the device. The alarm will also be reset even if the cause of the alarm, such as a temperature drop, has not been resolved. When an alarm is cleared with this command, the alarm will not be triggered again until the next reboot (via command or power-on).

Downlink Command: 'mqtt': :{'debug':'1','enable':'1','server':'aaa.bbb.com', 'port':789,'login':'abcdef','password':'abcdef'}

Configures the use of an MQTT service. When enabled (enable=1), all reports and alarms from the device are sent to the MQTT service specified as 'server' in parallel with other communication channels, using the IP port 'port'. Depending on the configuration of the MQTT service, an optional user login and password may need to be provided. The values can be subscribed to on the MQTT broker via the string '/AQS-XXXXXX', where XXXXXX is the 6-digit ID of the device.

Downlink Command: 'list': 0

Transmits all configuration parameters of the device as an array.

Downlink Command: 'valve': x

Sets a motor registered with the Aqua-Scope Monitor to the value X, which can be either 0 (closed) or > 0 (open). If more than one motor (device types 1 or 3) is registered, these motors are closed or opened together. If this is not desired, the type of a motor can be changed to a value other than 1 or 3. This motor must then be controlled directly using the 'svalve' command.

Downlink Command: 'svalve': {c: X,s: Y}

Sends a command to open or close a motor with a value Y to a sub-device in communication channel X, regardless of its device type. This command is needed when a motor is separated from the common control of all motors with the command 3. If the device in communication channel X is battery-operated and in deep sleep, this command will be executed when the device wakes up next. Pressing a button on the sub-device will wake it up.

Downlink Command: 'sconf': {c: X,p: Y,v: Z}

Sets a configuration parameter 'Y' of a sub-device in communication channel 'X' to the value 'Z'. If the device in communication channel X is battery-operated and in deep sleep, this command will be executed when the device wakes up next. Pressing a button on the sub-device will wake it up.

Downlink Command: '_': {"eid":"12345678","sensor_x":XXXX,"sensor_y":YYYY, }

The status report of a device is typically sent every 15 minutes and contains the names and current values of device-specific sensors. A status report is also sent for battery-operated devices. The interval (time between two reports) is defined in configuration parameter 29 (default 900 seconds). This does not apply to Aqua-Scope devices with a water pressure sensor (AQS*, PRE*, AQE*, ...) where the status is sent along with the raw data depending on the chosen sampling interval. The sensor types are provided in the device manual.

Downlink Command: 'sub': {X: {'c': cmd,'d': channel,'I': deveui,'k': key,'t': type},Y: {// ...}}

This configures sub-devices of an Aqua-Scope Monitor, whose functionality can only be used through the Aqua-Scope Monitor. Communication between these sub-devices and the Aqua-Scope main device occurs through a specially secured private LoRa Point-2-Point connection. Various commands are supported and are processed in the order they are specified in the JSON object. The command number X is not considered, but it's used to separate different commands.

Uplink Command: 'list': [1, 2, 3, 4, , 30]

Sends an array with all configuration parameters of a device in response to the downlink command 'list'.

Uplink Command: 'sub': {"c":X,"pay":YYY}

This is raw data from a sub-device in channel 'X'. Decoding the raw data can be done on the server. The encoding corresponds to the LoRaWAN communication channel encoding. The main device will also decode the received payload to execute commands intended for the main device (e.g., alarms that lead to motor shutdown).

Uplink Command: 'flow': {'event':'1|2', 'dur': XXX, 'cons': YYYY, 'reason': ZZZ }

This is a notification for the start and end of detected water consumption. 'event' = '1' indicates the start of a water consumption event with information about the reason for the event, and 'event' = '2' marks the end. It includes the event duration ('t'), the amount of water consumed ('l'), and, for debugging purposes, a possible reason for the termination of water flow. The duration is in seconds, and the amount is in milliliters.

Uplink Command: 'alarm': {"state":X,"type":Y,'val':Z,"map":AA}

This alarm object notifies active (state=1) or completed (status=0) alarm states. 'type' specifies the alarm type, and depending on the alarm type, an additional value may be provided if applicable (e.g., the current temperature value for a temperature alarm). The complete alarm vector 'map' can also be transmitted, where each bit corresponds to an alarm type.

Uplink Command: 'uptime': 'xxxx'

The heartbeat of a device transmits the uptime in seconds plus a device-specific status. If a meaningful status cannot be transmitted for a device, this object is omitted. A heartbeat is only sent for devices that are not battery-operated. The interval (time between two heartbeats) is defined in configuration parameter 30 (default 20 seconds).

Uplink Command: 'arr': xxxxx

If available on the device, this object transmits the raw data from the main sensor as a continuous string of hexadecimal characters of length 4. For example, "arr": "035403560350..." for 0x0354 = 852, 0x0356 = 854, 0x30350 = 848.

Local Web Server

HTTPD Dienst

The local web server of Aqua-Scope WLAN devices is active by default on Port 80 (HTTP service) and can be used for the initial configuration of WLAN, among other functions. Once the WLAN interface is successfully configured, the web server is deactivated. However, it can be reactivated from any communication channel. The web server allows for enabling and disabling, as well as configuring other communication channels like MQTT or JSON web service. It also provides easy access to the current sensor values of the device. Accessing the web server when the device is in sleep mode is challenging as there is a very limited time available for querying or setting values.

The web server interface is self-explanatory.


To use this communication channel, you need an HTTP server with a communication endpoint to which the device can send its data in JSON format via the POST field. The communication options are defined in the Aqua-Scope Cloud Interface description.

If encryption via XXTEA (https://en.wikipedia.org/wiki/XXTEA) is chosen, you must have a device-specific 128-bit encryption key. This key is securely embedded in the device and cannot be extracted or read. You can obtain this key directly from Aqua-Scope upon request, providing the 8-byte ID. The 8 bytes of the ID follow the format specified by Aqua-Scope.


When no encryption is selected, data transmission occurs as an HTML POST with a content type of 'application/json.' With encryption, 'application/raw' is used, and the JSON object is encrypted with XXTEA and then encoded as HEX ASCII.

The transmitted JSON object corresponds to the Aqua-Scope Cloud Interface description. As a response or command to the device, a downlink object can be sent in the HTTP text, the format of which also complies with the Aqua-Scope Cloud Interface.

The transmission of sensor raw data (using the 'arr' object) must be explicitly enabled, for example, in the app. This data is generally not encrypted.

The following small example demonstrates the reception of a JSON object from the Aqua-Scope device, exemplified as PHP code.

If you have any further questions or need assistance with anything specific, feel free to ask.

require_once __DIR__ . 'xxtea-php.php'; 
// from https://github.com/xxtea/xxtea-php

#define EID 060000001
#define KEY 06000000123456780600000012345678

$json  = json_decode(file_get_contents('php://input'), true);
if(!$json) {
	$key = hex2bin(KEY);	
	$jd = xxtea_decrypt(base64_decode(file_get_contents('php://input')),$key);
	$json  = json_decode(jd, true);
	if(!$json) die(”wrong key or wrong id”);

MQTT Service

All data (except for the raw data from the main sensor) can be sent in parallel to both the JSON web service and the Aqua-Scope Cloud to an MQTT broker. To do this, the server, port, and optionally an access login and password are provided. To retrieve data, you must subscribe to:

With '12345678' as the 8-digit device ID. It is also possible to send downlink commands as JSON objects via the MQTT service. The notation of these commands is identical to those of the Aqua-Scope Cloud.

Bluetooth Low Energy

The Bluetooth interface of Aqua-Scope WLAN devices is active by default and is used for the initial configuration of WLAN through the Aqua-Scope app. Once the WLAN interface is successfully configured, the Bluetooth interface is deactivated. However, it can be reactivated from any communication channel. Please note that reactivating the Bluetooth interface on battery-operated devices will block their sleep mode and quickly deplete the battery.

The Bluetooth interface implements the UART profile in BLE 5. It can be used with all serial Bluetooth applications. It's even more convenient when using a PC or an Android mobile phone with Bluetooth capabilities. You can open the Chrome browser, navigate to the website 'https://ble.aqua-scope.com,' and connect to the Bluetooth device 'AQS-XXXXXX' (where XX is the device's ID).

Once the Bluetooth connection is established, you have direct access to the internal serial console of the device. You can view all debug messages and execute commands, seeing their results on the console. The following commands are supported:


Alarm messages consist of an alarm type, the alarm status ( 1 = on, 0 = off) and an optional value that is associated ot the alarm.

Alarm 4 (0x04): Heavy Rain

Description: The sensor measures the time between two bucket events and calculates the rain intensity. Once the intensity rises beyond the value defined in Configuration parameter 10, the heavy rain alarm is issued. Please note that every bucket flip right after reboot will issue a heavy rain threshold since it's assumed that at the boot moment the bucket was flipped.

Optional Alarm Value: Current Rain Intensity in liter/hour

Configuration Parameters

This list of configuration parameters is supported by this device. All configuration parameters are 32 bit values but - with the exception of Parameter 3 only the lower 16 bits are used

Parameter 1 (0x01): System Register (Default: 0x5bfe = dec 23550)

The bitmap defines the general behavior of the device. Bit = 1 means function enabled, bit = 0 means function disabled.

Parameter 5 (0x05): Temperature Calibration (Default: 0x03e8 = dec 1000)

This is an offset value that can be set to align the internal measured temperature to the real-world temperature. Please keep in mind that the device das a simple internal NTC temperature sensor.

Parameter 8 (0x08): High Threshold for Temperature Alarm (Default: 0x0190 = dec 400)

If the measured temperature rises beyond this level a temperature alarm is issued. Dropping below the level clears the alarm

Parameter 9 (0x09): Heavy Rain Alarm Threshold (Default: 0x0014 = dec 20)

This parameter defines the intensity of rain causing a heavy rain alarm. This parameter overwrites the legacy parameter 10 but allows setting the threshold in liter/h resp. mm, rain column. The configuration parameter works from all firmware version 240613 onwards.

Parameter 10 (0x0a): Heavy Rain Alarm Threshold (legacy) (Default: 0x00c8 = dec 200)

This threshold defines when the Heavy Rain Alarm will be issued and cleared. The value is defined as interval between two rain bucket events in 0.43 * seconds. The strange value is determined by the internal structures of the Ultra Low Power Processor that is doing all the magic while the main processor is sleeping for battery conservation purposes. A simple conversion is possible: r(l/h) = 4150 / x

Parameter 11 (0x0b): Frost Warn Threshold (Default: 0x0028 = dec 40)

A frost alarm is sent as uplink message when the current temperature falls below the threshold. The threshold value is accepted in 1/10 degree Celsius. The default value is set to 4 degree Celsius.

Parameter 12 (0x0c): Rain Meter (Default: 0x0000 = dec 0)

This configuration parameter contains the total amount of rain measured since last setup in 0.5 l/h resp. 0.5 mm rain column. It can be reset to zero by writing 0 into the parameter. The same rain meter value but in l/m is reported as part of the regular status report.

Parameter 19 (0x13): Alarm Enable/Disable (Default: 0xd806 = dec 55302)

The bitmap defines which alarm type is active and will cause an alarm status command 0x0b. Bit = 1 means function enabled, bit = 0 disables the function. The different alarm types are shown in the section 'LoRaWAN Alarm Types'.

Parameter 27 (0x1b): Status Report Multiplier (Default: 0x0018 = dec 24)


Parameter 28 (0x1c): Active Communication Channels (Default: 0x0000 = dec 0)

This register is bit-mapped and defines which communication channels of the device are active. Te following bits are recognized:

Parameter 29 (0x1d): Reporting Interval (Default: 0x0384 = dec 900)

This parameter defines the interval in seconds the device automatically reports sensor values and heartbeat as an uplink message.