Approved content

The content below is provided by a partner.

SMARTHON/pxt-iot-bit 0.8.3 GitHub

Smarthon-iotbit

A MakeCode extension for Smarthon IoT:bit

About Smarthon IoT:bit

Smarthon IoT:bit enables micro:bit to connect Wi-Fi and allows users to record sensor data on cloud platforms like IFTTT and ThingSpeak. Besides, the great feature is supporting WAN control.
The users can connect up to 12 sensors and actuators. Let’s upgrade your micro:bit and ready for the IoT world!

You may check the product information by https://www.smarthon.cc/product-page/iot-bit-iot-expansion-board-for-micro-bit

You may check the Read the Docs about Smarthon IoT:bit here: https://smarthon-docs-en.readthedocs.io/en/latest/IoTbit/index.html

Function Tutorial

1. Initialize the Smarthon IoT:bit

Configurate the connection between IoT:bit and Micro:bit via Serial protocol

Default setting for Connection pins on IoT:bit is P16(TX) and P8(RX)

smarthonIoTBit.initializeWifi(SerialPin.P16, SerialPin.P8)

2. Connect to Wifi Station

Connect to the specific Wifi Station by SSID and Password

In example,
SSID:Smarthon
Password:12345678

smarthonIoTBit.setWifi("Smarthon", "12345678")

3. Upload data to Thingspeak

Upload the value data to the specific Thingspeak channel.

Required to input vaild channel API key. Allow sending up to 8 value field at the same time.

In example,
channel API key: abcdefg
field1 value:100
field2 value:0

smarthonIoTBit.sendThingspeak(
"abcdefg",
100,
0
)

4. Upload IFTTT Request

Summit a request to IFTTT Webhooks Service.

Required to input vaild API key provided by webhooks.

In example,
API key: abcdefg
event:email
value:10

smarthonIoTBit.sendIFTTT(
"abcdefg",
"email",
10
)

5. WiFi WAN Control

The IoT:bit can recevied command via internet
Before control the IoT:bit, you need an ID to identify the IoT:bit on the internet.

Use the getDeviceID to show the ID

basic.showString(smarthonIoTBit.getDeviceID())

You are required to set up the callback function to get the command message when the the command was received.
The WAN_Command variable can be access and use to make decision.

smarthonIoTBit.onWANRemote(function (WAN_Command) {

})

6. Channel communication

Connect to a specifc channel to prepare for listen other user’s message

smarthonIoTBit.WifiListenChannel("abc")

To listen the message, you are required to set up this callback block to get the variable

smarthonIoTBit.onWifiReceived(function (Channel, receivedMessage) {
})

Sending the message to other user in the specific channel

smarthonIoTBit.WifiSendMessage("abc", "hi")

7. NTP time

Get the NTP time from the internet

smarthonIoTBit.getNTP(smarthonIoTBit.CityList.HongKong)

To make use of the time, you are required to set up this callback block to get the variable

smarthonIoTBit.onNTPReceived(function (Year, Month, Day, Hour, Minute, Second) {
})

License

MIT

Supported targets

(The metadata above is needed for package search.)

smarthon-iotbit=github:SMARTHON/pxt-iot-bit#v0.8.3