zigbee2mqtt, node red, influxdb and grafana

 the iotstak comes with infuxDB:a data base very similar to firebase, which you don't need to setup the database every data type to make it work.

But you still need to setup a name of database, this is done with a terminal and command, there is not yet web like configuration page.

To access the ssh in a container, easy way is to go through portainer

Once connect to ssh, type in influx to get into database, then you can use SQL like command to create you database.

But luckily, there is a program: https://github.com/CymaticLabs/InfluxDBStudio

which can do the database things easier. The defaultuser:password of influxDB in IOTstack is : nordred: nodered


Now, back to node red.
To put data into influxDB you have to select the influxDB out
the influxDB in means to get data from influxDB into nodered.
then you have to config the server, the port of influxDB is 8086


Once server set, the measurement is the page where the data is loged.(you can set it here, no need to set this in influxDB) Once first data goes in influxDB, it will create it.
I set the measurement as sensor1, here is how it shows in influxDB
The data format into influxDB is easier then doing Gsheet, influxDB take JSON format, So I use a JSON node to transform string from zigbee2mqtt into JSON and it will work.


[{"id":"35518ae1.8f4fb6","type":"influxdb out","z":"8272628c.f9f93","influxdb":"19546816.cca298","name":"test humid","measurement":"sensor1","precision":"","retentionPolicy":"","x":610,"y":380,"wires":[]},{"id":"874a0011.90e43","type":"json","z":"8272628c.f9f93","name":"","property":"payload","action":"obj","pretty":false,"x":430,"y":380,"wires":[["35518ae1.8f4fb6"]]},{"id":"3e4aa319.6496dc","type":"mqtt in","z":"8272628c.f9f93","name":"temp/humid sensor01","topic":"zigbee2mqtt/0x00158d0003584cba","qos":"2","datatype":"auto","broker":"f2a8ec88.a4f7","x":180,"y":380,"wires":[["874a0011.90e43"]]},{"id":"19546816.cca298","type":"influxdb","hostname":"192.168.0.35","port":"8086","protocol":"http","database":"temphumid","name":"","usetls":false,"tls":""},{"id":"f2a8ec88.a4f7","type":"mqtt-broker","name":"Zigbee2mqtt","broker":"192.168.0.35","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

you can use query function of influxDBstudio to check the data.

Grafana is a dash board like representing tool, it can easily show data average over time, suitable form time base data, such as temp/humid recording.

Once set up database, you can log in Grafana with port:3000 the default password is admin:admin

once login, the first thing to do is the set up the data source. on the left hand side hoving on the configure icon.


you can see there are several type of data source possible, including google and cloud monitoring and AWS CloudWatch, Azure Monitor for mocirsoft.


mine use influxdb, the set up the influxDB address, and user:password(I created another user beside the default one.)


select the data base of influxDB(which we crated).



Save it and we can go to home for adding dash board.

adding new panel
There are plenty things to config,  the basic thing is to indicate the data source(seems you can have multiple data source) and which measurement and field, in my case is sensor1(the measurement we set in the influxDB node form nodered),  

I made 2 queries, one for temp and one for humid.








留言

這個網誌中的熱門文章

Heltec ESP32+OLED+Lora, hardware testing

micro SD card for ESP32, on lolin32 with OLED and heltec 32 lora oled

Install Network Time Protocol(NTP) on BeagleBone with Angstrom linux and set local time zone