Hackster is hosting Hackster Holidays, Ep. 5: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 5 on Friday!
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 hours861
Publish Data from Micro:bit v2 to Qubitro IoT Platform

Things used in this project

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 β€’ 92 followers
πŸ” Full Snack Develaper

Comments