AN APPROACH ADOPTED FOR SMART DATA GENERATION AND VISUALIZATION PROBLEMS

This paper discusses how to address and overcome some of the problems related to smart data generation and visualization, such as the poor autonomy of wireless sensor devices and the flexibility of the data management platform. We described the implementation and field experiment of a modular IoT application for Smart-Farming, in which the sensor devices are powered by an on-board battery and the data management system is based on a highly flexible software stack, capable of displaying time series graphs and processing millions of data per second. The experiment shown that the power consumption of the sensor devices depends on many factors and that the lifecycle of the devices can reach years using ultra-low power processors, low power wide area network (LPWAN) such as LoRaWAN and a mix of energy saving techniques. The data management and visualization platform shown to be able to display many types of time-series graphs, deal with a wide variety of data-sources and effectively manage a large amount of data.


Smart Data and Smart Services
Smart Cities promise to improve lives of people by meeting their needs through sustainable, energy-efficient and socially innovative solutions, i.e. solutions that produce less pollution, consume less energy and offer a new set of services. These new services will be based on data and will benefit from new technologies that are already available or that will soon be available (i.e. 5G, LP-WAN, smart-grid, energy harvesting techniques, etc..). The data will be generated from a multitude of sources such as people, activities, processes, buildings, vehicles, environment and so on. The characteristics of existing in large quantities, large varieties and having high throughput rates are common to those sources. This data must be filtered by interest and correlated with each other to make the intelligent service useful for people to guide their choices, anticipate their future needs and receive the right information based on the specific context. Therefore, smart data are the pillars on which we can build smart services that will improve our lives. Here we describe the implementation and field trial of an IoT system to generate, collect and display Smart Data addressing the problem of the autonomy of sensor devices and the flexibility and efficiency of data management and visualization.

System Architecture
An IOT system can be built according to a 4-layer architecture as shown in Figure 1.

Figure 1. IoT System layers
This architecture allows to create a highly modular and flexible system, which adapts to changes, and that can be scalable and performing by using the appropriate components. Below, we will describe peculiar characteristics of some elements which have been used for the implementation of our system.

Sensor Devices
A sensor device, as shown in Figure 2, consists of 3 functional blocks: sensing for data acquisition, computing for data processing and control, communication for transmitting information. The energy Storage provides energy to the sensor, generally an onboard battery with limited power capacity. As a result, the power consumption of the sensor devices is a critical factor of WSN applications and for this reason there is a great competition among the major manufacturers of ultra-low power (UPL) microchips used in these systems, with a strong tendency to integrate more and more functionality and provide hardware and software tools and platforms for rapid development and integration of solutions. All the leading companies have families of extremely performing products in terms of energy consumption such as STMicroelectronics' STM32L, Microchip's SAM-L, Texas MSP430 and NXP's KL Series. Even the EspressIf ESP-32, a system on a chip microcontrollers with integrated Wi-Fi and dual-mode Bluetooth, has some interesting energy-saving features, as it is able to operate in deep-sleep mode with only the ULP (ultra-low power) coprocessor active to perform some essential functions such as RTC (real-time clock) and partial access of RAM memory and GPIO ports. Another battle is fought by the sensor manufacturers that offer low power devices, integrated with other sensors, and with greater precision in measuring physical values and converting them from analog to digital. Companies like Texas, Bosh, Vishay, NXP are among the major players in this field. The sensor devices, besides having to be efficient during the acquisition and processing of the data, must have an efficient management of radio transmissions because, as we will see later, it can be in some cases the main contributor to the power consumption of the device. The recent technology shift proposes a device called Generic Node based on the concept of Software Defined Internet of Things (SDIoT). The Generic Node is an end device packed with multiple sensors that can support numerous use cases on a single unit with just one supply chain provisioned remotely or updated over the air (FOTA), while the device is in field.

Wireless Sensor Network
Wireless Sensor Networks (WSN) are used to transmit data gathered by a sensor device to a remote server in a wireless way. There are many implementations of WSNs, each fitting different system requirements; they are classified based on transmission range (short or long range), data rate (low rate or high rate), power consumption. In the IoT applications field with the deployment of hundreds or thousands of nodes arranged over large geographic areas, such as in the case of Smart-City or Smart-Region, LPWAN (Low Power Wireless Area Network) networks are of extreme interest on account of the fact that, in the face of a reduced transmission rate and unsecured quality of service, they offer the possibility of implementing long-range networks with low-cost devices that can remain in operation for years powered by simple Zinc-Carbon batteries. The most successful networks in this category are SigFox and LoRaWAN. To indefinitely prolong the battery life, the devices of the WSN networks can be equipped with systems for collecting energy otherwise dispersed (solar energy, kinetic energy, wind energy, etc.); networks made up of this type of device are called Energy Harvested WSN or EH-WSN.

