Connect ESP32 to Qubitro with MicroPython

Things that you need:

Let’s Install MicroPython on Rak11200:

Thonny IDE web page
Micropython Firmware
esptool package on Thonny
Select Interpreter Tab
Firmware install window

Programming:

Open device page
import time
import network
import machine as m
sta_if = network.WLAN(network.STA_IF); sta_if.active(True)
sta_if.scan() # Scan for available access points
sta_if.connect("SSID", "password") # Connect to an AP
sta_if.isconnected()
time.sleep(3)
from umqtt.robust import MQTTClient
import machine as m
from machine import Pin
led0=Pin(12,Pin.OUT)
led1=Pin(2,Pin.OUT)
DeviceID = ""
DeviceToken =""
client = MQTTClient(DeviceID, "broker.qubitro.com", 1883, user = DeviceID, password = DeviceToken)def checkwifi():while not sta_if.isconnected():
time.sleep_ms(500)
print(".")
sta_if.connect()
def publish():
checkwifi()
client.connect()
while True:

msg = b'{"Latitude": 72.7661 ,"Langitude": 337.7772, "Temperature": 27, "Humidity": 76}'
print(msg)
led1.value(1)
time.sleep(5)
led1.value(0)
client.publish(DeviceID, msg)
led0.value(1)
time.sleep(5)
led0.value(0)

publish()
Rak11200 data in Qubitro Portal

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Qubitro

Qubitro

Infrastructure for the Internet of Things solutions. Build connected solutions faster than ever.