12573浏览
查看: 12573|回复: 0

[ESP8266/ESP32] FireBeetle 2 ESP32 C6-WOL网络唤醒电脑

[复制链接]
本帖最后由 派大星ym 于 2024-4-14 21:47 编辑

FireBeetle 2 ESP32 C6-WOL网络唤醒电脑图2




最近参加了DF发布的ESP32C6的试用活动,很幸运获得了试用资格,
收到板子后,用卡尺测量尺寸画了个模型。


FireBeetle 2 ESP32 C6-WOL网络唤醒电脑图1



ESP32-C6简介

FireBeetle 2 ESP32-C6是一款基于ESP32-C6芯片设计的低功耗物联网开发板,适用于智能家居项目。ESP32-C6搭载160MHz的高性能RISC-V 32位处理器,支持Wi-Fi 6、Bluetooth 5、Zigbee 3.0、Thread 1.3通讯协议,可接入多种通讯协议的物联网网络。FireBeetle 2 ESP32-C6支持Type-C、5V DC、太阳能对锂电池进行充电,部署时有更多的供电方式选择。




首次使用





C6驱动显示屏(透明屏)

FireBeetle 2 ESP32 C6-WOL网络唤醒电脑图3

这里的板载GDI接口可以轻松的连接屏幕,(非常方便nice)

  1. /*!
  2. * @file Cube.ino
  3. * @brief Rotating 3D stereoscopic graphics
  4. * @n This is a simple rotating tetrahexon
  5. *
  6. * @copyright  Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
  7. * @licence     The MIT License (MIT)
  8. * @author [Ivey](Ivey.lu@dfrobot.com)
  9. * @maintainer [Fary](feng.yang@dfrobot.com)
  10. * @version  V1.0
  11. * @maintainer [Fary](feng.yang@dfrobot.com)
  12. * @version  V1.0
  13. * @date  2019-10-15
  14. * @url https://github.com/DFRobot/U8g2_Arduino
  15. */
  16. #include <Arduino.h>
  17. #include <U8g2lib.h>
  18. #include <SPI.h>
  19. /*
  20. * Display hardware IIC interface constructor
  21. *@param rotation:U8G2_R0 Not rotate, horizontally, draw direction from left to right
  22.            U8G2_R1 Rotate clockwise 90 degrees, drawing direction from top to bottom
  23.            U8G2_R2 Rotate 180 degrees clockwise, drawing in right-to-left directions
  24.            U8G2_R3 Rotate clockwise 270 degrees, drawing direction from bottom to top
  25.            U8G2_MIRROR Normal display of mirror content (v2.6.x version used above)
  26.            Note: U8G2_MIRROR need to be used with setFlipMode().
  27. *@param reset:U8x8_PIN_NONE Indicates that the pin is empty and no reset pin is used
  28. * Display hardware SPI interface constructor
  29. *@param  Just connect the CS pin (pins are optional)
  30. *@param  Just connect the DC pin (pins are optional)
  31. *
  32. */
  33. #if defined ARDUINO_SAM_ZERO
  34. #define OLED_DC  7
  35. #define OLED_CS  5
  36. #define OLED_RST 6
  37. /*ESP32 */
  38. #elif defined(ESP32)
  39. #define OLED_DC  D2
  40. #define OLED_CS  D6
  41. #define OLED_RST D3
  42. /*ESP8266*/
  43. #elif defined(ESP8266)
  44. #define OLED_DC  D4
  45. #define OLED_CS  D6
  46. #define OLED_RST D5
  47. /*AVR series board*/
  48. #else
  49. #define OLED_DC  2
  50. #define OLED_CS  3
  51. #define OLED_RST 4
  52. #endif
  53. U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(/* rotation=*/U8G2_R0, /* cs=*/ OLED_CS, /* dc=*/ OLED_DC,/* reset=*/OLED_RST);
  54. //2D array: The coordinates of all vertices of the tetrahesome are stored
  55. double tetrahedron[4][3] = {{0,20,-20},{-20,-20,-20},{20,-20,-20},{0,0,20}};
  56. void setup(void) {
  57.   u8g2.begin();  
  58. }
  59. void loop(void) {
  60.   /*
  61.        * firstPage will change the current page number position to 0
  62.        * When modifications are between firstpage and nextPage, they will be re-rendered at each time.
  63.        * This method consumes less ram space than sendBuffer
  64.    */
  65.   u8g2.firstPage();
  66.   do {
  67.   //Connect the corresponding points inside the tetrahethal together
  68.   u8g2.drawLine(OxyzToOu(tetrahedron[0][0], tetrahedron[0][2]), OxyzToOv(tetrahedron[0][1], tetrahedron[0][2]), OxyzToOu(tetrahedron[1][0], tetrahedron[1][2]), OxyzToOv(tetrahedron[1][1], tetrahedron[1][2]));
  69.   u8g2.drawLine(OxyzToOu(tetrahedron[1][0], tetrahedron[1][2]), OxyzToOv(tetrahedron[1][1], tetrahedron[1][2]), OxyzToOu(tetrahedron[2][0], tetrahedron[2][2]), OxyzToOv(tetrahedron[2][1], tetrahedron[2][2]));
  70.   u8g2.drawLine(OxyzToOu(tetrahedron[0][0], tetrahedron[0][2]), OxyzToOv(tetrahedron[0][1], tetrahedron[0][2]), OxyzToOu(tetrahedron[2][0], tetrahedron[2][2]), OxyzToOv(tetrahedron[2][1], tetrahedron[2][2]));
  71.   u8g2.drawLine(OxyzToOu(tetrahedron[0][0], tetrahedron[0][2]), OxyzToOv(tetrahedron[0][1], tetrahedron[0][2]), OxyzToOu(tetrahedron[3][0], tetrahedron[3][2]), OxyzToOv(tetrahedron[3][1], tetrahedron[3][2]));
  72.   u8g2.drawLine(OxyzToOu(tetrahedron[1][0], tetrahedron[1][2]), OxyzToOv(tetrahedron[1][1], tetrahedron[1][2]), OxyzToOu(tetrahedron[3][0], tetrahedron[3][2]), OxyzToOv(tetrahedron[3][1], tetrahedron[3][2]));
  73.   u8g2.drawLine(OxyzToOu(tetrahedron[2][0], tetrahedron[2][2]), OxyzToOv(tetrahedron[2][1], tetrahedron[2][2]), OxyzToOu(tetrahedron[3][0], tetrahedron[3][2]), OxyzToOv(tetrahedron[3][1], tetrahedron[3][2]));
  74.   // Rotate 0.1°
  75.   rotate(0.1);
  76.   } while ( u8g2.nextPage() );
  77.   //delay(50);
  78. }
  79. /*!
  80. * @brief Convert xz in the three-dimensional coordinate system Oxyz
  81. * into the u coordinate inside the two-dimensional coordinate system Ouv
  82. * @param x in Oxyz  
  83. * @param z in Oxyz
  84. * @return u in Ouv
  85. */
  86. int OxyzToOu(double x,double z){
  87.    return (int)((x + 64) - z*0.35);
  88. }
  89. /*!
  90. * @brief Convert the yz in the three-dimensional coordinate system Oxyz into the v coordinate inside
  91. * the two-dimensional coordinate system Ouv
  92. * @param y in Oxyz  
  93. * @param z in Oxyz
  94. * @return v in Ouv
  95. */
  96. int OxyzToOv(double y,double z){
  97.     return (int)((y + 26) - z*0.35);
  98. }
  99. /*!
  100. * @brief  Rotate the coordinates of all points of the entire 3D graphic around the Z axis
  101. * @param  angle represents the angle to rotate
  102. *     
  103. *  z rotation (z unchanged)
  104.     x3 = x2 * cosb - y1 * sinb
  105.     y3 = y1 * cosb + x2 * sinb
  106.     z3 = z2
  107. */
  108. void rotate(double angle)
  109. {
  110.   double rad, cosa, sina, Xn, Yn;
  111.   rad = angle * PI / 180;
  112.   cosa = cos(rad);
  113.   sina = sin(rad);
  114.   for (int i = 0; i < 4; i++)
  115.   {
  116.     Xn = (tetrahedron[i][0] * cosa) - (tetrahedron[i][1] * sina);
  117.     Yn = (tetrahedron[i][0] * sina) + (tetrahedron[i][1] * cosa);
  118.     //Store converted coordinates into an array of coordinates
  119.     //Because it rotates around the Z-axis, the coordinates of the point z-axis remain unchanged
  120.     tetrahedron[i][0] = Xn;
  121.     tetrahedron[i][1] = Yn;
  122.   }
  123. }
复制代码



不得不说透明屏的显示效果-厉害

FireBeetle 2 ESP32 C6-WOL网络唤醒电脑图4



OK点亮完炫酷的透明屏,接下来实现一个实用的应用



WOL网络唤醒

当你出门在外需要远程开机电脑,你会采用什么方法来实现需求啦。拆开机箱安装开机卡;购买智能插座设置电脑为来电启动。可我并不想对电脑硬件有任何的改动以及不想额外花销去购买智能插座,目前似乎能满足我需求的就是WOL网络唤醒技术。
网络唤醒(Wake-on-LAN,WOL)是一种计算机局域网唤醒技术,使局域网内处于关机或休眠状态的计算机,将状态转换成引导(Boot Loader)或运行状态



FireBeetle 2 ESP32 C6-WOL网络唤醒电脑图5




将C6连接在电脑同一局域网上,当按键按下时C6执行向局域网内9号端口广播带有要开机电脑网卡MAC地址的幻数据包来激活电脑
(当电脑开启了网络唤醒后,网卡会在关机的时候用非常低的功耗来接收数据并激活电脑)
  1. #include <WiFi.h>
  2. #include <WiFiUdp.h>
  3. #ifndef STASSID
  4. #define STASSID "***"
  5. #define STAPSK  "***"
  6. #endif
  7. #define port 9   
  8. const char* ssid     = STASSID;
  9. const char* password = STAPSK;
  10. WiFiUDP Udp;   
  11. bool isWarn=false;
  12. void setup() {
  13.   pinMode(D2,INPUT_PULLUP);
  14.   Serial.begin(115200);
  15.   Serial.println();
  16.   Serial.println();
  17.   Serial.print("Connecting to ");
  18.   Serial.println(ssid);
  19.   WiFi.mode(WIFI_STA);
  20.   WiFi.begin(ssid, password);
  21.   while (WiFi.status() != WL_CONNECTED) {
  22.     delay(500);
  23.     Serial.print(".");
  24.   }
  25.   Serial.println("");
  26.   Serial.println("WiFi connected");
  27.   Serial.println("IP address: ");
  28.   Serial.println(WiFi.localIP());
  29. }
  30. void loop() {
  31.   if(!digitalRead(D2)){
  32.     if(!isWarn){
  33.       
  34.     int i=0;
  35.     char mac[6]={0x04,0x7C,0x16,0x5A,0xD5,0x8C};  
  36.     char pac[102];
  37.     char * Address = "192.168.1.255";
  38.     int Port = 3333;
  39.     for(i=0;i<6;i++)
  40.     {
  41.       pac[i]=0xFF;
  42.     }
  43.     for(i=6;i<102;i+=6)
  44.     {
  45.       memcpy(pac+i,mac,6);
  46.     }
  47.     Udp.beginPacket(Address, Port);
  48.     Udp.write((byte*)pac, 102);
  49.     Udp.endPacket();
  50.     }
  51.     delay(500);
  52.   }
  53. }
复制代码


将C6的D2与GND引脚短接,电脑响应开机(这里的延时非常小最多1秒左右)如果唤醒失败,首先确保自己的电脑主板支持唤醒(现在的主板一般都是支持唤醒功能的),其次确保UDP广播端口/MAC地址正确,其次电脑的BIOS设置允许唤醒开启/网卡的魔术包唤醒功能开启。

这里C6需要和电脑在同一局域网下,如果再将C6接入物联网平台例如阿里云/Blynk等即可实现远程唤醒电脑








本来外壳模型计划用莫嘉的1元CNC活动加工的 ,但模型不符合活动的要求,~~在修改修改吧



ESP32 C6模型
下载附件ESP32C6.zip


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail