'''
example name：MQTT communication (publish)
version：v1.0
date：2020.3
Author：01Studio
Forum: forum.01studio.org
'''

import paho.mqtt.client as mqtt
import time

#Server and subject information
host = 'mqtt.p2hp.com'
port = 1883
topic = '/public/01Studio/1'

#Build mqtt client object
client = mqtt.Client()

#Initiate a connection
client.connect(host,port)

while True:

    #Publish message
    client.publish(topic,'Hello 01Studio!')

    time.sleep(1) #Send interval 1 second
