UIFlow Guide
通过BLE连接Blynk App, 实现手机端无线控制。注:仅带PSRAM机型(如M5Fire, M5Core2)支持。该功能仅支持Blynk legacy, 新版本的Blynk已没有提供BLE支持。
1.在Blynk legacy中创建新工程, 选择ESP32 Dev Board, 选择接入方式为BLE, 同时记录下AUTH TOKEN。按照下图步骤添加组件, 其中BLE连接为必要组件。
2.使用Blynk控制M5StackFire的RGB灯条颜色和亮度,并在屏幕上实时显示
from ble import blynk
blynk.init('Device Name', 'Token', blynk.BLE)
def blynk_write_all(*args):
global msg, num
num, msg = args[0], args[1]
pass
blynk.handle_event('write v*', blynk_write_all)
def blynk_read_all(*args):
global num
num = args[0]
pass
blynk.handle_event('read v*', blynk_read_all)
blynk.notify('')
def blynk_connected():
# global params
print('connected')
pass
blynk.handle_event('connected', blynk_connected)
blynk.tweet('')
blynk.virtual_write(1, '')