###### tags: `iot` `hw` `thu` {%hackmd theme-dark %} # IOT-HW3 ## IMAGES 1. Use CLI to send message:  2. Use python code to send message:  ## CODE ``` python import paho.mqtt.client as paho message = "------------------------------\nTesting MQTT Server in Python.\n------------------------------" broker="152.70.108.105" port=1883 def on_publish(client,userdata,result): #create function for callback print("Data published successfully! \n") pass client1= paho.Client("MQTT Tester") #create client object client1.on_publish = on_publish #assign callback function client1.connect(broker,port) #establish connection ret= client1.publish("test/mqtt", message) #publish message ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up