smart light solution introduction -...

17
s Espressif Smart Light Solution Introduction Version 0.5 Espressif Systems IOT Team http://bbs.espressif.com Copyright © 2016

Upload: lykien

Post on 08-Sep-2018

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

s

Espressif Smart Light Solution

Introduction

Version 0.5

Espressif Systems IOT Team

http://bbs.espressif.com

Copyright © 2016

Page 2: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

Disclaimer and Copyright Notice Information in this document, including URL references, is subject to change without notice.

THIS DOCUMENT IS PROVIDED AS IS WITH NO WARRANTIES WHATSOEVER, INCLUDING ANY

WARRANTY OF MERCHANTABILITY, NON-INFRINGEMENT, FITNESS FOR ANY PARTICULAR

PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION

OR SAMPLE. All liability, including liability for infringement of any proprietary rights, relating to use of information in this document is disclaimed. No licenses express or implied, by estoppel or

otherwise, to any intellectual property rights are granted herein.

The Wi - Fi Alliance Member Logo is a trademark of the Wi - Fi Alliance.

All trade names, trademarks and registered trademarks mentioned in this document are property of their respective owners, and are hereby acknowledged.

Copyright © 2016 Espressif. All rights reserved.

Confidential

Page 3: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

1. Introduction 1................................................................................................................1.1. Preamble 1 .............................................................................................................................................

1.2. ESP-Mesh 1 ...........................................................................................................................................

1.3. ESP-Touch 1 ..........................................................................................................................................

1.4. ESP-Now 1 .............................................................................................................................................

1.5. IOT Espressif App 2 ............................................................................................................................

2. ESP Smart Light Solution 1............................................................................................2.1. Mesh network level 2 ........................................................................................................................

2.2. Local and cloud mesh 2 ...................................................................................................................

2.2.1. Local device 2 ..................................................................................................................................

2.2.2. Cloud device 3 .................................................................................................................................

3. Configuring The Mesh 4.................................................................................................3.1. Overview 4 ............................................................................................................................................

3.2. Preparing the hardware 4 .................................................................................................................

3.3. Configure the devices 4 ....................................................................................................................

3.3.1. Initializing the devices 4 ...............................................................................................................

3.3.2. Adding a device 4 ...........................................................................................................................

3.4. Configure the ESP-NOW Controller Device (The Button) 7 ..................................................

3.4.1. Pairing ESP-NOW Controller Device with Smart Light 7 ....................................................

3.4.2. Begin to pair 7 ..................................................................................................................................

3.5. Operating the devices 8 ....................................................................................................................

3.5.1. Using the IOT App 8 ......................................................................................................................

3.5.2. Configuring the Controller Device's Functions 9 ..................................................................

4. Some Reference 11........................................................................................................4.1. FlowChart of ESP Smart Light 11 ....................................................................................................

4.2. Debug Mode 11 ...................................................................................................................................

4.3. SDK Download 12................................................................................................................................

Table of Contents

Confidential

Page 4: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

Introduction

1. Introduction

1.1. Preamble

In this document, we discuss the use of 4 different protocols developed by Espressif: ESP-Mesh, ESP-Touch, ESP-NOW and ESP-PAIR. These protocols are based on WiFi and works to augment the features

of the WiFi standard to provide features that are beyond the traditional sending of TCP/IP packets to the Internet.

In short, ESP protocols are designed for home automation, and as they are based on the WiFi standard,

they have the advantages of speed, and not interfering or being interfered by other WiFi networks. As such, by using ESP protocols, we can avoid complex wireless coexistence issues that arise when

different protocols work in the same frequency band, and mutually interfere with one another.

ESP protocols, based on WiFi, inherits the CSMA (Carrier Sensing Multiple Access) protocol, to avoid collision with other WiFi networks, and to sniff for the best opportunity to send the data packet when

the frequency band is empty. This also helps to reduce network latency and improve data rate and performance.

1.2. ESP-Mesh

With the increasing popularity of the Internet of Things and home automation devices, there is a trend to have more and more WiFi devices in the the application scenario. However, due to the limited

number of nodes that can be directly connected to one router (usually no more than 32 with many mid to low end router), it is sometimes not possible connect all nodes to the same router. The two possible

solutions are:

• Using a better router or multiple routers: we can increase the capacity of the routers, so that more nodes can be directly connected to the router or routers.

• Using a mesh network: the nodes establish a network independently and forward the packets. There are many different types of possible mesh network, using different types of protocols such

as Bluetooth mesh, Zigbee, ZWave, LORA, 6LoWPAN, etc. Espressif's approach is an implementation of a mesh network using a modified WiFi protocol with the capacity to connect about 100 devices.

1.3. ESP-Touch

ESP-Touch is a protocol developed by Espressif, to configure the Wi-Fi devices to connect to the router.

The device can be configured by ESP-Touch only when it is in the smart config mode. For details of the

configuration procedure, refer to 3. Configure your mesh devices.

1.4. ESP-Now

ESP-Now is another protocol developed by Espressif to enable multiple devices to communicate in the

absence of or without using Wi-Fi. The protocol is akin to the low power 2.4GHz wireless connectivity

Espressif Systems / 2016.011 2

Confidential

Page 5: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

Introduction

that is often deployed in wireless mice — the pairing between devices are needed prior to the communication, but once setup, it is persistent, the communication is peer to peer and no further

handshake is required to setup communication.

With ESP-Now, the user can implement very low power controller devices to communicate with client devices; such controller devices could have battery life of several years.

1.5. IOT Espressif App

IOT Espressif App (hereinafter referred to as the IOT app) is Espressif's template smartphone

application. It implements local and remote control of Wi-Fi devices, including smart lights and smart plugs. The app is open-source, and can be downloaded from Github.

Espressif Systems / 2016.012 2

Confidential

Page 6: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

ESP Smart Light Solution

2. ESP Smart Light Solution

ESP Smart light Solution (ESPSS) uses ESP-Mesh protocol, to reduce the loading of smart light devices

on the router. A possible scenario is where the user uses the mobile App (IOT App) to add devices (smart lights) to a mesh network with the ESP-Touch protocol, and then use the remote controller with

the ESP-Now protocol to control all these lights at the same time.

Root device The top node device in a mesh network.

Leaf device A node device with no children.

Parent device The converse notion of Child device.

Espressif Systems / 2016.011 12

Button

Router

Mobile App

Root device

Parent device

Leaf device

Child device

ESP-Now

ESP-Mesh

ESP-Touch

Leaf device

Confidential

Page 7: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

ESP Smart Light Solution

2.1. Mesh network level

The structure of the mesh network is shown in the figure below. The level of a device is defined by 1 +

(the number of connections between the device and the root device). For root device, the level is 1. Currently the mesh network can support at least 5 levels of the devices.

2.2. Local and cloud mesh

2.2.1. Local device If a device is configured to the router by ESP-Touch, but not activated on the server-end, it is a local device, as shown in the figure below. Such a device is accessible over WiFi when the mobile App is on the WiFi network, but not over the cloud platform.

Note:

Mesh Level: you can set mesh’s level by configuring the mesh API:

espconn_mesh_set_max_hops(uint8 max_hops);

Espressif Systems / 2016.012 12

Router

Dev2-1

Dev����

Dev����

Dev 2-2

Dev����

Dev����

Dev 2-3

Dev����

Dev����

��

��

��

RootLevel 1: White

Level 2: Red

Level 3: Green

Level 4: Blue

Confidential

Page 8: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

ESP Smart Light Solution

2.2.2. Cloud device In below situations,a device will be activated on the server-end and become a cloud device:

• The device is connected directly to a router by ESP-TOUCH.

• If a device joins in a mesh,when the mesh root communicates with server, the new-added device can also become an online cloud device.

There are three possible connection status, as shown below:

• Connected to cloud,

• Connected to local Wi-Fi but not connected to cloud, or

• Offline

Espressif Systems / 2016.013 12

Confidential

Page 9: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

Configuring The Mesh

3. Configuring The Mesh

3.1. Overview

You can use the ESP Touch function of the IOT app to configure the mesh device. The process is shown in the figure below.

3.2. Preparing the hardware

The following hardware devices are needed.

3.3. Configure the devices

3.3.1. Initializing the devices If you want to operate the devices with the IOT App, you may have to initialize them first.

• Setup your first mesh device as a mesh root. Turn on the light, if it is not configured before, it will firstly scan the existing mesh networks with the same SSID_PREFIX and GROUP_ID

as its own. If there is not available mesh in air, it will check the ROUTER recording history and try to connect the previous router. If

still not found, the mesh light will enter configure mode and wait for ESP-TOUCH packets from the smartphone.

• When ESP-TOUCH pairing succeeds, the smart light device will

connect to a router and become a mesh root device.

• Turn the other lights on, and they will scan the network, find that first

device, and connect to the device, eventually forming a mesh network.

3.3.2. Adding a device

If you wish to add a new device into the mesh, follow the steps below:

• Add your smartphone to the Wi-Fi that your want to configure.

• Enter the IoT App.

- If you are a new user, touch Register to register a new account.

- You can touch Quick Usage to operate the local devices.

Espressif Systems / 2016.014 12

Confidential

Page 10: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

Configuring The Mesh

• Login into the system with your account name and password. The system shows a cloud device

list and a local device list.

• Touch the button ⊕Add devices at the bottom of page, and then enter your SSID’s password.

Note

If you wish to operate the cloud devices, you can do so by logging in to the IOT App first, for the detail of cloud device, refer to 2.2 Local and cloud mesh > Cloud device.

Note:

If you are a new user, the lists are empty. By registering for a cloud account, your

settings, preferences and devices' data can be stored in the cloud, and the status and settings are also synchronized between different smartphones, as long as you are logged in.

Item Defination

Show password Choose this item to check the password you have entered.

This Wi-Fi is hidden

Choose this item if the Wi-Fi is hidden. Most of the Wi-Fis are not hidden.

Espressif Systems / 2016.015 12

Confidential

Page 11: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

Configuring The Mesh

• Turn on one light and wait until it turns green and flash (smart configure mode).Different colours of the smart light indicate different statuses of the device, as shown in the table below.

1. Touch OK, and the system shows a pop-up window : Configuring… > Discovering the devices…

2. When the device is found, the system shows 1 device found, after this light was added to the mesh, the systems shows a pop-up window: Esptouch Result > Connected to Wi-Fi Device List(1): ESP_A0D802.

3. Afterwards, the system shows Configuration completed.

• If the configuration failed, the system shows Configuration failed.

4. Hold and slide down the screen to refresh the device list. You can see the new device in the list.

5. Touch Mesh Root in the device list to see all the devices connected to the router.

Multiple devices

• If you want to configure one device, don’t choose Multiple devices, it takes about dozens of seconds to configure.

• If you want to configure multiple devices at the same time, choose

Multiple devices, it takes about less than 1 minute to configure.

Make device connect to cloud

If you wish to add devices to your cloud, choose this item first.

Note:

The system will remember the password, so you don’t need to enter the password again for the same Wi-Fi SSID if you have entered it before. Make sure the smartphone is connected to the Wi-Fi network ,or you can not add devices.

Light color Device status

Yellow The device is scanning the mesh network.

Green flash The device is in the smart configure mode which is ready to be configured.

Blue flash The device receives ESP-TOUCH packets and decoding the message.

White flash The device is get the SSID and PASSWORD of the ROUTER and is connecting.

Red flash The device fails to be configured, it will scan mesh network then.

Note:

You can see and control the node devices. The device which is directly connected to the router is the root node device.

Espressif Systems / 2016.016 12

Confidential

Page 12: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

Configuring The Mesh

3.4. Configure the ESP-NOW Controller Device (The Button)

3.4.1. Pairing ESP-NOW Controller Device with Smart Light After selecting the desired device, select the "three-vertical-dots" at the upper-right corner. Next, select