LPWA network
The transmission technology is of fundamental importance for determining the power consumption of the sensor devices as, for applications that do not require the controller to be active most of the time, data transmission is the phase of greatest power consumption of the devices. In this context, the LoRa and SigFox technologies are those that allow a good compromise between low power consumption and transmission range despite severe limitations on the transmission bandwidth, data transmission frequency and quality of service. A comparison table between LoRaWAN and SigFox is shown in Table  SigFox instead offers a paid service of a few euros per month and allows the use of its own infrastructure or infrastructure provided by network operators in concession, so that coverage can exceed the borders of single nations. SigFox Recently made public its radio specifications for connected devices.

LoRaWAN infrastructure
The LoRaWAN Network architecture is shown in Figure 3. The network server of a LoRaWAN infrastructure can be hosted on its own server (on-premise) or it's possible to use servers of providers that offer support for the development of LoRaWAN and that offer the service for free (or almost). Among them are TheThingsNetworks.org (TTN), Chipstark.io, LoRIOT.io. LoRaWAN network server allows users to register their own devices and / or gateways and to route messages from devices to application server. Vice versa, they are able to deliver messages from an application server to the device through the gateways on which the devices register. The main tasks of network server are to manage the message queue and to manage the security and privacy of communications between devices and network servers and vice versa, allowing the trace and decoding of messages. LoRaWAN gateways forward packets from sensor devices to the LoRaWAN network server and vice versa using the LoRa protocol for forwarding to devices and the high bandwidth networks (Wi-Fi, Ethernet or cellular) for forwarding to the network server. Duplicate messages are deleted from the network server.

Application Server and Smart Data Visualization
The Application Server provides services to the final users, which in our case provides the necessary resources to collect, manage and visualize smart data. Data collected by this kind of system grow very rapidly over time proportionally with the number of active devices and transmission frequency; it is therefore essential to carefully plan the life cycle of the data, its persistence and granularity in relation to the objectives to pursue. The visualization systems, through dashboards and time series graphs, help to monitor the trend of the data collected and to alert any exceedances or deviations from critical values.
To extrapolate meaningful behaviours and anticipate trends, however, it is necessary to use specific Data Analytics systems (not discussed here) capable of suggesting decisions based on pre-established rules or learned independently from the data. Platforms for data visualization, to be a critical success factor for organizations that collect large amounts of data, must be flexible, quickly adaptable to customer requests, and scalable.

SYSTEM DESCRIPTION
Here we describe a system successfully deployed for Smart-Farming application to measure, collect and visualize environment data (air and ground temperature, air and ground humidity, air pressure, UV index and ambient light). The System is composed by a sensor device based on LoRa radio technology that use The Things Networks LoRaWAN services and an application server built on the TIG stack architecture. Users can visualize graphs and dashboards with a web browser and can be notified by the system of specified events.
The system architecture is shown in Figure 4.

Data collection and transmission
The sensor device is shown in Figure 5. It is based on ESP32pico micro equipped with Semtech LoRa radio chip SX-1276 and an environmental sensor developed by Bosh (BME-280) and Vishay (VEML6030 and VEML6075) connected by I2C bus. The Ground humidity sensor is built with commercial capacitive soil moisture sensor connected to the analog I/O port. The ESP-32 board manufactured by Heltec Automation (Wireless Stick Lite) is also equipped with an integrated Li-Ion recharge battery controller.

Figure 5. Sensor device connection diagram
Sensors are automatically shut down when not in use to save energy; ESP-32 absorbs about 30uA in deep-sleep mode between two transmissions cycles. Most of the power is required during tx (and rx), from 50mA (10dBm) to 100mA (14dBm) depending on payload length, transmission settings and link conditions (LoRa has an adaptive mechanism to improve communication reliability in case of high radio interference and high loss path that can increase transmitter power).

Data ingestion and management
The Application Server was built on TIG stack architecture composed by Telegraf for data ingestion, InfluxDB for data management and Grafana for dashboard and graph composition and visualization as shown in Figure 6.
Telegraf is an open-source plugin-driven server agent for both collection and reporting of data, with more than 200 plug-ins already available, making it very flexible and easily extendable. After a simple configuration, Telegraf can interact with LoRaWAN network server using the MQTT protocol and record measurement data into InfluxDB. InfluxDB is a time series database (TSDB) built specifically for handling metrics and events that are time-stamped capable to ingest massive volumes of data (handle millions of data points per second) and efficiently execute tasks for data lifecycle management, data summarization, and queries over large time ranges. It offers automatic mechanisms to apply retention policy (RP) to expiring old data and apply continuous query (CQ) to reduce data granularity (downsampling) to minimize cost of storage over time. Figure 6. TIG stack composition

Dashboard and Graph composer system
Grafana is a powerful tool to visualize data queried from many different data-sources in many possible graphs and dashboards. Grafana is also capable to send a notification to many destinations such as email, Slack, PagerDuty, Webhook, Telegram, Microsoft Teams, Kafka via Notification Channel when a certain condition specified by alert rule occurs. The alert rules are evaluated in the Grafana backend in a scheduler and query execution engine that is part of core Grafana.

