Skip to content

Latest commit

 

History

History
913 lines (757 loc) · 39.4 KB

README.md

File metadata and controls

913 lines (757 loc) · 39.4 KB

rainy - a tiny tool for iot data collection and monitoring

rainy is a tiny tool for IoT data collection and monitoring, and supports the following devices and protocols:

These data can be sent to InfluxDB (Time Series Database) for visualization, or sent to MQTT Broker to be used as a data source for any other purposes.

rainy runs on Apache Felix (OSGi). I think that rainy can be embedded in the environment without OSGi.

I releases this in the form of the Eclipse plug-in project and this tool - rainy-felix.zip. The list of my source codes and third party bundles is Bundle list. You need Java 8. I have confirmed that it works in Raspberry Pi 3B (Raspbian Buster Lite OS (2019-07-10)).

The following figure is overview of rainy.

The following figure is overview which the monitoring is running together with rainy on same Raspberry Pi 3B. I checked easily that it also works with Raspberry Pi 4B.

The following image shows the hardware configuration.


Table of Contents


Purpose

The purpose of this tool is briefly as follows.

  • For private / office / factory room, easily collect general environmental information and industrial / factory equipment running information via OPC-UA.
  • Real-time monitoring and convert these information to MQTT as a data source for any other purposes.
  • Runs as Java / OSGi application on Raspberry Pi 3B (arm) and Ubuntu machine (amd64).

The concept is as follows.

Although I think the functionality and performance of this tool are not sufficient for formal operation, it may be an easy-to-try tool.

Setup OS

Please refer to here for setting RaspberryPi 3B as an environment for running rainy. Both Bluetooth, serial communication, GPIO and I2C can be enabled.

Setup sending data

rainy supports InfluxDB and MQTT broker as sending data.

Install InfluxDB and startup

I am using InfluxDB on Ubuntu 18.04. The installation is as follows from here.

# wget https://dl.influxdata.com/influxdb/releases/influxdb_1.7.8_amd64.deb
# dpkg -i influxdb_1.7.8_amd64.deb
# systemctl enable influxdb.service
# systemctl start influxdb.service

In addition, the step to install InfluxDB on Raspberry Pi 3B is as follows.

# wget https://dl.influxdata.com/influxdb/releases/influxdb_1.7.8_armhf.deb
# dpkg -i influxdb_1.7.8_armhf.deb
# systemctl enable influxdb.service
# systemctl start influxdb.service

Install Mosquitto (MQTT Broker) and startup

I am using Mosquitto as MQTT broker on Ubuntu 18.04. The installation is as follows.

# apt-get update
# apt-get install mosquitto
# apt-get install mosquitto-clients
# systemctl enable mosquitto.service
# systemctl start mosquitto.service

In addition, the step to install Mosquitto on Raspberry Pi 3B is the same as above.

Setup visualization tools

Install Grafana and startup

I am using Grafana on Ubuntu 18.04. The installation is as follows from here.

# wget https://dl.grafana.com/oss/release/grafana_6.4.3_amd64.deb
# dpkg -i grafana_6.4.3_amd64.deb
# systemctl enable grafana-server.service
# systemctl start grafana-server.service

In addition, the step to install Grafana on Raspberry Pi 3B is as follows.

# wget https://dl.grafana.com/oss/release/grafana_6.4.3_armhf.deb
# dpkg -i grafana_6.4.3_armhf.deb
# systemctl enable grafana-server.service
# systemctl start grafana-server.service

Install Chronograf and startup

I am using Chronograf on Ubuntu 18.04. The installation is as follows from here.

# wget https://dl.influxdata.com/chronograf/releases/chronograf_1.7.14_amd64.deb
# dpkg -i chronograf_1.7.14_amd64.deb
# systemctl enable chronograf.service
# systemctl start chronograf.service

In addition, the step to install Chronograf on Raspberry Pi 3B is as follows.

# wget https://dl.influxdata.com/chronograf/releases/chronograf_1.7.14_armhf.deb
# dpkg -i chronograf_1.7.14_armhf.deb
# systemctl enable chronograf.service
# systemctl start chronograf.service

Testing HTTPS connection with self-signed certificate

In general, it is not recommended to use a self-signed certificate for formal operation, but it is sufficient for testing purposes.

Create a self-signed certificate and private key with file names cert.pem and cert.key

# openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout cert.key -out cert.pem -subj "/CN=localhost" -days 365

Create /etc/rainy directory and place these files there

# mkdir /etc/rainy
# cp cert.pem cert.key /etc/rainy/
# cd /etc/rainy
# chmod 0644 cert.pem cert.key

Setting Grafana HTTPS connetion

See here for details.

  • Edit /etc/grafana/grafana.ini
@@ -29,7 +29,7 @@
 #################################### Server ####################################
 [server]
 # Protocol (http, https, socket)
-;protocol = http
+protocol = https
 
 # The ip address to bind to, empty will bind to all interfaces
 ;http_addr =
@@ -58,8 +58,8 @@
 ;enable_gzip = false
 
 # https certs & key file
-;cert_file =
-;cert_key =
+cert_file = /etc/rainy/cert.pem
+cert_key = /etc/rainy/cert.key
 
 # Unix socket path
 ;socket =
  • Restart Grafana and connect to https://hostAddress:3000/ with a browser
# systemctl restart grafana-server.service

Setting Chronograf HTTPS connetion

See here for details.

  • Edit /etc/default/chronograf
TLS_CERTIFICATE=/etc/rainy/cert.pem
TLS_PRIVATE_KEY=/etc/rainy/cert.key
  • Restart Chronograf and connect to https://hostAddress:8888/ with a browser
# systemctl restart chronograf.service

Configuration - rainy/conf

rainy.properties

  • clientID
    Set a unique client identifier for running rainy.
  • cc2650
    Set to true when using CC2650. default is false.
  • bme280
    Set to true when using BME280. default is false.
  • bh1750fvi
    Set to true when using BH1750FVI. default is false.
  • mhz19b
    Set to true when using MH-Z19B. default is false.
  • ppd42ns
    Set to true when using PPD42NS. default is false.
  • rcwl0516
    Set to true when using RCWL-0516. default is false.
  • hcsr501
    Set to true when using HC-SR501. default is false.
  • opcua
    Set to true when using OPC-UA. default is false.

Note. This tool uses Pi4J for BME280/BH1750FVI/PPD42NS/RCWL-0516/HC-SR501, so these devices can only be used with Raspberry Pi series (arm). Therefore, their feature of this tool does not work on amd64 Linux machines, so set them to false on amd64 Linux machines.

Setting the connection for sending data

InfluxDB - influxdb.properties

  • influxDBUrl
    default is http://localhost:8086.
  • userName
  • password
  • actions
    Set the number of actions to collect. default is 1000.
  • flushDuration
    Set the time to wait at most (msec). default is 1000.
  • dataOnly
    Set to true when collecting only data. default is true.

MQTT - mqtt.properties

  • brokerUri
    default is tcp://localhost:1883.
  • userName
  • password
  • clientID
    First half string of unique client identifier when connecting to MQTT broker. After this string, this system adds a random string to complete the clientID string.
  • qos
    default is 0.
  • topic
    Topic when publishing data to MQTT broker. default is rainy.

Setting sensors and protocols

CC2650 - cc2650.properties

Here is also helpful.

  • bluetoothAdapter
    Bluetooth adapter name. default is hci0. Check the list of adapter names with the hciconfig command.
# hciconfig -a
hci0:   Type: Primary  Bus: UART
        BD Address: B8:27:EB:7D:0F:7D  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING 
        RX bytes:28342 acl:441 sco:0 events:2265 errors:0
        TX bytes:34605 acl:441 sco:0 commands:1955 errors:0
        Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
        Link policy: RSWITCH SNIFF 
        Link mode: SLAVE ACCEPT 
        Name: 'raspberrypi'
        Class: 0x000000
        Service Classes: Unspecified
        Device Class: Miscellaneous, 
        HCI Version: 4.1 (0x7)  Revision: 0x168
        LMP Version: 4.1 (0x7)  Subversion: 0x2209
        Manufacturer: Broadcom Corporation (15)
  • influxDB
    Set to true when sending data to InfluxDB. default is false.
  • mqtt
    Set to true when sending data to MQTT broker. default is false.
  • prettyPrinting
    Set to true when indenting the log output of JSON format data. default is false. It is also necessary to change the following log level of conf/logging.properties.
    #io.github.s5uishida.level=INFO
    -->
    io.github.s5uishida.level=FINE
    
  • readCrontab
    Set the schedule for sensing data in crontab format. default is every minute.
  • batteryLevel
    Set to true when getting battery level. default is false.
  • Example of setting Temperature sensor
    • temperature
      Set to true when using a Temperature sensor. default is false.
    • temperatureNotify
      Set to true when using the notification function. default is false. When the notification function is enabled, the readCrontab schedule for Temperature sensor is disabled.
    • temperatureNotificationPeriod
      Set the notification time interval in milliseconds. default is 1000.
  • Movement
    • gyroscope
      Set to true when using a Gyroscope sensor. default is false.
    • accelerometer
      Set to true when using a Accelerometer sensor. default is false.
    • magnetometer
      Set to true when using a Magnetometer sensor. default is false.
    • movementNotify
      Set to true when using the notification function. default is false. When the notification function is enabled, the readCrontab schedule for Movement sensor is disabled.
    • movementNotificationPeriod
      Set the notification time interval in milliseconds. default is 1000.
    • wakeOnMotion
      Set to true when sending movement data when a shake is detected. It sends Movement data at a time interval specified by notification for 10 seconds. default is false.
    • accelerometerRange
      Set Accelerometer range. default is 2.
  • devices
    List the addresses of the target CC2650 devices. To check the address of CC2650, use hcitool command as follows.
# hcitool lescan
LE Scan ...
B0:B4:48:B9:92:86 (unknown)
B0:B4:48:B9:92:86 CC2650 SensorTag

After launching hcitool command, press the power button of CC2650 and the scan results will be displayed as above.

BME280 - bme280.properties

Here is also helpful.

  • i2cBusAddress
    Set the I2C bus number and address. default is 1:76.
  • influxDB
    Set to true when sending data to InfluxDB. default is false.
  • mqtt
    Set to true when sending data to MQTT broker. default is false.
  • prettyPrinting
    Set to true when indenting the log output of JSON format data. default is false. It is also necessary to change the following log level of conf/logging.properties.
    #io.github.s5uishida.level=INFO
    -->
    io.github.s5uishida.level=FINE
    
  • readCrontab
    Set the schedule for sensing data in crontab format. default is every minute.

BH1750FVI - bh1750fvi.properties

Here is also helpful.

  • i2cBusAddress
    Set the I2C bus number and address. default is 1:23.
  • influxDB
    Set to true when sending data to InfluxDB. default is false.
  • mqtt
    Set to true when sending data to MQTT broker. default is false.
  • prettyPrinting
    Set to true when indenting the log output of JSON format data. default is false. It is also necessary to change the following log level of conf/logging.properties.
    #io.github.s5uishida.level=INFO
    -->
    io.github.s5uishida.level=FINE
    
  • readCrontab
    Set the schedule for sensing data in crontab format. default is every minute.

MH-Z19B - mhz19b.properties

Here is also helpful.

Note. When using with PPD42NS, please connect pin#4 (Yellow) of PPD42NS to pin#19 (GPIO10) or pin#38 (GPIO20) of Raspberry Pi 3B. Or when connecting pin#4 (Yellow) of PPD42NS to pin#8 (GPIO14) of Raspberry Pi 3B, connect MH-Z19B to Raspberry Pi 3B via USB serial adapter (etc. DSD TECH SH-U09C USB to TTL Serial Adapter with FTDI FT232RL Chip). When connecting MH-Z19B to a USB serial adapter, you should specify /dev/ttyUSB0 for the port name.

  • portName
    Set the serial port name. default is /dev/ttyAMA0.
  • influxDB
    Set to true when sending data to InfluxDB. default is false.
  • mqtt
    Set to true when sending data to MQTT broker. default is false.
  • prettyPrinting
    Set to true when indenting the log output of JSON format data. default is false. It is also necessary to change the following log level of conf/logging.properties.
    #io.github.s5uishida.level=INFO
    -->
    io.github.s5uishida.level=FINE
    
  • readCrontab
    Set the schedule for sensing data in crontab format. default is every minute.
  • autoCalibration
    Set whether to calibrate automatically every 24 hours after powered on. default is false.
  • zeroCalibration
    Set whether to calibrate to 400 ppm. default is false.
  • detectionRange
    Set the detection range to 2000 or 5000 ppm. default is 5000ppm.

