add esp-now tutorial

This commit is contained in:
shaoxiang
2019-09-04 10:14:49 +08:00
parent da913ff8bb
commit e606b69e16
4 changed files with 106 additions and 14 deletions
+93
View File
@@ -36,6 +36,99 @@ Display information, you can choose some built-in label types, or enter custom t
><img src="/image/Remote/Remote_Phone.png" width="30%">
# Dashboard
#### Function Description
> In addition to the remote control features that are consistent with Remote, Remote-Beta provides a more powerful data panel function. Currently supports two data chart styles of polyline/column, the layout style of the page can be freely adjusted, and will be based on The user API Key is saved to achieve the persistence of the layout style.
><img src="image\Remote_beta\remote_beta_01.jpg" width="60%">
* __Create Chart__
A data chart program that generates data for the specified chart style.
* __Remote Button__
Remote button control, each time the button is clicked, the program in Block is executed once.
* __Remote Slider__
Slider control (click the gear button on the block to add a variable X before use, and pass the X to the integer from 0 to 100)
* __Remote Switch__
Remote switch control, please click the gear button on the block to add a variable X before use. When controlling, close X to pass 1 and disconnect X to pass 0.
<mark>Note: When naming blocks, avoid spaces and special symbols</mark>
#### Instructions
> Drag the data chart program to the programming area and fill in the relevant information of the chart in the option box. (Name: chart name, ChartType: polyline/column, DataType: data type of the chart, temporarily only support the number, key: the key of the data Word, Value: Data Source, Interval: Interval Refresh Time)
__Note: A table can only use one data source. If multiple tables with the same name appear, the data source will use the last data in the order in which the program is executed.
><img src="image\Remote_beta\remote_beta_02.jpg" width="60%">
>The buttons, sliders, and switches are used in the same way as the Remote function. For details, see the function description of the upper block. After editing, click Run Program. Click the QR code option on the right side of the page to scan or copy the data page. Link, use a browser to access.
><img src="image\Remote_beta\remote_beta_03.jpg" width="60%">
> After entering the control page, keep the M5 device running normally, you can see the data in the chart is refreshed according to the interval we configured. Drag the arrow in the lower right corner of the chart to zoom the entire chart. Click the upper left corner to open the side. Navigation, providing shades of theme color switching and layout switches. (After opening the layout switch, the user is free to modify the position of the chart and other elements placed on the page)
><img src="image\Remote_beta\remote_beta_04.jpg" width="60%">
><img src="image\Remote_beta\remote_beta_05.jpg" width="60%">
# ESP-NOW
#### Function Description
>ESP-NOW is a short-range, low-power communication protocol that enables multiple devices to communicate without or without Wi-Fi. This protocol is similar to the low-power 2.4GHz wireless connection found in wireless mice—devices are paired before communicating. After pairing, the connections between devices are continuous, peer-to-peer, and do not require a handshake protocol.
><img src="image\ESP_now\esp_now_01.jpg" width="60%">
* __Get mac addr__
Get the mac address of this machine.
* __Add peer ff as id__
Add the specified mac address and set it to id
* __Set pmk__
Set the pairing key
* __Broadcast data__
Broadcast specified data
* __Receive mac_addr data__
Receive data, get the sender's mac address and the data content carried
* __After send message flag__
Send a callback function, automatically execute the callback function after executing the send message, and return whether the flag bit flag is successfully sent. The success is True and the failure is False.
* __Send message id with data__
Send data to the device with the specified id.
#### Instructions
<h3><mark>Receiver</mark></h3>
> Display the local mac address on the screen, use the data receiving block and create two variables for receiving the sender's address and data content. The data is processed inside the receiving block function for display or judgment and other operations. For example, the lower program controls the LED light switch by judging whether the received data is "1".
__Note: The created variable name is not allowed to be consistent with the parameter name, ie variables with the names "addr" and "data" are not allowed to be used for data acquisition __
><img src="image\ESP_now\esp_now_02.jpg" width="40%">
<h3><mark>Sender</mark></h3>
> Add the mac address of the receiving device, fill in the sent data content in the sending program, select the id of the receiving device. Use the button program to control the data transmission. Using the callback function can help us determine whether the data is successfully sent from the machine. We need to use a variable to get its return result.
__Note: The created variable name is not allowed to be consistent with the parameter name, ie variables with the name "flag" are not allowed to be used for data acquisition __
><img src="image\ESP_now\esp_now_03.jpg" width="40%">
>Complete the program editing, respectively run the receiver and transmitter programs, you can achieve ESP-NOW short-range wireless communication.
# MQTT communication
__________________________
Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

