devicehive
by Nikolay Khabarov
通过尼古拉·哈巴罗夫(Nikolay Khabarov)
如何使用DeviceHive运行Grafana (How to run Grafana with DeviceHive)
DeviceHive is an IoT platform which has plenty of different components. The Grafana plugin is one of them. This plugin can gather data from a DeviceHive server and display it with different dashboards using the very popular tool — Grafana. This article explains how to create a Grafana dashboard with DeviceHive. As an example, this uses the ESP8266 chip analog pin to visualise the voltage on it.
DeviceHive是一个物联网平台,具有许多不同的组件。 Grafana插件就是其中之一。 该插件可以从DeviceHive服务器收集数据,并使用非常流行的工具-Grafana在不同的仪表板上显示数据。 本文介绍了如何使用DeviceHive创建Grafana仪表板。 例如,它使用ESP8266芯片模拟引脚来显示其上的电压。
数据 (Data)
To display anything on a dashboard we need data. In terms of a DeviceHive server, data can be provided via ‘commands’ and ‘notifications’. Commands are typically used to deliver any messages to a device which the device should execute while ‘notifications’ are the opposite, devices notify their subscribers about certain events. ‘Commands’ and ‘notifications’ are basically simple JSON messages.
要在仪表板上显示任何内容,我们需要数据。 对于DeviceHive服务器,可以通过“命令”和“通知”提供数据。 命令通常用于将任何消息传递到设备应执行的消息,而“通知”则相反,设备将某些事件通知其订户。 “命令”和“通知”基本上是简单的JSON消息。
Both of these two entities can be used to plot graphs, display static text, a gauge, table or any other Grafana components. For this article we will generate notifications using special DeviceHive firmware for the ESP8266 chip. This firmware allows the chip to connect directly to a DeviceHive server using its protocol and has plenty of documented commands which can be issued from the server side.
这两个实体均可用于绘制图形,显示静态文本,量规,表格或任何其他Grafana组件。 对于本文,我们将使用ESP8266芯片的特殊DeviceHive固件生成通知。 该固件允许芯片使用其协议将其直接连接到DeviceHive服务器,并具有可从服务器端发出的大量书面命令 。
使用ESP8266固件生成通知 (Generating notifications with ESP8266 firmware)
The binaries for the DeviceHive firmware are available here. Download the latest version and flash this firmware to your chip. The release archive contains documentation on how to do that, but if you have a ‘nodemcu’-like board you just need to connect the board via a microUSB cable to your computer and run the ‘esp-flasher’ util from the release archive for your operating system and wait until it flashes the board. Having flashed the board, there is a need to configure the chip which Wi-Fi network, DeviceHive server, and credential it should use. There are two ways to do that: using a posix-like terminal with the ‘esp-terminal’ util or wirelessly as described