PPD42NS - ppd42ns.properties

Here is also helpful.

  • gpioPin
    Set to GPIO_10, GPIO_20 or GPIO_14. default is GPIO_10.
  • influxDB
    Set to true when sending data to InfluxDB. default is false.
  • mqtt
    Set to true when sending data to MQTT broker. default is false.
  • prettyPrinting
    Set to true when indenting the log output of JSON format data. default is false. It is also necessary to change the following log level of conf/logging.properties.
    #io.github.s5uishida.level=INFO
    -->
    io.github.s5uishida.level=FINE
    
  • readCrontab
    Set the schedule for sensing data in crontab format. default is every minute.

RCWL-0516 - rcwl0516.properties

Here is also helpful.

  • gpioPin
    Set to GPIO_18, GPIO_19, GPIO_12 or GPIO_13. default is GPIO_18.
  • influxDB
    Set to true when sending data to InfluxDB. default is false.
  • mqtt
    Set to true when sending data to MQTT broker. default is false.
  • prettyPrinting
    Set to true when indenting the log output of JSON format data. default is false. It is also necessary to change the following log level of conf/logging.properties.
    #io.github.s5uishida.level=INFO
    -->
    io.github.s5uishida.level=FINE
    

When a motion is detected, an event occurs immediately. If mqtt is set to true, this event can be received from the MQTT broker.

HC-SR501 - hcsr501.properties

Here is also helpful.

  • gpioPin
    Set to GPIO_18, GPIO_19, GPIO_12 or GPIO_13. default is GPIO_19.
  • influxDB
    Set to true when sending data to InfluxDB. default is false.
  • mqtt
    Set to true when sending data to MQTT broker. default is false.
  • prettyPrinting
    Set to true when indenting the log output of JSON format data. default is false. It is also necessary to change the following log level of conf/logging.properties.
    #io.github.s5uishida.level=INFO
    -->
    io.github.s5uishida.level=FINE
    

When a motion is detected, an event occurs immediately. If mqtt is set to true, this event can be received from the MQTT broker.

OPC-UA - opcua.properties

  • influxDB
    Set to true when sending data to InfluxDB. default is false.
  • mqtt
    Set to true when sending data to MQTT broker. default is false.
  • prettyPrinting
    Set to true when indenting the log output of JSON format data. default is false. It is also necessary to change the following log level of conf/logging.properties.
    #io.github.s5uishida.level=INFO
    -->
    io.github.s5uishida.level=FINE
    
  • keyStoreType
  • keyStoreAlias
  • keyStorePassword
  • certificate

OPC-UA server - conf/opcua/milo-public-demo.properties

The following is an example of Public Demo Server of Eclipse Milo.

  • use
    Set to true to use this server. default is false.
  • serverName
    Set the OPC-UA server name.
  • endpointIP
    Set the OPC-UA server address.
  • endpointPort
    Set the OPC-UA server port number.
  • securityPolicy
    Set one of Basic128Rsa15, Basic256, Basic256Sha256 or None in securityPolicy. default is None.
  • securityMode
    Set one of Sign, SignAndEncrypt or None to securityMode. default is None.
  • userName
  • password
  • requestTimeout
    default is 10000 (msec).
  • sessionTimeout
    default is 10000 (msec).
  • publishingInterval
    Set publishingInterval (msec). default is 1000 (msec).
  • samplingInterval
    Set samplingInterval (msec). default is 500 (msec).
  • queueSize
    Set queueSize. default is 10.
  • dataChangeTrigger
    Set one of the following to dataChangeTrigger:
    • 0 for DataChangeTrigger.Status
    • 1 for DataChangeTrigger.StatusValue
    • 2 for DataChangeTrigger.StatusValueTimestamp
      default is 1.
  • nodeIDs
    List the target node ID. The format is as follows.
    <namespaceIndex>,<identifier>,<depth>
    
    nodeIDs=2,Dynamic/RandomInt32,0 \
        2,Dynamic/RandomInt64,0 \
        2,Dynamic,-1 \
        0,2295,-1
    
    In the above example, specify 2,Dynamic/RandomInt32 and 2,Dynamic/RandomInt64 uniquely, and search for the NodeID to be monitored from 2,Dynamic and 0,2295(VendorServerInfo) at an infinite depth. In this case, only 2,Dynamic,-1 and 0,2295,-1 should be specified, but I wrote it for explanation of the format.

