Вы находитесь на странице: 1из 7

NODE RED

untuk install nodes mysql dan dashboard dan postgre

manage pallate > install node

INSTALL
https://www.digitalocean.com/community/tutorials/how-to-connect-your-internet-of-things-
with-node-red-on-ubuntu-16-04

SQL :

SELECT min(nilai), MAX(nilai), minute(waktu) FROM `sensor` WHERE


`topic` = 'trans01/temperature' GROUP BY MINUTE(waktu)

INI UNTUK MASALAH CHART JSON YANG TIDAK MUNCUL

Step 3: Diagnosis # Step 3: Diagnosis


Now that you know which browsers you are experiencing issues in you can start to diagnose the
issue.

Firefox # Firefox
1. Open the Console
Go to the screen where you are experiencing the error. In Firefox, navigate to Tools > Web
Developer > Error Console or press Ctrl + Shift + J.
2. Identify the Error
The error console will open. If you don’t see any errors try reloading the page. The error may be
generated when the page loads.
The console will provide you with the error type, the location of the error and the line number
The image above shows the error to be in jquery.js on line 2.

MASALAH GROUP BY DAK BISA

Type: sudo vi /etc/mysql/my.cnf


type A to enter insert mode
In the last line paste below two line code:
[mysqld]
sql_mode =
STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_A
UTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Type esc to exit input mode

https://github.com/mysqljs/mysql

Log MQTT to MySQL


Logs all or selected MQTT activity to a MySQL database.
By default logs everything - change the topic in the MQTT node to be more selective (e.g.
"my\path#" or "my\topic")
MySQL table needs the following columns:
• id (integer, autoincrement) (optional)
• timestamp (date-time)
• topic (string 200)
• data (string 200)

Requires node-red-node-mysql and configuration of your MQTT and MySQL server details
[{"id":"a06d74db.919808","type":"mqtt
in","z":"b194ff77.b24e2","name":"","topic":"#","qos":"2","broker":"","x":210,"y"
:460,"wires":[["98201759.e4d558"]]},
{"id":"6825dd23.d4ee44","type":"debug","z":"b194ff77.b24e2","name":"","active":t
rue,"console":"false","complete":"true","x":610,"y":420,"wires":[]},
{"id":"98201759.e4d558","type":"function","z":"b194ff77.b24e2","name":"Create
query in topic","func":"var out = \"INSERT INTO tcl_mqtt_log
(timestamp,topic,data)\"\nout = out + \"VALUES ('\" + new Date().toISOString() +
\"','\" \nout = out + msg.topic + \"','\" + msg.payload + \"');\"\n
\nmsg.topic=out;\n\nreturn msg;","outputs":1,"noerr":0,"x":400,"y":460,"wires":
[["6825dd23.d4ee44","ddb3e588.199508"]]},
{"id":"be41a506.f7f9f8","type":"comment","z":"b194ff77.b24e2","name":"Log
everything","info":"","x":200,"y":420,"wires":[]},
{"id":"4265dd53.5b18a4","type":"debug","z":"b194ff77.b24e2","name":"","active":t
rue,"console":"false","complete":"false","x":750,"y":460,"wires":[]},
{"id":"ddb3e588.199508","type":"mysql","z":"b194ff77.b24e2","name":"","x":610,"y
":460,"wires":[["4265dd53.5b18a4"]]}]

node-red-contrib-postgres-multi 0.2.0
A Node-RED node to query PostgreSql, with multi-query support
npm install node-red-contrib-postgres-multi

node-red-contrib-postgres-multi
A Node-RED node to query PostgreSQL, with multiple query support.
Based on node-red-contrib-postgres by Kris Daniels.
Ini orinyo
var out = "INSERT INTO `sensor-nodered` ( `waktu`, `topic`, `nilai`))"
out = out + "VALUES ('" + new Date().toISOString() + "','"
out = out + msg.topic + "','" + msg.payload + "');"

msg.topic=out;

return msg;

YANG DI PERBAHARUI

var out = "INSERT INTO `sensorruby` ( `topic`, `nilai`) "


out = out + "VALUES ('"
out = out + msg.topic + "','" + msg.payload + "');"
msg.topic=out;

return msg;

PASSWORD POSTGREE : S1hCTgJTHz

BELAJAR NODERED :

http://noderedguide.com/tutorial-sqlite-and-node-red/

Ini buat ambil data dari internet , scrapping mmudah

http://noderedguide.com/node-red-lecture-6-intermediate-flows-2/

FRONT END NODERED

If you want to create your own front end for Node-RED the best place for you to start would be the
ui-builder project https://www.npmjs.com/package/node-red-contrib-uibuilder 207

MySQL Connection Pool Manager


Greenkeeper enabled license scan passing

build passing dependencies up to date devDependencies up to date

This is a production level Node.JS mySQL connection pool wrapper powered by mysqljs/mysql.

Summary
This module allows for intelligent management & load balancing of mySQL connection pools. It is
written in JavaScript, does not require compiling, and is MIT licensed. Its designed to be used by
persistent and self-terminating processes.

UNTUK RUNNING BACKGROUND AUTOMATIC

Using PM2
PM2 is a process manager for Node.js. It makes it easy to run applications on boot and ensure they
are restarted if necessary.
1. Install PM2
sudo npm install -g pm2

Note : sudo is required if running as a non-root user on Linux or OS X. If running on Windows,


you will need to run in a command shell as Administrator, without the sudo command.
If running on Windows, you should also ensure tail.exe is on your path, as described here.

2. Determine the exact location of the node-red command.


If you have done a global install of node-red, then on Linux/OS X the node-red command will
probably be either: /usr/bin/node-red or /usr/local/bin/node-red. The command
which node-red can be used to confirm the location.

If you have done a local install, it will be node_modules/node-red/bin/node-red,


relative to where you ran npm install from.

3. Tell PM2 to run Node-RED


The following command tells PM2 to run Node-RED, assuming /usr/bin/node-red as the
location of the node-red command.

The -- argument must appear before any arguments you want to pass to node-red.
pm2 start /usr/bin/node-red -- -v

Note : if you are running on a device like the Raspberry Pi or BeagleBone Black that have a
constrained amount of memory, you must pass an additional argument:
pm2 start /usr/bin/node-red --node-args="--max-old-space-size=128" -- -v

Note : if you want to run as the root user, you must use the `--userDir` option to specify where
Node-RED should store your data.
This will start Node-RED in the background. You can view information about the process and
access the log output using the commands:
pm2 info node-red
pm2 logs node-red

More information about managing processes under PM2 is available here.

4. Tell PM2 to run on boot


PM2 is able to generate and configure a startup script suitable for the platform it is being run on.
Run these commands and follow the instructions it provides:
pm2 save
pm2 startup

for newer Linux systems that use systemd use


pm2 startup systemd
Temporary Note: There's an open issue on PM2 on GitHub which highlights an issue that has been
introduced recently. Linux users need to manually edit the generated `/etc/init.d/pm2-init.sh` file
and replace
export PM2_HOME="/root/.pm2"

to point at the correct directory, which would be like:


export PM2_HOME="/home/{youruser}/.pm2"

5. Reboot
Finally, reboot and check everything starts as expected.
UNTUK CEK STATUS NODE-RED :
https://app.pm2.io/bucket/5d76e778d4f97908835c60fb/backend/overview/servers

https://nodered.org/docs/faq/starting-node-red-on-boot

pm2 monitor

indrawataw@gmail.com ApoDioBos password

UNTUK FIREWALL
SUPAYA BISA DI AKSES DARI WEBSITE

sudo ufw allow 1880

Enable the FirewallPermalink


With your chosen rules in place, your initial run of ufw status will probably output Status:
inactive. To enable UFW and enforce your firewall rules:
sudo ufw enable

Similarly, to disable UFW’s rules:


sudo ufw disable

UFW StatusPermalink
You can check the status of UFW at any time with the command: sudo ufw status. This will
show a list of all rules, and whether or not UFW is active:

Вам также может понравиться