+13 -14
View File
@@ -2,7 +2,7 @@
**[数据面板](#数据面板)**
<!-- **[ESP-NOW](#ESP-NOW)** -->
**[ESP-NOW](#ESP-NOW)**
**[MQTT通讯](#MQTT通讯)**
@@ -24,8 +24,6 @@
# 远程控制
__________________________
@@ -107,7 +105,7 @@ __注意:一个的表格只能使用一个数据来源,若是出现多个相
><img src="image\Remote_beta\remote_beta_05.jpg" width="60%">
<!-- # ESP-NOW
# ESP-NOW
#### 功能说明
@@ -131,30 +129,31 @@ __注意:一个的表格只能使用一个数据来源,若是出现多个相
接收数据,获取发送者mac地址以及携带的数据内容
* __After send message flag__
发送回调函数,在执行发送信息后自动执行回调函数,并返回是否发送成功的标志位flag.
发送回调函数,在执行发送信息后自动执行回调函数,并返回是否发送成功的标志位flag.成功为True,失败为False.
* __Send message id with data__
发送数据至指定的id.
发送数据至指定的id的设备.
#### 使用方法
>填写
<h3><mark>接收端</mark></h3>
__注意:一个的表格只能使用一个数据来源,若是出现多个相同名称的表格,其数据来源将按照程序执行顺序使用最后一个数据__
>将本机mac地址显示在屏幕上,使用数据接收块并创建两个变量用于接收发送者地址与数据内容.在接收块函数内部进行数据的处理,用作显示或是判断等其他操作.如下方程序通过判断接收数据是否为"1",控制LED灯的开关.
><img src="image\Remote_beta\remote_beta_02.jpg" width="60%">
__注意:创建的变量名称不允许与形参名称一致,即不允许使用名称为"addr"、"data"的变量用作数据获取__
>按键、滑动条、开关的使用方式与Remote功能完全一致,详情可查看上方程序块功能介绍,完成编辑后,点击运行程序.单击页面右侧的二维码选项,扫描或复制数据页面的链接,使用浏览器进行访问.
><img src="image\ESP_now\esp_now_02.jpg" width="40%">
><img src="image\Remote_beta\remote_beta_03.jpg" width="60%">
<h3><mark>发送端</mark></h3>
>添加接收端设备的mac地址,在发送程序中填写发送的数据内容、选择接收的设备的id.使用按键程序去控制数据的发送.使用回调函数能够帮助我们判断数据是否成功从本机发送出去.我们需要用一个变量去获取它的返回结果.
>进入控制页面后,保持M5设备的正常运行,就能看到图表中的数据按照我们所配置的间隔时间不断刷新,拖动图表右下角箭头能够实现整个图表缩放.点击左上角能够打开侧边导航,提供深浅主题色切换以及布局开关.(打开布局开关后,用户即可自由的修改图表及其他元素在页面中所摆放的位置)
__注意:创建的变量名称不允许与形参名称一致,即不允许使用名称为"flag"的变量用作数据获取__
><img src="image\Remote_beta\remote_beta_04.jpg" width="60%">
-->
><img src="image\ESP_now\esp_now_03.jpg" width="40%">
>完成程序编辑,分别运行接收端与发射端程序,即可实现ESP-NOW短程无线通信.
# MQTT通讯
__________________________