Skip to content

Instantly share code, notes, and snippets.

@tomovwgti tomovwgti/
Last active Aug 29, 2015

What would you like to do?
MQTT publish
# Copyright (c) 2014 Roger Light <>
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Distribution License v1.0
# which accompanies this distribution.
# The Eclipse Distribution License is available at
# Contributors:
# Roger Light - initial implementation
# This shows an example of using the publish.single helper function.
import sys
import paho.mqtt.publish as publish
except ImportError:
# This part is only required to run the example from within the examples
# directory when the module itself is not installed.
# If you have the module installed, just use "import paho.mqtt.publish"
import os
import inspect
cmd_subfolder = os.path.realpath(os.path.abspath(os.path.join(os.path.split(inspect.getfile( inspect.currentframe() ))[0],"../src")))
if cmd_subfolder not in sys.path:
sys.path.insert(0, cmd_subfolder)
import paho.mqtt.publish as publish
publish.single("message", "Hello MQTT!", hostname="HOST NAME")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.