We tried to create an engaging demo-game for events which should show the example of what you can build with our products. An interactive smart water meter demo with LwM2M and IPSO sensor (The Internet Protocol for Smart Objects) support. This simple solution for measuring the flow of liquids uses cellular or Wi-Fi connectivity to connect to the cloud and report the information on water usage or, in case of this demo, how much water was pumped through the system. Our demo also has options to measure the temperature, acidity, and pressure of the water.That’s why our Bubblemaker is based on the implementation of the Anjay LwM2M Client for Nordics devices.
Smart water meters are devices equipped with technology that goes beyond traditional water meters. These intelligent meters use mostly wireless communication and Internet of Things (IoT) capabilities to automatically collect and transmit water usage data to utility providers or homeowners.
The LwM2M (Lightweight Machine-to-Machine) protocol was designed to standardize messaging and device management for resource-constrained IoT devices. The LwM2M protocol optimizes bandwidth-efficient consumption by using space-efficient binary payloads and supports different wireless transport protocols such as NB-IoT, LTE-M, Wi-Fi, and SMS transport. It provides a uniform data format for easy interpretation of data, standardized device management processes, and support for FOTA (Firmware Over The Air).
Anjay is a library that implements the OMA Lightweight Machine-to-Machine protocol. Supporting multiple integration layers, it ensures the development of lightweight IoT devices.
Coiote IoT Device Management Platform allows you to manage your LwM2M devices throughout their entire lifecycle. Coiote IoT DM supports device onboarding, data management, data visualization, automated tests, firmware updates, monitoring & alerting, and cloud integrations.
Possible configurationsThis demo is configurable and it can be used as:
- The game for two players with two water flow meters
- The monitoring system for one water flow meter sensor
Our demo, as a game project, has options to change sensors and pump settings. It is possible to use a single water meter with an electrical or hand pump as well as two water meters with two hand pumps. This tutorial shows the usage of an nRF9160 DK with two water meters and one temperature sensor. Also, this demo has a variant where the water is pumped by an electrical pump. In addition, you can drive the electrical pump using CoioteDM!
NoteOnly the water flow meter sensor and the LED strip are needed parts. Other sensors can be excluded easily. For this go to the Add or exclude the sensors.
The bubblemaker supports the following LwM2M Objects:
- Security (/0)
- Server (/1)
- Device (/3)
- Connectivity Monitoring (/4)
- Firmware Update (/5)
- Sensors:
- Temperature (/3303) with multiple DS18B20 sensors on single 1Wire line
- Pressure (/3323)
- Acidity (/3326)
- On/Off switch (/3342)
- Push button (/3347)
- Water meter (/3424)
- Power Control (/3312)
We need to connect our sensors to the device. We have designed and manufactured the special PCB shield to wire everything up for easier connection of all required components. The actual PCB shield is designed for two temperature sensors, two water meter sensors, two acidity sensors, two pressure sensors, an LED strip, and a relay module for an electric water pump.
After wiring all sensors to the device, we will end up with something like this:
For readability, below is a wiring scheme:
NoteCustom created PCB isn’t required to wire everything up. You can wire sensors directly to the device.Build and flash the main application
First of all, get Zephyr, SDK (Software Development Kit), and other dependencies, as described in Zephyr's Getting Started Guide (first 4 steps).
After navigating to Zephyr workspace (~/zephyrproject
is default after following the Getting Started Guide), clone Anjay Zephyr client repository.
git clone https://github.com/AVSystem/Anjay-zephyr-client
If the environment was not set up earlier, go to the source path, and open the Terminal tab. In case it begins in the wrong directory, navigate to where you have initialized Zephyr and its dependencies (e.g. ~/zephyrproject
). Then run:
west config manifest.path Anjay-zephyr-client/bubblemaker
west config manifest.file west-nrf.yml
west update
Add or exclude the sensorsTo add or exclude any in a build, it is enough to comment or delete its name in the aliases section or its name and corresponding io-channel in the zephyr, user section in the boards/nrf9160dk_nrf9160_ns.overlay file. For better understanding, we will show you the example of having one temperature sensor #0, two acidity sensors, and two water meter sensors without an automatic water pump. The file should look like this:
/ {
aliases {
push-button-0 = &button0;
push-button-1 = &button1;
switch-0 = &button2;
switch-1 = &button3;
status-led = &led0;
temperature-0 = &ds18b200;
//temperature-1 = &ds18b201;
led-strip = &led_strip;
water-meter-0 = &water_meter0;
water-meter-1 = &water_meter1;
//water-pump-0 = &water_pump0;
};
zephyr,user {
/* these settings act as aliases for ADC sensors */
io-channels = <&adc 2>, <&adc 3>;
io-channel-names = "acidity0", "acidity1";
};
/* rest of the file */
Now you can build and flash the project using:
west build -b nrf9160dk_nrf9160_ns
west flash
Connect to the LwM2M ServerCoiote IoT Device Management is a scalable LwM2M-based IoT platform for complete device lifecycle management.
To connect to the Coiote IoT DM platform, please register at https://eu.iot.avsystem.cloud.
To connect the board:
Log in to Coiote IoT DM and from the left side menu, select Device Inventory.
In Device Inventory, click Add device.
Select the Connect your LwM2M device directly via the Management server tile.
In the Device credentials step:
In the Endpoint name enter your board endpoint name, e.g. test_device.
In the Security mode section, select the PSK (Pre-Shared Key) mode.
In the Key identity field, type the same name as in the Endpoint name field.
In the Key field, type the password used in the device-server authentication.
NoteRemember your device credentials provided in Coiote IoT DM must be the same as are on the Client side.
Click the Add device button and Confirm in the confirmation pop-up.
Configure the ClientWith the board still connected to a serial port interface, open a serial communication program.
TipTo show available subcommands, use the Tab key.
Use the anjay
command to list possible options:
Check your default credentials using anjay config show
command in the program:
NoteIf your default credentials are different from device credentials provided in Coiote IoT DM, change them using the anjay config set <possible_option> <value>
command.
Use the anjay start
command to run the Client.
Go to Coiote IoT DM to check if your device is connected. Click Next, then Go to Summary, then Finish. You will see your Device Center view:
Now, our demo can start pumping the water and collecting data. Feel free to try this and pump some water!
Configuring dashboard on Coiote IoT DMAfter successfully creating your device in Coiote it is time to show some charts with parameters. But first you need to set the observation.
NoteThe example shows how to set observations on water meter resources. Repeat further steps for the acidity, pressure, and temperature Sensor Value resources.
To set an observation on a resource (and, effectively send LwM2M Write-Attributes and Observe operations to the device):
- Click the eye icon in the Operations column.
- In the side navigation menu, enable the desired attributes, fill in the values, and click Set observation.
InfoNot more often than once every - the minimum time in seconds between two notifications.At least once every - the maximum time in seconds between two notifications. The notification is sent even if the value hasn't changed.
Read more about other attributes in our Brief description of OMA LwM2M.
After configuring the observations we can observe parameters that changed throughout the day.
To see our charts go to the Dashboard
tab from the main server website view.
You can also check charts for other sensors.
Building different applications using Anjay and Coiote DMThe Bubblemaker is one of many applications that you can build with Anjay and Coiote. More demos can be found here. Also, if you want to run the Anjay on your desktop without any additional hardware you can find a repository here.
Comments