8733| 31
|
[MP动手做] MicroPython动手做(30)——物联网之Blynk |
Blynk专为物联网而设计。它可以远程控制硬件,可以显示传感器数据,可以存储数据,对其进行虚拟化,还可以执行许多其他出色的工作。 该平台包含三个主要组件: Blynk应用程序-允许您使用我们提供的各种小部件为您的项目创建惊人的界面。 Blynk服务器-负责智能手机和硬件之间的所有通信。您可以使用我们的Blynk Cloud或在本地运行您的私有Blynk服务器。它是开源的,可以轻松处理数千个设备,甚至可以在Raspberry Pi上启动。 Blynk库-适用于所有流行的硬件平台-支持与服务器的通信并处理所有传入和传出的命令。 现在想像一下:每次在Blynk应用程序中按下Button时,消息就会传播到Blynk Cloud空间,神奇地在其中找到通向硬件的方式。它在相反方向上的作用相同,并且所有操作都在眨眼间发生。 |
#MicroPython动手做(30)——物联网之Blynk #远程网络八音盒电子琴 [mw_shl_code=python,false]#MicroPython动手做(30)——物联网之Blynk #远程网络八音盒电子琴 from mpython import * import network import blynklib import time import music my_wifi = wifi() my_wifi.connectWiFi("zh", "zy1567") blynk = blynklib.Blynk("8d52fd7ed2844892a843158e127ed3f2", server="blynk.mpython.cn", port=8080) @blynk.handle_event("connect") def connect_handler(): print('Blynk connected') @blynk.handle_event("disconnect") def connect_handler(): print('Blynk disconnected') @blynk.handle_event('write V1') def write_virtual_pin_handler(pin, _value): global my_list for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] music.play('C3:2') @blynk.handle_event('write V2') def write_virtual_pin_handler(pin, _value): global my_list for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] music.play('D3:2') @blynk.handle_event('write V3') def write_virtual_pin_handler(pin, _value): global my_list for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] music.play('E3:2') @blynk.handle_event('write V4') def write_virtual_pin_handler(pin, _value): global my_list for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] music.play('F3:2') @blynk.handle_event('write V5') def write_virtual_pin_handler(pin, _value): global my_list for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] music.play('G3:2') @blynk.handle_event('write V6') def write_virtual_pin_handler(pin, _value): global my_list for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] music.play('A3:2') @blynk.handle_event('write V7') def write_virtual_pin_handler(pin, _value): global my_list for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] music.play('B3:2') oled.fill(0) oled.DispChar(" 远程八音盒电子琴", 0, 16, 1) oled.show() rgb[1] = (int(0), int(51), int(0)) rgb.write() time.sleep_ms(1) while True: blynk.run()[/mw_shl_code] |
6、Blynk远程控制小车前后左右行驶 [mw_shl_code=python,false]#MicroPython动手做(30)——物联网之Blynk #Blynk远程控制小车前后左右行驶 from mpython import * import network import blynklib import music import time import parrot my_wifi = wifi() my_wifi.connectWiFi("zh", "zy1567") blynk = blynklib.Blynk("67988e85a728460fb1d543b9d15e0b5f", server="blynk.mpython.cn", port=8080) @blynk.handle_event("connect") def connect_handler(): print('Blynk connected') @blynk.handle_event("disconnect") def connect_handler(): print('Blynk disconnected') @blynk.handle_event('write V1') def write_virtual_pin_handler(pin, _value): for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] parrot.set_speed(parrot.MOTOR_1, 80) parrot.set_speed(parrot.MOTOR_2, 80) @blynk.handle_event('write V2') def write_virtual_pin_handler(pin, _value): for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] parrot.set_speed(parrot.MOTOR_1, -50) parrot.set_speed(parrot.MOTOR_2, -50) @blynk.handle_event('write V3') def write_virtual_pin_handler(pin, _value): for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] parrot.set_speed(parrot.MOTOR_1, -50) parrot.set_speed(parrot.MOTOR_2, 50) @blynk.handle_event('write V4') def write_virtual_pin_handler(pin, _value): for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] parrot.set_speed(parrot.MOTOR_1, 50) parrot.set_speed(parrot.MOTOR_2, -50) @blynk.handle_event('write V5') def write_virtual_pin_handler(pin, _value): for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] parrot.set_speed(parrot.MOTOR_1, 0) parrot.set_speed(parrot.MOTOR_2, 0) oled.fill(0) oled.DispChar(" 远程控制小车", 0, 1, 1) oled.show() music.play('D5:1') rgb[1] = (int(0), int(51), int(0)) rgb.write() time.sleep_ms(1) while True: blynk.run()[/mw_shl_code] |
#MicroPython动手做(30)——物联网之Blynk #远程开关控制板载RGB灯 [mw_shl_code=python,false]#MicroPython动手做(30)——物联网之Blynk #远程开关控制板载RGB灯 from mpython import * import network import blynklib import time import music my_wifi = wifi() my_wifi.connectWiFi("zh", "zy1567") blynk = blynklib.Blynk("N14sXx7xQ-rXQF4_gKIFjEQqCC_LzybL", server="116.62.49.166", port=8080) @blynk.handle_event("connect") def connect_handler(): print('Blynk connected') @blynk.handle_event("disconnect") def connect_handler(): print('Blynk disconnected') @blynk.handle_event('write V1') def write_virtual_pin_handler(pin, _value): global i for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] rgb.fill((int(153), int(0), int(0))) rgb.write() time.sleep_ms(1) music.play('G5:1') @blynk.handle_event('write V0') def write_virtual_pin_handler(pin, _value): global i for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] rgb.fill( (0, 0, 0) ) rgb.write() time.sleep_ms(1) music.play('E5:1') oled.fill(0) oled.DispChar(" 网络已经连接", 0, 16, 1) oled.show() rgb[1] = (int(0), int(102), int(0)) rgb.write() time.sleep_ms(1) music.play('C5:1') while True: blynk.run()[/mw_shl_code] |
Blynk是一项物联网(IoT)服务,旨在使远程控制和从您的设备中读取传感器数据的速度尽可能快和容易。Blynk是一个物联网平台,简化了物联网的移动和Web应用程序的构建。加入最流行的物联网平台,将您的设备连接到云,设计应用程序以控制它们,分析遥测数据并大规模管理已部署的产品。Blynk使复杂的物联网技术变得简单,我们设计,开发和测试了完整的IoT解决方案的构建基块,因此在Blynk上运行的企业不必这样做。最全面的物联网堆栈,Blynk将云平台与将事物,人员和数据置于企业运营核心的应用程序相结合。 Blynk官网 https://blynk.io/ |
Blynk是一个与硬件无关的物联网平台,具有可定制的移动应用程序、私有云、规则引擎和设备管理分析仪表盘。 在blynk平台中,通过可视化拖拽,你就能创建一个可发布到Google play或App Store的应用。blynk开源了若干项目,开源地址在 github.com/blynkkk,如果担心自己的数据安全,可以自行搭建server。blynk默认支持400多款硬件,其中很多是开源硬件,所有的硬件驱动,blynk都开源出来了! blynk几乎一条龙服务,帮助你构建自己的物联网产品。 blynk特征 所有受支持的硬件和设备的相似API和UI 使用以下方式连接到云: WiFi无线上网 蓝牙和BLE 以太网路 USB(串行) GSM … |
#MicroPython动手做(30)——物联网之Blynk #尝试简单打印Blynk的v值 [mw_shl_code=python,false]#MicroPython动手做(30)——物联网之Blynk #尝试简单打印Blynk的v值 from mpython import * import network my_wifi = wifi() my_wifi.connectWiFi('zh', 'zy1567') import blynklib blynk = blynklib.Blynk('N14sXx7xQ-rXQF4_gKIFjEQqCC_LzybL', server='116.62.49.166', port=8080) @blynk.handle_event("connect") def connect_handler(): print('Blynk connected') @blynk.handle_event("disconnect") def connect_handler(): print('Blynk disconnected') @blynk.handle_event('write V0') def write_virtual_pin_handler(pin, _value): global v for i in range(0, len(_value)): try: _value = eval(_value) except: pass if len(_value) == 1: _value = _value[0] print(v) while True: blynk.run()[/mw_shl_code] |
© 2013-2025 Comsenz Inc. Powered by Discuz! X3.4 Licensed