BIGIOT

BIGIOT is an IoT cloud platform that makes it more convenient for you to communicate with smart devices. Through the Internet, you can chat with your smart devices and send commands in the form of conversations, remote controls, etc., view real-time data, set alarm conditions according to actual needs, and notify users through APP, email, SMS, Weibo, WeChat, and other means.

../../../../../../_images/1540363897144665.jpg

BIGIOT architecture

Connecting the mPython Board to BIGIOT

Preparation

Device Communication

bigiot simple communication example:
 1from mpython import *
 2import bigiot
 3
 4my_wifi = wifi()
 5my_wifi.connectWiFi("youruser", "yourpassword")
 6
 7ID = ""                             # Device ID
 8API_KEY = ""                        # Device API KEY
 9
10
11
12def say_cb(msg):                    # Callback function
13    print(msg)
14    oled.DispChar("%s,%s" %(msg[0],msg[1]),0,10)    # Display on the OLED
15    oled.show()
16    oled.fill(0)
17
18
19device = bigiot.Device(ID, API_KEY)         # Build a bigiot device
20
21device.say_callback(say_cb)                 # Set the callback function for say communication
22
23device.check_in()                           # Log in

Before connecting to the BIGIOT platform, you need to ensure that the mPython Board is connected to the Internet. When instantiating the device Device(id,api_key), the BIGIOT smart device information ID and API KEY are used. Set the callback function say_callback(f) for say communication. In the f(msg,id,name) callback function, the msg parameter is the received message, the id parameter is the sending device ID, and the name parameter is the device name. check_in() is the device online function, and you can see the device’s connection status on the BIGIOT platform. In the above example, the callback function is set and the data received by say communication is printed out.

Client Sending Messages to the mPython Board

BIGIOT supports communication between multiple clients and devices, such as browsers, WeChat mini programs and official accounts, and APP (Android).

../../../../../../_images/bigiot_1.gif

Browser

../../../../../../_images/bigiot_2.gif

WeChat mini program

mPython Board Sending to Devices or Clients

Device

You can add multiple smart devices on the BIGIOT platform at the same time. As long as the smart device is online and you know the device’s ID, you can send messages to the smart device.

Send a message to the device with ID: 7947:

>>> device.say(device_id = 7947, msg = 'hello I am mPython')

Client

To send a message to the web or WeChat clients, you can view your user ID in the platform’s “Personal Information”:

>>> device.say(user_id = 5600, msg = 'hello I am mPython')

Group

You can also set up multiple smart devices into a group on the platform and send messages to the group. This way, all members of the group can receive the message, similar to the IP multicast function:

>>> device.say(group_id = 145, msg = 'hello I am mPython')

say(user_id, group_id, device_id, msg) This function is used for conversations with devices or clients. The user_id, group_id, and device_id parameters are the user ID, group ID, and device ID respectively. Select the parameters to use according to the conversation object. msg is the conversation message, of type string.

Sending Data to the Interface

Send the light data of the mPython Board to interface: 9564:

while True:
    val=light.read()
    device.update(9564,str(val))
    sleep(1)

BIGIOT provides interfaces for collecting real-time sensor data and plotting charts. update(id, data) is the data upload function. id is the interface ID, and the data parameter is the uploaded sensor data. Note that this type is a string. If it is an int, it needs to be converted to str. Also, data should not be sent too fast, with an interval of at least 1 second or more.

Voice Assistant

BIGIOT can also connect to Tmall Genie and Baidu Voice Assistant, with BIGIOT devices acting as clients. They receive voice commands sent from the server, enabling the application of voice control of smart homes.

Method for Tmall Genie to Bind and Control BIGIOT Devices

For the Tmall Genie binding method, refer to the tutorial: https://www.bigiot.net/talk/359.html