"Pair EspButton". You will be able to see the details about the Button. At the bottom of the screen, you will also see "Start configure".

3.4.2. Begin to pair Click the Start configure at the bottom. A 60-minute countdown will be started. To complete the pairing, you need to press the controller button for 3 seconds at the same time.

Espressif Systems / 2016.017 12

Confidential

Page 13: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

Configuring The Mesh

At the last period of pairing, a pop-up window as below will appear. If you allow this device pairing with

your button,click Permit. If you want to pair another devices, click OK in continue to pair. You can also pair some devices at the same time.

3.5. Operating the devices

3.5.1. Using the IOT App You can use the IOT App to operate the devices. Follow the steps below.

1. Touch ESP_A0d802 to see the operation page of the device.

• You can change the RGB and touch Confirm to operate the light.

2. Touch in the ESP_A0d802 operation page to see the network structure of the device.

• The device and all its child devices are shown by default.

• Touch to go back to the ESP_A0d802 operation page.

Espressif Systems / 2016.018 12

Confidential

Page 14: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

Configuring The Mesh

3.5.2. Configuring the Controller Device's Functions After pairing the controller device, you can now use the controller device to control the smart light.

Some of the characteristics of the controller device are as follow:

• The controller device has low power consumption.Static Current: The Button works in deep sleep mode, without current consumption.Total number of clicks: 19,000 times per charge on a 3.7V, 500mAh rechargeable lithium battery.

• The functions of the button can be customized. To do so, login to the App and select a device.

Next click the “EspButton Settings”. You should see the above diagram of a button. Now, define the 4 buttons’ functions separately (corresponding to the 4 corners). You can also define the functions of the clicks corresponding to the 4 sides.

Espressif Systems / 2016.019 12

Note:

If the pairing fail in 60 seconds, the device will turn Red.

Confidential

Page 15: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

Configuring The Mesh

The basic functions you can select are as below:

Button

Function

Short press

Reset function Restore factory settings

Set color Change smart light color

Turn on/off Power on/off all lights

Set timer Powers off the devices after a pre-determined period time

Set Brightness Set the brightness of all lights.

Espressif Systems / 2016.0110 12

Confidential

Page 16: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

Some Reference

4. Some Reference

4.1. FlowChart of ESP Smart Light

4.2. Debug Mode

In Debug mode, different colors are used to illustrate different states of the smart light:

• Yellow, flash 6 times: Begin the mesh scanning.

• Green , flash always: New device can not find other mesh devices and will enter into ESP-TOUCH mode, in which mode, the device will be configured. If ESP-TOUCH fail/timeout, the device turns

red, if success,the device turns white.

• If the light joined an existing mesh successfully, it will flash certain times in certain color:

- RED: mesh level 2

- GREEN: mesh level 3

- BLUE: mesh level 4

- PURPLE: mesh level 5

• After joined a mesh,as the sub-light’s color is synchronized with its parent, the color will be

changed automatically if they are not same.

• When the parent node are removed or turned off or other errors appear, the light will scan the mesh again and flash in yellow.

Yellow : Start mesh scan

Green : Find no existing mesh, and no recorded router available.Enter ESP-TOUCH mode.Green Flashing :Start ESP-TOUCH.

Red:ESP-TOUCH fail

Power on

Yellow:Restart mesh scan

After Joining a mesh, flashing Colour:white - rootred - level 2green - level 3blue - level 4purple - level 5

Sub-node’s colour is synchronised with its parent node

white:Connected with recorded router,as a mesh root node

Espressif Systems / 2016.0111 12

Confidential

Page 17: Smart Light Solution Introduction - wiki.ai-thinker.comwiki.ai-thinker.com/_media/esp8266/docs/smart_light_user_guide_en... · Smart Light Solution Introduction ... and mutually interfere

Some Reference

4.3. SDK Download

The firmware and instructions can be obtained from:

https://github.com/espressif/ESP8266_LIGHT_WITH_MESH/wiki

Espressif Systems / 2016.0112 12