Experiment results
A first implication derived after running the experiment with own LoRaWAN gateways is that network coverage must be considered to avoid unexpected result. After placing the LoRaWAN gateway and sensor device near the street level, in an urban environment, the resulting coverage was only a few hundred meters and in near-open space just a thousand meters; this is not unexpected due to the limited height at which antennas has been positioned. In any case, the Okumura-Hata model and two-ray model can be applied, under specified circumstances, to evaluate path losses (and hence the coverage radius) in the following scenarios: urban or rural environment and open-space (transmitting antenna and receiving antenna are in LOS -line of sight). Once the connection between the sensor device and the Application Server was established through the gateway and LoRaWAN network server, we began to collect data and setup Grafana panels organized in dashboards and time-series graphs as shown in Figure 7. LoRa Class A devices, with a spreading factor 7, bandwidth 125kHz, CRC Enabled and Coding rate 4/5 takes about 40ms to transmit a payload of 12bytes but it was also necessary to open 2 Rx windows and keep both microcontroller and radio awake for all this time. The Rx windows are necessary to receive data from the application: class A devices can only receive after they make a transmission. The measured result of the sum of start-up time, acquisition time from sensors and tx/rx activity was about 5.8 sec. for each acquisition/transmission cycle. With regards to the measured absorbed current waveform, the results are shown in Figure 8. Using a board with 30uA deep-sleep power consumption, sensors as described before, a mean transmission level of 10dBm, authentication mode with ABP, we can calculate the duration of the battery that depends on frequency of transmission cycle and battery capacity. Given a battery capacity, current absorption figure for a awakening and transmission cycle and frequency of these cycles it is possible to calculate the battery lifecycle (Batt_lifecycle) as shown in (1) where Batt_cap is the battery capacity in Watt*h, P_cycle is the absorbed power in one cycle in Watt*h, Tx_cycle are the hours between two tx cycles.
As shown in Figure 9, the battery lifecycle for a sensor device that transmits data every 6 hours, is about 3.6 years without considering the phenomenon of self-discharge of the battery. The power consumption distribution graph shown in Figure 10 shows that for this application and type of sensor device, the power consumption when device is in deep-sleep is the main contributor. Figure 10. Power consumption distribution for sensor device activity Note that a sensor device equipped with different CPU's that requires 5uA in deep-sleep mode, will result in totally different Power consumption distribution, with Radio activity being the main contributor.

Comments on experiment results
The platform used for data management and visualization offers excellent performance in terms of flexibility, modularity, possibility of managing heterogeneous data sources, presentation and customization of time series, interoperability, scalability and response times (these last two depend on the host architecture). In addition, the platform can effectively manage data consolidation based on programmable granularity reduction operations, avoiding the obscuration of important data due to overabundance and limiting the increase in storage space (and costs) required over the time and data acquisitions. The autonomy of battery powered sensors depends on many factors, at node and network level such as microprocessor platform, sensor technology, sw management, duty cycle, radio transmission power, etc. To obtain satisfactory results in terms of autonomy, it is necessary to both write efficient sw for the given hw platform (giving up flexibility), and to bind to a specific transmission technology for Low Power networks sacrificing latency, bandwidth capacity, throughput, quantity of data that can be transmitted with a single packet, QoS, etc.
The results here presented were obtained adopting general energy saving techniques that can be widely applied in the WSN: -Operating with ULP (ultra low-power) co-processor -Switching off all sensors, GPIO's, radio and I2C/I2S buses when device goes to deep sleep mode -Using low-power sensors, with many sensors integrated in the same breakout board -Using low-power transmission network -Reducing radio activity as much as possible (compress payload, avoid acknowledged protocol, etc..)

CONCLUSION AND FUTURE WORK
This document described some problems and possible solutions of wireless sensor networks (WSN) for smart data generation and visualization through the implementation and field experiment of an IoT application for Smart-Farming based on LoRa Wide Area Network (LoRaWAN). The results of the experiment are shown and discussed in terms of autonomy and energy consumption of the devices and in terms of features offered by the data management and visualization platform. While the TIG stack (Telegraf, InfluxDB and Grafana) shown to have all the desirable characteristics, battery-powered devices can achieve an acceptable lifecycle only with an appropriate hardware and software configuration. This can be very limiting, especially in applications where higher duty-cycle (the fraction of the time for which the device is active) and faster detection are required. To overcome these limitations and extend the lifecycle of the sensor devices, several techniques developed in recent years to harvest energy from surrounding environment can be used to recharge on-board battery. For example energy harvesting solutions that harness solar energy are used in smart farming applications, solutions that harness wind energy by means of micro wind turbines are used in structural health monitoring (SHM) of underground train tunnels, solutions that harness kinetic energy. As future work, the authors aim to investigate technology of Vibration Energy Harvester (VEH) to develop a SHM application for railways, roads, bridges, viaducts, which uses vibrational energy to recharge the onboard battery of sensor device.