conf/opcua also contains a milo-example.properties file. This is an example server-properties file of connecting to the server (milo-example-server) where the Milo sample server code is built almost as it is.

For reference, there is toem impulse OPC/UA Extension (Eclipse pulug-in) as a tool for easily checking the address space of OPC-UA server.

Run rainy

  • start
    Start rainy as follows.
# cd /path/to/rainy-felix/bin
# sh rainy-start.sh
-> ps
START LEVEL 1
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (6.0.3)
[   1] [Active     ] [    1] bcpkix (1.62)
[   2] [Active     ] [    1] bcprov (1.62)
[   3] [Active     ] [    1] java driver for bh1750fvi - ambient light sensor (0.1.2)
[   4] [Active     ] [    1] bluetooth scanner (0.1.4)
[   5] [Active     ] [    1] bluez-dbus-osgi (0.1.2.201911022022)
[   6] [Active     ] [    1] java driver for bme280 - combined humidity, pressure and temperature sensor (0.1.3)
[   7] [Active     ] [    1] bsd-parser-core (0.3.4)
[   8] [Active     ] [    1] bsd-parser-gson (0.3.4)
[   9] [Active     ] [    1] java driver for ti sensortag cc2650 (0.1.2)
[  10] [Active     ] [    1] Apache Commons Lang (3.9.0)
[  11] [Active     ] [    1] cron4j-osgi (2.2.5)
[  12] [Active     ] [    1] dbus-java-osgi (3.2.1.SNAPSHOT)
[  13] [Active     ] [    1] Gson (2.8.5)
[  14] [Active     ] [    1] Guava: Google Core Libraries for Java (26.0.0.jre)
[  15] [Active     ] [    1] java driver for hc-sr501 - pir motion detector sensor module (0.1.1)
[  16] [Active     ] [    1] Java client for InfluxDB (2.15)
[  17] [Active     ] [    1] jSerialComm (2.5.1)
[  18] [Active     ] [    1] Jackson-annotations (2.9.9)
[  19] [Active     ] [    1] Jackson-core (2.9.9)
[  20] [Active     ] [    1] jackson-databind (2.9.9.1)
[  21] [Active     ] [    1] JavaBeans Activation Framework (1.2.0)
[  22] [Active     ] [    1] jaxb-api (2.3.1)
[  23] [Active     ] [    1] file:/home/pi/rainy-felix/bundle/jaxb-runtime-2.3.2.jar
[  24] [Active     ] [    1] java driver for mh-z19b - intelligent infrared co2 module (0.1.3)
[  25] [Active     ] [    1] A modern JSON library for Kotlin and Java (1.7.0)
[  26] [Active     ] [    1] MessagePack serializer implementation for Java (0.8.17)
[  27] [Active     ] [    1] Netty/Buffer (4.1.38.Final)
[  28] [Active     ] [    1] netty-channel-fsm-osgi (0.3.0)
[  29] [Active     ] [    1] Netty/Codec (4.1.38.Final)
[  30] [Active     ] [    1] Netty/Codec/HTTP (4.1.38.Final)
[  31] [Active     ] [    1] Netty/Common (4.1.38.Final)
[  32] [Active     ] [    1] Netty/Handler (4.1.38.Final)
[  33] [Active     ] [    1] Netty/Resolver (4.1.38.Final)
[  34] [Active     ] [    1] Netty/Transport (4.1.38.Final)
[  35] [Active     ] [    1] Apache Felix Shell Service (1.4.3)
[  36] [Active     ] [    1] Apache Felix Shell TUI (1.4.1)
[  37] [Active     ] [    1] Apache ServiceMix :: Bundles :: jsr305 (3.0.2.1)
[  38] [Active     ] [    1] Apache ServiceMix :: Bundles :: okhttp (3.14.1.1)
[  39] [Active     ] [    1] Apache ServiceMix :: Bundles :: okio (1.15.0.1)
[  40] [Active     ] [    1] Apache ServiceMix :: Bundles :: retrofit (2.5.0.2)
[  41] [Active     ] [    1] Paho MQTT Client (1.2.1)
[  42] [Active     ] [    1] OSGi LogService implemented over SLF4J (1.7.26)
[  43] [Active     ] [    1] Pi4J :: Java Library (Core) (1.2)
[  44] [Active     ] [    1] java driver for ppd42ns - dust sensor module (0.1.7)
[  45] [Active     ] [    1] osgi activator of rainy - a tiny tool for iot data collection and monitoring (0.1.8)
[  46] [Active     ] [    1] OPC-UA bundle of rainy - a tiny tool for iot data collection and monitoring (0.1.5)
[  47] [Active     ] [    1] rainy - a tiny tool for iot data collection and monitoring (0.1.24)
[  48] [Active     ] [    1] java driver for rcwl-0516 - microwave presence sensor module (0.1.1)
[  49] [Active     ] [    1] sdk-client (0.3.4)
[  50] [Active     ] [    1] sdk-core (0.3.4)
[  51] [Active     ] [    1] slf4j-api (1.7.26)
[  52] [Resolved   ] [    1] slf4j-jdk14 (1.7.26)
[  53] [Active     ] [    1] stack-client (0.3.4)
[  54] [Active     ] [    1] stack-core (0.3.4)
[  55] [Active     ] [    1] strict-machine-osgi (0.1.0)
-> 
  • stop
    Stop rainy as follows.
