Commit 35351caf by mohammed.shibili

test producer

parent 9bc6a85a
import paho.mqtt.client as mqtt
import json
# Define the dictionary you want to publish
data = {
"silver": [4, 5, 6]
}
# Convert the dictionary to a JSON string
payload = json.dumps(data)
# Define the MQTT topic you want to publish to
topic = "ticket2/silver"
# Define the MQTT broker address
broker_address = "192.168.0.220"
# Create a new MQTT client instance
client = mqtt.Client("dict_publisher")
# Connect to the MQTT broker
client.connect(broker_address)
# Publish the JSON string to the MQTT topic
client.publish(topic, payload)
# Disconnect from the MQTT broker
client.disconnect()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment