Lintang Wisesa
Published © GPL3+

Publish Data from Micro:bit v2 to Qubitro IoT Platform

Publish built-in sensors' BBC Micro:bit v2 data to Qubitro IoT platform through MQTT protocol.

BeginnerFull instructions provided2 hours189
Publish Data from Micro:bit v2 to Qubitro IoT Platform

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×1
Grove Shield for micro:bit v2.0
Seeed Studio Grove Shield for micro:bit v2.0
×1
Cytron Technologies Grove WiFi 8266
×1

Software apps and online services

MakeCode
Microsoft MakeCode

Story

Read more

Schematics

(Micro:bit + Grove WiFi 8266) x Qubitro

Publish sensor readings from BBC Micro:bit to Qubitro IoT platform

Code

Micro:bit x Qubitro (JavaScript)

JavaScript
Publish sensor readings from BBC Micro:bit to Qubitro IoT platform
basic.showIcon(IconNames.Heart)
ESP8266_IoT.initWIFI(SerialPin.P16, SerialPin.P2, BaudRate.BaudRate115200)
ESP8266_IoT.connectWifi("your_ssid", "your_pwd")

basic.forever(function () {
    ESP8266_IoT.setMQTT(
    ESP8266_IoT.SchemeList.TCP,
    "YOUR_QUBITRO_DEVICE_ID",
    "YOUR_QUBITRO_DEVICE_ID",
    "YOUR_QUBITRO_DEVICE_TOKEN",
    ""
    )
    ESP8266_IoT.connectMQTT("broker.qubitro.com", 1883, false)
    ESP8266_IoT.publishMqttMessage("{\\\"temperature\\\":" + input.temperature() + "}", "YOUR_QUBITRO_DEVICE_ID", ESP8266_IoT.QosList.Qos0)
    basic.pause(5000)
})

Micro:bit x Qubitro (Python)

Python
Publish sensor readings from BBC Micro:bit to Qubitro IoT platform
basic.show_icon(IconNames.HEART)
ESP8266_IoT.init_wifi(SerialPin.P16, SerialPin.P2, BaudRate.BAUD_RATE115200)
ESP8266_IoT.connect_wifi("your_ssid", "your_pwd")

def on_forever():
    ESP8266_IoT.set_mqtt(ESP8266_IoT.SchemeList.TCP,
        "YOUR_QUBITRO_DEVICE_ID",
        "YOUR_QUBITRO_DEVICE_ID",
        "YOUR_QUBITRO_DEVICE_TOKEN",
        "")
    ESP8266_IoT.connect_mqtt("broker.qubitro.com", 1883, False)
    ESP8266_IoT.publish_mqtt_message("{\\\"temperature\\\":" + str(input.temperature()) + "}",
        "YOUR_QUBITRO_DEVICE_ID",
        ESP8266_IoT.QosList.QOS0)
    basic.pause(5000)
basic.forever(on_forever)

Credits

Lintang Wisesa

Lintang Wisesa

21 projects • 84 followers
🍔 Full Snack Develaper

Comments

Add projectSign up / LoginAbout BBC micro:bit