-> stop 0

Output sensor values to the log file

If you change the following logging level of conf/logging.properties to INFO --> FINE and restart rainy, the sensor values will be output to the log file logs/rainy.log.0.

#io.github.s5uishida.level=INFO
-->
io.github.s5uishida.level=FINE

The sample of the output log is as follows.

[/dev/ttyAMA0] co2:1110 
[I2C_1_76] temperature:20.84 
[I2C_1_76] humidity:52.66211 
[I2C_1_76] pressure:1012.5222 
[I2C_1_23] optical:82.5 
[hci0] B0:B4:48:ED:B6:04 obj:15.8125 amb:21.75 
[hci0] B0:B4:48:ED:B6:04 humidity:56.78711 
[hci0] B0:B4:48:ED:B6:04 pressure:1012.96 
[hci0] B0:B4:48:ED:B6:04 optical:84.84 
[hci0] B0:B4:48:ED:B6:04 gyr[x]:-8.888245 
[hci0] B0:B4:48:ED:B6:04 gyr[y]:-7.5759883 
[hci0] B0:B4:48:ED:B6:04 gyr[z]:-0.06866455 
[hci0] B0:B4:48:ED:B6:04 acc[x]:0.010375977 
[hci0] B0:B4:48:ED:B6:04 acc[y]:-0.0040283203 
[hci0] B0:B4:48:ED:B6:04 acc[z]:0.24835205 
[hci0] B0:B4:48:ED:B6:04 mag[x]:183.0 
[hci0] B0:B4:48:ED:B6:04 mag[y]:403.0 
[hci0] B0:B4:48:ED:B6:04 mag[z]:-192.0 
[GPIO_10] pcs:4248.701 ugm3:6.6253257
[GPIO_18] detect:true
[GPIO_19] detect:true

In order to reduce writing to the SD card, it is usually recommended to set it to INFO.

Check the database name for each device created in InfluxDB

Check from the log file logs/rainy.log.0. The following is an example. Note that InfluxDB will not do anything if the database already exists.

execute - CREATE DATABASE RP3B_01__dev_ttyAMA0               <-- MH-Z19B
...
execute - CREATE DATABASE RP3B_01_I2C_1_76                   <-- BME280
...
execute - CREATE DATABASE RP3B_01_I2C_1_23                   <-- BH1750FVI
...
execute - CREATE DATABASE B0_B4_48_B9_92_86                  <-- CC2650
...
execute - CREATE DATABASE B0_B4_48_ED_B6_04                  <-- CC2650
...
execute - CREATE DATABASE milo_digitalpetri_com_62541_milo   <-- Public Demo Server of Eclipse Milo
...
execute - CREATE DATABASE RP3B_01_GPIO_10                    <-- PPD42NS
...
execute - CREATE DATABASE RP3B_01_GPIO_18                    <-- RCWL-0516
...
execute - CREATE DATABASE RP3B_01_GPIO_19                    <-- HC-SR501

These database names are required for the visualization tools Grafana and Chronograf to connect to InfluxDB.

Create dashboards with visualization tools

Visualization tools can be connected to InfluxDB to monitor time-series sensor data.

