Created
November 29, 2019 11:50
-
-
Save raucao/1d25af83fae68cc2f7a89c322ba8bcdc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import board | |
import adafruit_dht | |
import paho.mqtt.publish as publish | |
dhtDevice = adafruit_dht.DHT11(board.D14) | |
broker_address = "192.168.2.52" | |
port = 1883 | |
client_id = "python" | |
username = "foo" | |
password = "bar" | |
temperature = dhtDevice.temperature | |
humidity = dhtDevice.humidity | |
publish.single("home/data_center/temperature", payload=temperature, | |
hostname=broker_address, port=port, | |
client_id=client_id, tls=None, | |
auth={"username": username, "password": password}) | |
publish.single("home/data_center/humidity", payload=humidity, | |
hostname=broker_address, port=port, | |
client_id=client_id, tls=None, | |
auth={"username": username, "password": password}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment