EPTmachine

  • 2023-09-15
  • 加入了学习《泰克泰想开车智能(下)篇》,观看 USB2.0 RX测试

  • 2023-09-08
  • 回复了主题帖: 大家对吃海产品的意见如何

    吃哪里的海鲜也要将zzzq,未来世界确实越来越保守了,不知道大家的技术栈以后怎么调整呢?

  • 2023-09-07
  • 回复了主题帖: 国内首批Matter设备正式量产啦,对此你怎么看?

    这收费标准直接劝退很多小企业了

  • 2023-09-01
  • 加入了学习《ADI - 世健 工业嘉年华》,观看 ADI - 世健 工业嘉年华 开幕致辞

  • 2023-08-23
  • 加入了学习《直播回放: 使用低成本 MSPM0 MCU 快速开发》,观看 使用低成本 MSPM0 MCU 快速开发

  • 2023-08-20
  • 回复了主题帖: 【得捷电子Follow me第2期】+任务2:网络功能使用

     

  • 回复了主题帖: 【得捷电子Follow me第2期】+任务3:控制WS2812B

    确实,Adafruit的库做的很全面,很适合新手入门提升兴趣,不过深入学习还是回到底层

  • 回复了主题帖: 【得捷电子Follow me第2期】+任务2:网络功能使用

    秦天qintian0303 发表于 2023-8-20 07:45 楼主你好,创建WiFi热点还需要特殊设计吗?代码没有提示错误,不过没有创建成功
    主程序最后要加一个 while:     pass

  • 2023-08-19
  • 回复了主题帖: 《RT-Thread设备驱动开发指南》读书笔记一 串口驱动

    程序框架一复杂就不知道是哪了    

  • 2023-08-17
  • 回复了主题帖: 来做个调查呀~~小伙伴们都对什么样的书感兴趣呀??

    工程师要胆大心细,要不然很吃亏

  • 回复了主题帖: 报销返现通知|得捷电子 Follow me 第一期活动

    已填写,等待京东卡到手

  • 2023-08-16
  • 回复了主题帖: 【得捷电子Follow me第2期】+任务5:通过网络控制WS2812B

    官网的教程给力,照着Demo抄一遍就好了

  • 发表了主题帖: 【得捷电子Follow me第2期】+任务5:通过网络控制WS2812B

    Adafruit IO是Adafruit的远程IO平台,可以通过网页实现对开发板上外设的控制。 1.Adafruit IO设置 首先,我们需要登陆Adafruit IO网站,并注册自己的账号, 然后在Feeds界面中neopixel的数据源。 在Dashboards界面添加“Neopixel”的控制界面。 在DashBoards中添加一个Color Picker的颜色控制块。 在Color Picker的数据关联界面设定其与nexpixel的Feed对象关联在一起。 到此为止,Adafruit IO中的相关设置就做好了。 2. 开发板配置 在开发板的配置文件settings.toml中定义连接Wifi的名称和密码,同时设置AIO Key的用户名和KEY,相关的信息可以在以下界面查看。 将相关字段的值作为系统变量写入settings.toml中,这样就完成了开发板的系统变量设置。 # SPDX-FileCopyrightText: 2023 Adafruit Industries # # SPDX-License-Identifier: MIT # This is where you store the credentials necessary for your code. # The associated demo only requires WiFi, but you can include any # credentials here, such as Adafruit IO username and key, etc. WIFI_SSID = "Wifi名称" WIFI_PASSWORD = "Wifi密码" AP_SSID = "ESP32_Feather" AP_PASSWORD = "EEWorld_2023" AIO_USERNAME = "Adafruit IO用户名" AIO_KEY = "Adafruit IO密钥" 3.Adafruit IO程序编写 在CIRCUTPY的lib文件中添加图片中的库文件。 使用IO_MQTT(mqtt_client)初始化MQTT客户端,同时设定相关的回调函数,在主函数中对连接进行检查,并调用消息轮询函数。另外对显示屏进行初始化,确定显示区域,并在MQTT的回调函数中读取Adafruit IO的Color Picker发送过来的RGB数据,用于控制neopixel,并在显示屏上显示相关的数据信息。相关代码如下: # SPDX-FileCopyrightText: 2021 Ladyada for Adafruit Industries # SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries # SPDX-License-Identifier: MIT import time import ssl import os from random import randint import microcontroller import socketpool import wifi import board import neopixel import displayio import terminalio import adafruit_minimqtt.adafruit_minimqtt as MQTT from adafruit_io.adafruit_io import IO_MQTT from adafruit_display_text import bitmap_label, label # WiFi try: print("Connecting to %s" % os.getenv("WIFI_SSID")) wifi.radio.connect(os.getenv("WIFI_SSID"), os.getenv("WIFI_PASSWORD")) print("Connected to %s!" % os.getenv("WIFI_SSID")) # Wi-Fi connectivity fails with error messages, not specific errors, so this except is broad. except Exception as e: # pylint: disable=broad-except print("Failed to connect to WiFi. Error:", e, "\nBoard will hard reset in 30 seconds.") time.sleep(30) microcontroller.reset() # Initialise NeoPixel pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.3) # Set up TFT display display = board.DISPLAY board.DISPLAY.brightness = 0.35 board.DISPLAY.rotation = 0 group = displayio.Group() weather_color=0x00FF00 neopixel_area = label.Label(terminalio.FONT, text="NeoPixel", color=weather_color) neopixel_area.x = 2 neopixel_area.y = 30 neopixel_area.line_spacing = 0.8 neopixel_area.scale = 1 main_group = displayio.Group() main_group.append(group) main_group.append(neopixel_area) # Show the main group on the display display.show(main_group) # Define callback functions which will be called when certain events happen. def connected(client): print("Connected to Adafruit IO! Listening for NeoPixel changes...") # Subscribe to Adafruit IO feed called "neopixel" client.subscribe("neopixel") def message(client, feed_id, payload): # pylint: disable=unused-argument print("Feed {0} received new value: {1}".format(feed_id, payload)) #neopixel_area.text = "Feed {0} received new value: {1}".format(feed_id, payload) if feed_id == "neopixel": pixel.fill(int(payload[1:], 16)) # Create a socket pool pool = socketpool.SocketPool(wifi.radio) # Initialize a new MQTT Client object mqtt_client = MQTT.MQTT( broker="io.adafruit.com", username=os.getenv("AIO_USERNAME"), password=os.getenv("AIO_KEY"), socket_pool=pool, ssl_context=ssl.create_default_context(), ) # Initialize Adafruit IO MQTT "helper" io = IO_MQTT(mqtt_client) # Set up the callback methods above io.on_connect = connected io.on_message = message timestamp = 0 while True: try: # If Adafruit IO is not connected... if not io.is_connected: # Connect the client to the MQTT broker. print("Connecting to Adafruit IO...") io.connect() # Explicitly pump the message loop. io.loop() # Adafruit IO fails with internal error types and WiFi fails with specific messages. # This except is broad to handle any possible failure. except Exception as e: # pylint: disable=broad-except print("Failed to get or send data, or connect. Error:", e, "\nBoard will hard reset in 30 seconds.") time.sleep(30) microcontroller.reset() 运行效果如图所示: 4.总结 Adafruit IO提供了易用丰富的物联网接口,可以对不同格式的数据进行操作和传递,初学者可以很快地搭建可用地示例,同时良好的程序接口和丰富的社区资源,可以帮助初学者快速入门,理解物联网应用的框架。

  • 2023-08-15
  • 发表了主题帖: 【得捷电子Follow me第2期】+任务4:日历&时钟

    Adafruit官网上关于如何使用NTP(网络时间协议)和如何获取天气信息有详细的教程以及相应的库支持。本文将根据官方的示例实现电子万年历和时钟功能。 1.硬件介绍 本文使用到的硬件有ESP32-S3以及TFT显示屏,利用ESP32-S3自带的Wifi功能连接到网络,从网络上获取时间信息和天气信息,在TFT显示屏上将获取的信息显示出来。 2.网络时间获取 参考Adafruit官网提供NTP演示示例,在CIRCUTPY的lib中添加adafruit_ntp库用于支持网络时间的获取,参考官网提供的示例代码,同时将获取的时间信息显示在显示屏上,相关代码如下: # Get current time using NTP print("Fetching time from NTP.") pool = socketpool.SocketPool(wifi.radio) #指定NTP服务器为国内阿里云服务器 ntp = adafruit_ntp.NTP(pool, server="ntp.aliyun.com", tz_offset=TZ_OFFSET) rtc.RTC().datetime = ntp.datetime 3.天气信息获取 通过心知天气的API接口获取天气信息,天气信息以JSON字符的形式返回,在心知天气的官网上可以查看API的调用方式以及返回数据的例子。 从返回的数据中解析其中的数据,提取出城市、温度、以及天气信息,同时在显示屏上显示出来,相关代码如下: DATA_SOURCE = "http://api.seniverse.com/v3/weather/now.json?key=SG-nLPzA3pyLEy9Tw&location=wuxi&language=en&unit=c" while True: # Fetch weather data from 心知 API print("Fetching json from", DATA_SOURCE) response = requests.get(DATA_SOURCE) print(response.json()) # Extract temperature and weather condition data from API response current_temp = response.json()["results"][0]["now"]["temperature"] current_weather_condition = response.json()["results"][0]["now"]["text"] current_city = response.json()["results"][0]["location"]["name"] print("Weather condition: ", current_weather_condition) 整个工程的代码如下: # 在这里写上你的代码 :-) # SPDX-FileCopyrightText: 2022 Carter Nelson for Adafruit Industries # # SPDX-License-Identifier: MIT import board import rtc import wifi import adafruit_ntp import os import ssl import time import displayio import terminalio import socketpool import adafruit_requests from adafruit_display_text import bitmap_label, label DATA_SOURCE = "http://api.seniverse.com/v3/weather/now.json?key=SG-nLPzA3pyLEy9Tw&location=wuxi&language=en&unit=c" # --| User Config |-------------------------------- TZ_OFFSET = 8 # time zone offset in hours from UTC NEO_PIN = board.NEOPIXEL # neopixel pin NEO_CNT = 1 # neopixel count # ------------------------------------------------- # Set up TFT display display = board.DISPLAY board.DISPLAY.brightness = 0.35 board.DISPLAY.rotation = 0 group = displayio.Group() time_color = 0xFF0000 weather_color = 0x00FF00 time_area = label.Label(terminalio.FONT, text="Hello", color=time_color) time_area.x = 2 time_area.y = 10 time_area.line_spacing = 0.8 time_area.scale = 1 weather_area = label.Label(terminalio.FONT, text="Weather", color=weather_color) weather_area.x = 2 weather_area.y = 30 weather_area.line_spacing = 0.8 weather_area.scale = 1 main_group = displayio.Group() main_group.append(group) main_group.append(time_area) main_group.append(weather_area) # Show the main group on the display display.show(main_group) # Connect to local network wifi.radio.connect(os.getenv("WIFI_SSID"), os.getenv("WIFI_PASSWORD")) print("Wifi connected.") # Get current time using NTP print("Fetching time from NTP.") pool = socketpool.SocketPool(wifi.radio) ntp = adafruit_ntp.NTP(pool, server="ntp.aliyun.com", tz_offset=TZ_OFFSET) rtc.RTC().datetime = ntp.datetime # requests = adafruit_requests.Session(pool, ssl.create_default_context()) # Define time interval between requests time_interval = 3000 # set the time interval to 30 minutes # Wait for wake up time now = time.localtime() print("Current time: {:2}:{:02}".format(now.tm_hour, now.tm_min)) while True: # Fetch weather data from 心知 API print("Fetching json from", DATA_SOURCE) response = requests.get(DATA_SOURCE) print(response.json()) # Extract temperature and weather condition data from API response current_temp = response.json()["results"][0]["now"]["temperature"] current_weather_condition = response.json()["results"][0]["now"]["text"] current_city = response.json()["results"][0]["location"]["name"] print("Weather condition: ", current_weather_condition) time_area.text = "Hello EEWorld\n\Time is {:2}:{:02}".format( now.tm_hour, now.tm_min ) weather_area.text="City: " + current_city+"\n"\ +"Temperature: {}".format(current_temp)+"\n"\ +"Weather: "+ current_weather_condition # just sleep until next time check time.sleep(30) now = time.localtime() 代码的运行效果如图所示:   4.总结 官网上的例子由于使用大部分都是国外的服务器,在移植时需要使用者对NTP和天气API的具体使用要有了解,从而能正确地使用国内的服务,使自己的代码正确运行。

  • 2023-08-14
  • 发表了主题帖: 【得捷电子Follow me第2期】+任务3:控制WS2812B

    在开发板上优异内置地RGB NeoPixel状态指示灯。可以通过编写CircutPython代码来实现对LED的颜色和亮度调节。 1.硬件介绍 NeoPixel是Adafruit产品WS281X系列中的可寻址LED灯,其包含了红、绿、蓝三色LED各一个,通过一个控制引脚来实现对其的控制。由于其极小的封装特别适合用于板上信息提示以及其他有趣的应用。 2.控制NeoPixel不同颜色间切换 在CircutPython环境中控制NeoPixel需要在CIRCUTPY的lib库中添加neopixel.mpy和adafruit_pixelbuf.mpy这两个库。 neopixel.mpy中提供了用于控制LED灯的函数,在实现对RGB灯的控制前,调用neopixel.NeoPixel()实例化一个实例,并对其管脚和模块个数进行初始化。并通过对neopixel提供的成员变量和函数(这里使用brightness成员变量调节亮度,使用fill()成员函数调节颜色)实现对LED亮度和颜色的控制。 在code.py中添加以下代码,从而实现RGB灯不同颜色之间的切换。 # 在这里写上你的代码 :-) # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries # SPDX-License-Identifier: MIT """CircuitPython status NeoPixel red, green, blue example.""" import time import board import neopixel pixel = neopixel.NeoPixel(board.NEOPIXEL, 1) pixel.brightness = 0.3 while True: pixel.fill((255, 0, 0)) time.sleep(0.5) pixel.fill((0, 255, 0)) time.sleep(0.5) pixel.fill((0, 0, 255)) time.sleep(0.5) 效果如视频所示: [localvideo]0e8f9e22e89b06bc0f45dfc5756134c8[/localvideo]   3.控制NeoPixel实现彩虹灯的效果 在Adafruit提供的colorwheel库中,调用rainbow()函数可以根据给定参数控制彩虹灯的变换速度,调用方法十分简单。示例代码如下: # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries # SPDX-License-Identifier: MIT """CircuitPython status NeoPixel rainbow example.""" import time import board from rainbowio import colorwheel import neopixel pixel = neopixel.NeoPixel(board.NEOPIXEL, 1) pixel.brightness = 0.3 def rainbow(delay): for color_value in range(255): pixel[0] = colorwheel(color_value) time.sleep(delay) while True: rainbow(0.02) 效果如视频所示: [localvideo]7a57a73f8d1c5e602b70e672ded1f02a[/localvideo]   4.总结 Adafruit对于板上外设的使用方法提供了全方位的封装,并且在官方网站上提供了丰富演示样例,可以让开发者快速上手,快速搭建出有趣的应用。十分感谢EEWorld论坛和得捷电子提供的这次学习机会。

  • 发表了主题帖: 【得捷电子Follow me第2期】+任务2:网络功能使用

    本帖最后由 EPTmachine 于 2023-8-14 19:38 编辑 ESP32系列芯片的一大优点就是内置了Wifi功能,不需要外接Wifi芯片从而实现Wifi连接,这一优点使其特别适用于物联网应用。 1.程序使用到的硬件 由于芯片本身具有Wifi功能,所以实现网络功能只需要ESP32-S3芯片就可以了,不需要额外的器件,在Wifi应用中,ESP32-S3可以通过Wifi连接网络中,也可以创建为Wifi热点,让其他设备连接到ESP32-S3上。 2.连接到Wifi 参考Adafruit官网和CircutPython官网上对于Wifi功能的介绍,连接到附近的Wifi网络,需要的导入的库有os和wifi。 首先在对CIRCUTPY中的settings.toml修改,定义系统变量WIFI_SSID和WIFI_PASSWORD的值。settings.toml的内容示例如下: WIFI_SSID = "WIFI名称" WIFI_PASSWORD = "WIFI密码" 在code.py中添加以下代码, # SPDX-FileCopyrightText: 2020 Brent Rubell for Adafruit Industries # # SPDX-License-Identifier: MIT import os import wifi print("ESP32-S3 Station Test") print(f"My MAC address: {[hex(i) for i in wifi.radio.mac_address]}") print("Available WiFi networks:") for network in wifi.radio.start_scanning_networks(): print("\t%s\t\tRSSI: %d\tChannel: %d" % (str(network.ssid, "utf-8"), network.rssi, network.channel)) wifi.radio.stop_scanning_networks() print(f"Connecting to {os.getenv('WIFI_SSID')}") wifi.radio.connect(os.getenv("WIFI_SSID"), os.getenv("WIFI_PASSWORD")) print(f"Connected to {os.getenv('WIFI_SSID')}") print(f"My IP address: {wifi.radio.ipv4_address}") 在串口中打印的信息如下: ESP32-S3 Station Test My MAC address: ['0xf4', '0x12', '0xfa', '0x59', '0xd4', '0xe0'] Available WiFi networks: HOST_BWG RSSI: -65 Channel: 6 CMCC-2301 RSSI: -72 Channel: 6 2101 RSSI: -63 Channel: 1 ChinaNet-bb4Z RSSI: -86 Channel: 1 TP-LINK_1404 RSSI: -90 Channel: 1 CMCC-2807 RSSI: -91 Channel: 11 花花之家 RSSI: -93 Channel: 11 2306 RSSI: -91 Channel: 4 Xiaomi_85AB RSSI: -88 Channel: 8 Linzai_2401 RSSI: -91 Channel: 5 Connecting to HOST_BWG Connected to HOST_BWG My IP address: 192.168.0.101 3.创建Wifi热点 创建Wifi热点时,同时采用类似的方法,首先在CIRCUTPY中的settings.toml定义要创建的热点的AP_SSID和AP_PASSWORD。settings.toml的内容示例如下: AP_SSID = "WIFI名称" AP_PASSWORD = "WIFI密码" 在code.py中添加以下代码, import os import wifi import adafruit_requests print("ESP32-S3 Access Point Test") print(f"My MAC address: {[hex(i) for i in wifi.radio.mac_address]}") wifi.radio.start_ap(os.getenv("AP_SSID"), os.getenv("AP_PASSWORD")) 在电脑上就可以搜索到创建的热点名。   4.总结 在官网和网上能找到的关于CircutPythton的Wifi使用教程,Wifi模块的设计高度模块化,各个函数的意义很明确,使用起来很方便,对于熟悉Wifi开发的人来说,可以很快地搭建应用,验证方案地可行性。

  • 发表了主题帖: 【得捷电子Follow me第2期】+任务1:控制屏幕显示中文

    Follow ME第2季使用到的开发板为Adafruit ESP32-S3 TFT Feather,板上载有TFT显示屏、NEOPixel指示灯以及电源管理芯片等外设,配合ESP32自身的Wifi和蓝牙功能,能够实现联网、获取网络数据并在显示屏上显示。 1 开发环境搭建 在Adafruit ESP32-S3 TFT Feather上进行开发,开发环境的搭建包括两部分,一是IDE的安装,这里选择Mu Editor,从官网下载安装包,安装选项选择默认即可。 安装完成后,选择开发板的运行模式为CircutPython。 在开发板上运行CircutPython需要烧写bootloader和CircutPython固件。其中bootloader固件只需要烧写一次即可,CircutPython固件可以选择不同版本的固件进行烧写。Bootloader固件烧写的方法通过esp flash tool下载,烧写前需要按组boot键,再按下rst键,最后松开boot键,进入Bootloader烧写模式。 完成上述操作后上电,就可以得到如下的画面: 此时,电脑上也会出现一个FTHRS3BOOT的虚拟U盘,从Adafruit官网下载该开发板对应的CircutPython UF2固件,将下载好的固件放入虚拟U盘中,会自动将固件烧写到芯片中。 烧写完成后会运行CircutPython,同时电脑上会出名为CIRCUITPY的USB设备,编写好的代码和库文件都存放在这里。其中的code.py是circutpython主程序的入口,其中的内容发生变化时,系统会复位并执行其中的代码。 2 控制屏幕显示中文 在屏幕上显示中文,需要屏幕的驱动、中文字库以及字符绘制驱动,其中屏幕的驱动在CircutPython固件中已经包含,可以通过REPL中输入help(‘modules’)查看已有的固件库。 中文字库由于需要占用较大的内存空间,使用carrothu-cn/chinese-bitmap-fonts (github.com)其中的一个字体(wenquanyi_10pt.pcf)。将字体文件存储到CIRCUTPY设备的lib文件夹下。就可以在程序中导入并使用该字符集了。 另外还需在lib文件夹下添加额外的adafruit_display_text库中的label, wrap_text_to_lines模块、adafruit_bitmap_font中的bitmap_font模块。这样就可以轻松地在显示屏上显示中文了。 CIRCUTPY设备上的lib文件夹中的内容如下。 开发板的BOOT按键可以作为按键输入来控制程序的运行,按键未按下时为True,通过检测其上升沿来调节显示文字的内容,显示中文的程序以及相应的注释如下。 # 在这里写上你的代码 :-) #导入使用到的lib import board import digitalio import displayio from adafruit_display_text import label, wrap_text_to_lines from adafruit_bitmap_font import bitmap_font #初始化按键相关变量 button = digitalio.DigitalInOut(board.BUTTON) button.switch_to_input(pull=digitalio.Pull.UP) button_buf = button.value #初始化显示屏参数 display = board.DISPLAY board.DISPLAY.brightness = 0.35 board.DISPLAY.rotation = 0 font = bitmap_font.load_font("lib\wenquanyi_10pt.pcf") color = 0xFF0000 text_change = 0 #设定文本显示范围 text_group = displayio.Group() text_area = label.Label(font, text="Follow ME2 ", color=color) text_area.x = 2 text_area.y = 10 text_area.line_spacing = 0.8 text_area.scale = 1 #启动屏幕显示 text_group.append(text_area) display.show(text_group) while True: # 检测按键边沿的上升沿,并改变文本切换控制变量 if ((button_buf != button.value) and (button.value==False)) : text_change = text_change + 1 button_buf = button.value if (text_change==1): text_area.text="EEWorld Forum社区\n" elif (text_change==2): text_area.text="ESP32 S3 Demo程序\n" elif (text_change==3): text_area.text="Feather Series产品\n" elif (text_change==4): text_change=1 程序的运行效果如视频所示。 [localvideo]2885a683356208111a344b12f6a6b09e[/localvideo]   3 问题 由于circuitpython固件的名字长度长,如果不注意可能会下载错固件型号,我在下载的时候就出现了这样的问题,在S3界面下载了S2的固件。文件名只差了一个字母,得到的结果则完全不同。大家做任务的时候一定要注意这个问题。

  • 2023-08-11
  • 回复了主题帖: 阅读打卡第一站:IO设备框架基础知识——《RT-Thread设备驱动开发指南》

    1.RT-Thread 设备基类是什么? rt_device 2.RT-Thread为设备提供了哪些操作方法? init、open、close、write、read、control 3.设备名的最大长度是什么指定的? 通过查看源码可以知道是由宏 RT_NAME_MAX 决定的。 4.设备注册失败,可能的原因是什么? 通过产看源码,设备注册失败可能的原因是dev为空、设备类型不存在、设备名超出最大字符串限制    

  • 回复了主题帖: 【得捷电子Follow Me第二期】第一章 收到货物的分享

    收到板子了,跟着大佬一起学习知识。

  • 2023-07-25
  • 加入了学习《Miz702 zynq视频初阶教程(米联客)》,观看 第十五章 ZYNQ AXI4总线详解及样例分析

最近访客

< 1/3 >

统计信息

已有34人来访过

  • 芯积分:515
  • 好友:--
  • 主题:19
  • 回复:81
  • 课时:--
  • 资源:--

留言

你需要登录后才可以留言 登录 | 注册


现在还没有留言