|
本帖最后由 点点&木木 于 2019-4-12 09:14 编辑 智能照明是物联网的催化剂。在本教程中,我们将了解如何使用Zerynth App通过移动设备控制NeoPixelLED。 ) \! j% a' N) |2 X' ~* V
7 G: B( e" B1 }7 q+ p3 D0 l& d2 s 0 `$ A5 p: H/ r- U# P 这个项目中使用的东西 硬件组件 Zerynth Shield × 1 Arduino × 1 STM32 Nucleo ST NUCLEO × 1 粒子光子 × 1 UDOO DUAL × 1 Adafruit NeoPixel × 1 低功耗无线模块与低成本,超小型LED,传感器和通信设备相结合,使智能照明成为物联网和家庭自动化的催化剂。 2 W- W8 E! b+ n在本教程中,我们将了解如何使用Zerytnh应用程序通过移动设备控制NeoPixelLED灯条,该应用程序可实现颜色的选择和各种预配置动画的菜单的选择。 1 p, W. ?; R: F8 ?) q9 q5 n! i第1步:所需材料 + V# i4 i, J5 [5 e) ?
TOI盾和uC板 , o& m; C! i9 f" ^/ c1 u + Q+ K9 L# s4 u( f0 J8 O% U
WiFi盾 . b7 j* a# F" E! F: Q" ?: J8 b
$ l+ k5 C. r& i2 J' h% C ! D# g9 q# f9 K% P( g
Neopixel
玻璃灯 0 w0 \0 \$ g" Y. a. s# N9 T3 r3 E$ ^0 ]8 m9 h; E+ N4 L D$ W + p& x8 N! O! r/ @6 F3 ]8 C* Z- ]9 l 该项目需要的内容很少: Zerynth Studio :一个基于多平台和浏览器的Python开发环境,其具有云同步和电路板管理功能。无论你使用哪种操作系统,Zerynth都会运行!只需下载Zerynth并安装它(http://www.zerynth.com/zerynth-studio/ )。 Zerynth App:用于智能对象和物联网系统的Zerynth移动界面。任何手机都将成为对象显示和遥控器。下载地址:http ://www.zerynth.com/zerynth-app/ Zerynth Shield (可在此处获取:https ://store.open-electronics.org/index.php?_route_ = Shield_ZERYNTH&search = toi )。随时可用的多传感器板,为您的日常生活物品增添智能功能。 Arduino DUE 或ST NucleoF401RE 或ParticlePhoton 。无论您使用哪种主板,Zerynth都能实现多板兼容的!您可以在此处找到所有支持的电路板详细信息:http ://www.zerynth.com/zerynth-studio/ 如果你不使用粒子光子(内置WiFi模块),您需要将电路板连接到网络,如元素的WiFi盾的Adafruit的。您也可以使用任何其他适配器并安装无线芯片CC3000 Texas Instruments 来实现。(http://www.ti.com/product/cc3000 )。 来自Adafruit 的NeoPixel LED 条(或环)(可在此处获取http://www.adafruit.com/products/1426 )。一个玻璃或3D印刷灯。 + ^0 l- J/ Q4 f* `% w 第2步:组装 ! [- S- ~9 y# z' K3 f7 D& R% u
( }1 T/ D8 p5 n( w9 z 接下来,只需将wifi Shield和Zerynth Shield搭载到你的Arduino(或ST Nucleo或UDOO)上。只需LED将它背负在ZerynthShield上的专用连接器上。 将NeoPixel LED连接到ZerynthShield上的相关端口。最后将所有电路板和LED都放入灯泡中。 & H( g5 x9 O! t, X; m3 D$ R* Q 第3步:编程
7 g1 k/ k4 t: c; Q: E 使用Zerynth非常简单! ' P& w$ z9 f4 Q/ r2 \& E$ G; Y) y连接并“虚拟化”您的电路板(已在此处解释 http://bit.ly/Hackster-VIPER-Theremin ) 在Zerynth中创建一个新项目(已在此处解释 http://bit.ly/Hackster-IoT-Notes-Printer )。注意:您需要创建3(+1)个文件:main.py,animation.py,template.html(和project.md) 复制发布的代码 上传你电路板上的代码,你就完成了! 打开灯后,它将自动连接到预设网络。 然后只需打开Zerynth应用程序,它将搜索连接到网络的Zerynth对象,选择感兴趣的对象,在本例中为“Zerytnh Lamp”,您可以与它进行交互!在这种情况下,Zerynth应用程序显示颜色选择器和用于选择各种预配置动画的菜单。 + `$ r0 q5 X. R& g6 o6 W1 H代码非常简单,有很多注释。 - X o; r0 X5 e: \第4步:让物联网更加明亮! / v2 s+ }+ {# n8 J7 r$ a7 w
. B4 a* ]. ^. b9 y Zerynth Shield提供一套传感器和执行器,包括用于触摸检测的传感器,红外LED,麦克风,光传感器和温度传感器。您可以从这个非常简单的示例代码开始,以开发您喜欢的东西。使用Zerynth Shield扩展灯泡的功能! . k' H; R5 f3 {* X : f2 K7 J' r. |& j& A Z" H1 H 原理图 1 P! y4 O: Y" K3 |$ }) i$ Q+ p- q+ { 代码 ' W& W; q1 L5 H5 Q- d3 N. l' R################################################################################ # Zerynth Lamp # # Created by Zerynth Team 2015 CC # Authors: G. Baldi, D. Mazzei ################################################################################ # import needed modules import streams from bcm43362 import bcm43362 as wifi_driver from wireless import wifi import animation from toishield import toishield # and import the zerynthapp module from zerynthapp import zerynthapp streams.serial() # connect to a wifi network try: wifi_driver.auto_init() print("Establishing Link...") wifi.link("SSID",wifi.WIFI_WPA2,"password") print("Ok!") except Exception as e: print(e) # save the template.html in the board flashwith new_resource new_resource("template.html") #### ZerynthApp Setup # :: Javascript to Python :: # the following functions will be calledwhen buttons are pressed def change_color(r, g, b): animation.setup_color(r, g, b) def change_animation(n): animation.setup_anim(n) def change_speed(n): animation.setup_anim_speed(n) # configure the Zerynth app with a name, adescripton and the template url vp = zerynthapp.ZerynthApp("Zerynth Lamp", "Try me!", "resource://template.html") # everytime Javascript generates events thecorresponding functions are called vp.on("change_color", change_color) vp.on("change_animation", change_animation) vp.on("change_speed", change_speed) # run the ZerynthApp! vp.run() # since vp.run starts a new thread, you cando whatever else you want down here! # let's control leds animation.start(D6, 24) 7 x/ @6 I4 N& a0 x; p# C2 R |
| 点赞 |
【MCU实战经验】+基于stm32L的低功耗物联网温度测量节点
【NUCLEO-WBA65RI评测】物联网 LED
【NUCLEO-WBA65RI评测】蓝牙体温计
【NUCLEO-WBA65RI评测】Home Assistant 物联网心率计
意法半导体与高通达成无线物联网战略合作
《RT-Thread设备驱动开发指南》书籍学习记录
[STM32WB55评测] 开箱
【我心中的STM32WBA52】
【我心中的STM32WBA52】
将STM 32 Lora DiscoveryKit连接到AWS物联网(三)
微信公众号
手机版