Case Grafana

Please refer to Getting started of Grafana site for how to use Grafana.
The following figure is a sample image of a dashboard.

The following figure is a sample graph of Magnetometer using Plotly panel.

The following figure is a sample monitoring image with environmental information on the floor map using ImageIt panel.

Case Chronograf

Please refer to Getting started of Chronograf site for how to use Chronograf.
The following figure is a sample image of a dashboard.

The following figure is a sample dashboard for the following NodeIDs on OPC-UA Public Demo Server of Eclipse Milo.

  • 1,VendorServerInfo/ProcessCpuLoad
  • 1,VendorServerInfo/SystemCpuLoad
  • 1,VendorServerInfo/UsedMemory
  • 2,Dynamic/RandomDouble
  • 2,Dynamic/RandomFloat
  • 2,Dynamic/RandomInt32
  • 2,Dynamic/RandomInt64

The upper displays 1,VendorServerInfo/ProcessCpuLoad, 1,VendorServerInfo/SystemCpuLoad and 1, VendorServerInfo/UsedMemory. The middle displays 2,Dynamic/RandomDouble and 2,Dynamic/RandomFloat superimposed and the lower displays 2,Dynamic/RandomInt32 and 2,Dynamic/RandomInt64 as time series graphs.

If you put data into InfluxDB which is a time series DB, you can easily create a dashboard using Grafana or Chronograf.

Check the data sent to MQTT broker

Check the data sent to the MQTT broker using the MQTT client command as follows:

# mosquitto_sub -d -t rainy/B0_B4_48_ED_B6_04
Client mosqsub|2095-u1804 sending CONNECT
Client mosqsub|2095-u1804 received CONNACK
Client mosqsub|2095-u1804 sending SUBSCRIBE (Mid: 1, Topic: rainy/B0_B4_48_ED_B6_04, QoS: 0)
Client mosqsub|2095-u1804 received SUBACK
Subscribed (mid: 1): 0
Client mosqsub|2095-u1804 received PUBLISH (d0, q0, r0, m0, 'rainy/B0_B4_48_ED_B6_04', ... (670 bytes))
{"deviceID":"B0:B4:48:ED:B6:04","clientID":"RP3B-01","samplingDate":"2019-08-09 12:56:00.009","samplingTimeMillis":1565351760009,"samplingTimeNanos":0,"firmwareVersion":"1.30 (May 23 2016)","batteryLevel":{"value":72,"unit":"%"},"objectTemperature":{"value":27.46875,"unit":"deg C"},"ambientTemperature":{"value":32.03125,"unit":"deg C"},"humidity":{"value":34.61914,"unit":"%"},"pressure":{"value":1009.16,"unit":"hPa"},"optical":{"value":203.84,"unit":"lux"},"gyroscope":{"x":-10.589599,"y":-7.8887935,"z":-2.281189,"unit":"deg/s"},"accelerometer":{"x":-0.029785156,"y":-0.06347656,"z":1.1887207,"unit":"G"},"magnetometer":{"x":138.0,"y":125.0,"z":-199.0,"unit":"uT"}}

Limitations

  • Only one Bluetooth adapter can be used.
  • Only a few CC2650 (Bluetooth devices) can be used at the same time. (Restriction of Bluetooth chip)
  • When the connection with CC2650 is lost, it may not recover automatically.
  • This tool uses Pi4J for BME280/BH1750FVI/PPD42NS/RCWL-0516/HC-SR501, so these devices can only be used with Raspberry Pi series (arm). Therefore, the the features of these devices of this tool does not work on amd64 Linux machines.
  • To use Pi4J 1.2's I2C functionality, sun.misc.SharedSecrets.class is required, but this class can only be used up to Java 8 and cannot be used since Java 9. Therefore, Java 8 is required to use BME280 and BH1750FVI.
  • Depending on the combination of the number of monitored items of OPC-UA servers and the publishing interval, the load on InfluxDB may become too large.

Bundle list

The following bundles I created follow the MIT license.

Please check each license for the following bundles used in addition to these.

I would like to thank the authors of these very useful codes, and all the contributors.

P.S.

If Raspberry Pi 4B (4GB memory model), InfluxDB and Grafana may be able to run together with rainy in enough resources. In this case, from sensor data collection to monitoring, it may be possible to run with one RP4.