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. .. figure:: /_static/external/1540363897144665.jpg :width: 550 :align: center BIGIOT architecture - BIGIOT platform communication protocol: https://www.bigiot.net/help/1.html Connecting the mPython Board to BIGIOT -------------------------------------- Preparation +++++++++++++++++++++ * Before use, you need to register an account at BIGIOT https://www.bigiot.net and add smart devices. * In the program, you need to use the bigiot mPython library, which you can get from https://github.com/labplus-cn/awesome-mpython/tree/master/library. Upload bigiot.py to the file system. Device Communication ++++++++++++++++++++++++ .. literalinclude:: /_static/products/ledong-v2/_static/examples/IoT/bigiot.py :caption: bigiot simple communication example:: :linenos: 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). .. figure:: /_static/products/ledong-v2/_static/image/tutorials/IoT/bigiot_1.gif :align: center Browser .. figure:: /_static/products/ledong-v2/_static/image/tutorials/IoT/bigiot_2.gif :align: center :width: 500 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