If you have to save data from a MQTT broker into a mysql database.
This node script connects to the MQTT broker as a client and to the mysql database as a user.
It can subscribe to topics and every time the broker is sending a message it saves it to the mysql database.
Plugin will be in sync with your MQTT Broker and simultaneously will be in connectivity with your DB.
Whenever any activity happens on MQTT Broker it will Stores the Topic and Payload in an array and pass that as a parameter into the connected DB
- move to the directory where you have kepp this plugin
- Just Update the MQTT Broker_URL and Database_URL
- Make Sure you have install all the required packages if not then
- npm install mqtt --save
- npm install mysql-server --save
- npm mqttTOmysql.js
Add a service on the server or start it manually.
Credits to Karan Sharma who wrote the original. I added some minor changes. Contributions welcome!