People used to regard mobile phones, TVs or routers as the control centers of smart homes until the emergence of smart speakers. It should be that you control your smart devices just by saying a sentence such as "Open the light of living room", rather than by clicking on the phone screen. Now, there are so many smart speakers in market for controlling the smart device, two of the most famous are Google Home from Google and Echo from Amazon. In China, the most famous smart speaker are XiaoAi from XiaoMi and Tmall Genie from Alibaba. Now, all of these companies have developed IoT platform so that the manufacturer who produce smart homes can connect their smart productions to these smart speakers. This project is intended to introduce how to control a Silicon Labs Wi-Fi device.with TmallGenie.
The software architecture of project consists of:
The hardware consists of :
User can control the LED0 in EFM32GG11 STK through one of two methods below.
We assume the whole device combine the EFM32GG11 STK and the WGM110 module is a smart light. The block is illustrated below.
Connect the boards as illustrated in the picture below. Configure the EFM32GG11 STK board switch as AEM and configure the WGM110 Expansion Kit switch as High Power.
Import the firmware to Simplicity Studio, open file "app_wifi_cfg.h", modify the macro APP_WIFI_AP_SSID to your Wi-Fi SSID and modify APP_WIFI_AP_PWD to your Wi-Fi password, as the picture shown below. Then compile it. Program the Hex file to EFM32GG11 Giant Gecko Starter Kit (SLSTK3701A) to make it as a smart light device. The compiled firmware is located directory Bin/, the default Wi-Fi SSID is "netis_1F7506" and the password is "password", if you want to recompile the firmware you can configure your Wi-Fi.
When the firmware is runing for the first time, it needs to report itself to silabs-iot. It will issue a http request to silabs-iot so that web server of silabs-iot will add information of the device to database, then the device can been used by one of users.
You need to bind the device and declare it belongs to you then you can control it. Please follow to the steps below to bind a device.
After binding your device, you can see it on the MyDevice page. click the device and will pop up a window on which there is a switch, you can turn on/off the LED just by click the switch.
At first, you need to download a Tmall Genie App into your phone and bind your Tmall Genie following the hint of Tmall Genie App. Please follow to the steps below to bind Silabs-iot with Tmall Genie.
Now, you can control the device just by talking to Tmall Genie, such as "天猫精灵，开灯" ("Tmall Genie, Open Light Please"). The video attached demonstrate how to control the device with Tmall Genie by voice.
Note: The Tmall Genie only supports Chinese and it supports turn on/off and query on this case.
The web server of silabs-iot is developed with ThinkPHP5.1, ThinkPHP is a free, open source, fast and simple object-oriented PHP development framework for web application development, visit it from https://www.kancloud.cn/manual/thinkphp5_1/353946.
The following image illustrates the processes of communication among the web server of user, Tmall Genie, silabs-iot, alibaba web server and device.
The authorization protocol between them is based on OAuth2.0. OAuth2.0 is an open protocol to allow secure authorization in a simple and standard method from web, mobile and desktop applications, get more details from https://oauth.net/2/ . The OAuth2.0 server on this case is based on the library from Brent Shaffer, download it from GitHub: https://github.com/bshaffer/oauth2-server-php. The process is divided into the following steps, as the picture shown below.
The communication between devices and web server is based on Http protocol. The device need to visit web server periodic so that it can update the LED0 once the Tmall Genie change the state of light.