Skip to content

Commit

Permalink
mqtt example over wifi
Browse files Browse the repository at this point in the history
  • Loading branch information
varna9000 committed Oct 13, 2022
1 parent 6bc6602 commit ee2aabc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions extras/mqtt_publish_wifi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from umqtt.simple import MQTTClient

def do_connect():
import network
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print('connecting to network...')
sta_if.active(True)
sta_if.connect('ssid', 'password')
while not sta_if.isconnected():
pass
print('network config:', sta_if.ifconfig())



do_connect()

c = MQTTClient("varnalab_client","broker.hivemq.com")

c.connect()
c.publish(b"varnalab", b"здрасти")
c.disconnect()

0 comments on commit ee2aabc

Please sign in to comment.