Rajbir Singh
Published © GPL3+

Wireless Sensor Using Node-RED to MySQL

Sending NCD IoT Wireless Long-Range Vibration and Temperature Sensor to MySQL using Node-RED.

IntermediateProtip2 hours250
Wireless Sensor Using Node-RED to MySQL

Things used in this project

Hardware components

National Control Devices Wireless Vibration and Temperature Sensor
×1
National Control Devices 900HP-S3B Long Range Wireless Mesh Modem with USB Interface
×1

Software apps and online services

Node-red
XAMPP

Story

Read more

Code

Node-RED Flow

JSON
[{"id":"ab91f6eb.240f38","type":"tab","label":"Flow 9","disabled":false,"info":""},{"id":"5dd41f6d.915ab","type":"ncd-gateway-node","z":"ab91f6eb.240f38","name":"","connection":"8cca9788.ffe138","x":130,"y":80,"wires":[["12e691e.ab6976e"]]},{"id":"d22c7a49.01a578","type":"ncd-wireless-node","z":"ab91f6eb.240f38","name":"","connection":"1eb93cb8.033cb3","config_comm":"cb5cdf57.475f9","addr":"","sensor_type":"8","auto_config":"","node_id":0,"delay":300,"destination":"0000FFFF","power":4,"retries":10,"pan_id":"7FFF","change_enabled":"","change_pr":"0","change_interval":"0","cm_calibration":"60.6","bp_altitude":"0","bp_pressure":"0","bp_temp_prec":"0","bp_press_prec":"0","amgt_accel":"0","amgt_mag":"0","amgt_gyro":"0","impact_accel":"0","impact_data_rate":"4","impact_threshold":25,"impact_duration":1,"activ_interr_x":1,"activ_interr_y":2,"activ_interr_z":4,"activ_interr_op":8,"filtering":0,"data_rate":5,"time_series":0,"reading_type":1,"x":80,"y":240,"wires":[["6963b687.e08fd8","5ddf132d.818fbc"]]},{"id":"12e691e.ab6976e","type":"debug","z":"ab91f6eb.240f38","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":410,"y":80,"wires":[]},{"id":"6963b687.e08fd8","type":"debug","z":"ab91f6eb.240f38","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":260,"y":400,"wires":[]},{"id":"5ddf132d.818fbc","type":"function","z":"ab91f6eb.240f38","name":"MySQL Function","func":"rms_x = msg.payload.rms_x\nrms_y = msg.payload.rms_y\nrms_z = msg.payload.rms_z\nmax_x = msg.payload.max_x\nmax_y = msg.payload.max_y\nmax_z = msg.payload.max_z\nmin_x = msg.payload.min_x\nmin_y = msg.payload.min_y\nmin_z = msg.payload.min_z\ntemperature = msg.payload.temperature\nmsg.topic = \"INSERT INTO vibration_temperature ( `rms_x`, `rms_y`, `rms_z`, `max_x`, `max_y`, `max_z`, `min_x`, `min_y`, `min_z`, `temperature`) VALUES ( \"+ rms_x +\", \"+ rms_y +\", \"+ rms_z +\", \"+ max_x +\", \"+ max_y +\", \"+ max_z +\", \"+ min_x +\", \"+ min_y +\", \"+ min_z +\", \"+ temperature +\");\"\nreturn msg;","outputs":1,"noerr":0,"x":370,"y":240,"wires":[["4d7967a3.5510a8"]]},{"id":"4d7967a3.5510a8","type":"mysql","z":"ab91f6eb.240f38","mydb":"4bd6fc82.510b44","name":"MySQLDatabase","x":700,"y":240,"wires":[[]]},{"id":"8cca9788.ffe138","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false},{"id":"1eb93cb8.033cb3","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false},{"id":"cb5cdf57.475f9","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false},{"id":"4bd6fc82.510b44","type":"MySQLdatabase","z":"","host":"127.0.0.1","port":"3306","db":"rjdatabase","tz":"GMT +5:30"}]

Credits

Rajbir Singh

Rajbir Singh

19 projects • 4 followers
A skilled developer with experience of extensive development in the Internet of Things (IoT).

Comments