Skip to content

Python code to push and pull message into MQTT broker and insert in MogoDB

Notifications You must be signed in to change notification settings

geraudk2000/mqtt_python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MQTT Message Push and Pull with MongoDB Integration

This project focuses on developing a Python code that enables the pushing and pulling of messages into an MQTT broker, while also seamlessly integrating with MongoDB for data storage. The code facilitates communication with an MQTT broker to publish and subscribe to topics, allowing the exchange of messages.

Features

  • MQTT Message Push: The code allows you to publish messages to an MQTT broker by specifying the desired topic and payload. This feature enables seamless communication between MQTT clients.

  • MQTT Message Pull: By subscribing to specific MQTT topics, the code enables the retrieval of messages from the MQTT broker. Subscribed messages can be processed further or stored in a database.

  • MongoDB Integration: The project includes functionality to insert the received MQTT messages into a MongoDB database. This integration allows for persistent storage, retrieval, and analysis of the MQTT message data.

Requirements

Ensure that the following dependencies are installed before running the code:

  • Python (version X.X.X)
  • Paho MQTT library (version X.X.X)
  • PyMongo library (version X.X.X)
  • MongoDB (version X.X.X)

Usage

  1. Clone the repository and navigate to the project directory.

  2. Install the required dependencies using the package manager of your choice or by running pip install -r requirements.txt.

  3. Configure the MQTT broker connection settings in the code, including the broker's IP address, port, username, and password.

  4. Modify the MongoDB connection settings to match your MongoDB server configuration.

  5. Start the Python script, which will establish a connection with the MQTT broker.

  6. Publish messages using the appropriate function, specifying the topic and payload.

  7. Subscribe to specific topics to pull messages from the MQTT broker.

  8. The received messages will be stored in the configured MongoDB database for further processing or analysis.

Notes

  • Ensure that you have a working MQTT broker with the necessary authentication details before using this code.

  • Make sure to set up a MongoDB database and provide the correct connection details to establish a successful connection.

  • Adjust the code as needed to meet your specific project requirements.

License

This project is licensed under the MIT License. Feel free to modify and distribute it as per the license terms.

About

Python code to push and pull message into MQTT broker and insert in MogoDB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published