在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

基于ESP32和Wio Terminal的DeepSeeek移動(dòng)終端項(xiàng)目

柴火創(chuàng)客空間 ? 來(lái)源:柴火創(chuàng)客空間 ? 2025-02-28 16:51 ? 次閱讀

今天小標(biāo)給大家?guī)?lái)的是印度Maker的DeepSeek移動(dòng)終端項(xiàng)目,該項(xiàng)目使用ESP32開發(fā)板作為主控,結(jié)合Wio Terminal的屏幕進(jìn)行DeepSeeek輸出顯示。

2c42e6d0-f4fd-11ef-9310-92fbcf53809c.png

材料清單

Beetle ESP32 C6

面包板

跳線

Wio 終端

DFRobot Beetle ESP32 C6

2c79a5da-f4fd-11ef-9310-92fbcf53809c.jpg

高性能:配備 160MHz RISC-V 32 位處理器

多種通信協(xié)議:支持 Wi-Fi 6、藍(lán)牙 5、Zigbee 3.0 和 Thread 1.32。

超低功耗:具有深度睡眠模式,電流消耗僅為 14uA。

電池管理:集成鋰電池充電管理,使其適用于可穿戴應(yīng)用。

緊湊的尺寸:尺寸僅為 25*20.5 毫米,像硬幣一樣小。

Wio Terminal 是一個(gè)基于 ATSAMD51 微控制器的完整開源開發(fā)平臺(tái)。

2c9bbb02-f4fd-11ef-9310-92fbcf53809c.jpg

它具有 2.4 英寸 LCD 屏幕、板載傳感器和無(wú)線連接選項(xiàng),使其成為各種應(yīng)用的絕佳選擇。主要功能包括:

2cb381d8-f4fd-11ef-9310-92fbcf53809c.jpg

高性能:配備 120MHz ARM Cortex-M4F 處理器

顯示屏:2.4 英寸 LCD 屏幕,分辨率為 320x240

連接性:通過(guò)附加模塊支持 Wi-Fi、藍(lán)牙和 LoRa

多功能 I/O:包括 GPIO、數(shù)字、模擬I2CUART 和 SPI 接口

內(nèi)置傳感器:具有陀螺儀、加速度計(jì)、麥克風(fēng)和光傳感器。

使用 Wio Terminal,可以輕松擴(kuò)展 Beetle ESP32 聊天機(jī)器人項(xiàng)目的功能,提供實(shí)時(shí)反饋和交互式顯示。

設(shè)置硬件

首先將 LED 連接到 Beetle ESP32。以下是引腳連接:

電阻器將 LED1 連接到引腳 4。

這個(gè)簡(jiǎn)單的設(shè)置將使我們能夠通過(guò)閃爍的 LED 來(lái)可視化聊天機(jī)器人的活動(dòng)。

接下來(lái),通過(guò) UART 將 Wio 終端連接到 Beetle ESP32:

將 Wio Terminal 的 TX 引腳連接到 Beetle ESP32 C6 的 RX 引腳。

將 Wio Terminal 的 RX 引腳連接到 Beetle ESP32 C6 的 TX 引腳。

確保連接兩個(gè)設(shè)備的接地 (GND)。

2cc41296-f4fd-11ef-9310-92fbcf53809c.jpg

這個(gè)簡(jiǎn)單的設(shè)置將允許我們通過(guò)在 Wio 終端上顯示 API 響應(yīng)來(lái)可視化聊天機(jī)器人的活動(dòng)。

連接Wi-Fi

要將 Beetle ESP32 連接到 Wi-Fi 網(wǎng)絡(luò),請(qǐng)使用以下代碼片段:

#include


      
const char* ssid = "Your_SSID";      
const char* password = "Your_PASSWORD";      


      
void setup() {      
  Serial.begin(115200);      
  WiFi.begin(ssid, password);      
        
  while (WiFi.status() != WL_CONNECTED) {      
    delay(1000);      
    Serial.print(".");      
  }      
        
  Serial.println("Connected to WiFi");      
}

替換為本地實(shí)際 Wi-Fi 憑證 "Your_SSID""Your_PASSWORD"

創(chuàng)建 Web 服務(wù)器

接下來(lái),讓我們?cè)?Beetle ESP32 上設(shè)置一個(gè) Web 服務(wù)器:

// HTML content to be served
const char index_html[] PROGMEM = R"rawliteral(



  
  
  DFRobot Chatbot
  


  
  

DFRobot Beetle ESP32 C3 Chatbot

Debug Panel

)rawliteral";

此代碼設(shè)置了一個(gè)基本的 Web 服務(wù)器,該服務(wù)器用作 HTML 頁(yè)面,用戶可以在其中輸入他們的問(wèn)題。

2ce62020-f4fd-11ef-9310-92fbcf53809c.jpg

處理用戶問(wèn)題,首先導(dǎo)航到 Open router 并創(chuàng)建一個(gè)新的 API 密鑰。

2cff37f4-f4fd-11ef-9310-92fbcf53809c.jpg

將以下代碼添加到您的項(xiàng)目中:

HTTPClient http;          
    http.begin("https://openrouter.ai/api/v1/chat/completions");          
    http.addHeader("Content-Type", "application/json");          
    http.addHeader("Authorization", String("Bearer ") + apiKey);          




          
    StaticJsonDocument<512> jsonDoc;          
    jsonDoc["model"] = "deepseek/deepseek-r1-distill-llama-70b";  // deepseek/deepseek-r1-distill-llama-70b //openai/gpt-4o-mini-2024-07-18          
    JsonArray messages = jsonDoc.createNestedArray("messages");          




          
    JsonObject systemMessage = messages.createNestedObject();          
    systemMessage["role"] = "system";          
    systemMessage["content"] = "Answer the user's question concisely and informatively.";          




          
    JsonObject userMessage = messages.createNestedObject();          
    userMessage["role"] = "user";          
    userMessage["content"] = question;          




          
    String requestBody;          
    serializeJson(jsonDoc, requestBody);          




          
    Serial.println("Sending HTTP POST request...");          
    int httpResponseCode = http.POST(requestBody);          
    Serial.print("HTTP Response code: ");          
    Serial.println(httpResponseCode);          




          
    String response = http.getString();          
    Serial.print("HTTP Response: ");          
    Serial.println(response);          




          
    StaticJsonDocument<1024> responseDoc;          
    DeserializationError error = deserializeJson(responseDoc, response);          




          
    if (!error) {          
      String assistantResponse = responseDoc["choices"][0]["message"]["content"].as();      
      Serial.print("Assistant Response: ");      
      Serial.println(assistantResponse); // Print the assistant response      
      Serial1.println(assistantResponse);      
      return response; // Return entire API response      
    } else {      
      return "Failed to parse JSON response.";      
    }      
  }

不要忘記替換為 OpenAI 的實(shí)際 API 密鑰。"Your_API_Key"

最后,讓我們?cè)谔幚韱?wèn)題時(shí)通過(guò)閃爍 LED 來(lái)添加一些視覺(jué)反饋:

int led0 = 15;          
int led1 = 4;          




          
void setup() {          
  pinMode(led0, OUTPUT);          
  pinMode(led1, OUTPUT);          
}          




          
void loop() {          
  digitalWrite(led0, HIGH);          
  digitalWrite(led1, LOW);          
  delay(100);          
  digitalWrite(led0, LOW);          
  digitalWrite(led1, HIGH);          
  delay(100);          
}

Beetle ESP32 C6 代碼:

這是完整的草圖,請(qǐng)將憑據(jù)更改為您的憑據(jù)。

#include 
#include 
#include 
#include 

int led0 = 15;
int led1 = 4;

// WiFi credentials
const char* ssid = "";
const char* password = "";
const char* apiKey = "";

// Create WebServer object on port 80
WebServer server(80);

// HTML content to be served
const char index_html[] PROGMEM = R"rawliteral(



  
  
  DFRobot Chatbot
  


  
  

DFRobot Beetle ESP32 C3 Chatbot

Debug Panel

)rawliteral"; // Function to process the user question and get the response String processQuestion(String question) { Serial.print("User Question: "); Serial.println(question); // Print the user question if (WiFi.status() == WL_CONNECTED) { HTTPClient http; http.begin("https://openrouter.ai/api/v1/chat/completions"); http.addHeader("Content-Type", "application/json"); http.addHeader("Authorization", String("Bearer ") + apiKey); StaticJsonDocument<512> jsonDoc; jsonDoc["model"] = "deepseek/deepseek-r1-distill-llama-70b"; // deepseek/deepseek-r1-distill-llama-70b //openai/gpt-4o-mini-2024-07-18 JsonArray messages = jsonDoc.createNestedArray("messages"); JsonObject systemMessage = messages.createNestedObject(); systemMessage["role"] = "system"; systemMessage["content"] = "Answer the user's question concisely and informatively."; JsonObject userMessage = messages.createNestedObject(); userMessage["role"] = "user"; userMessage["content"] = question; String requestBody; serializeJson(jsonDoc, requestBody); Serial.println("Sending HTTP POST request..."); int httpResponseCode = http.POST(requestBody); Serial.print("HTTP Response code: "); Serial.println(httpResponseCode); String response = http.getString(); Serial.print("HTTP Response: "); Serial.println(response); StaticJsonDocument<1024> responseDoc; DeserializationError error = deserializeJson(responseDoc, response); if (!error) { String assistantResponse = responseDoc["choices"][0]["message"]["content"].as(); Serial.print("Assistant Response: "); Serial.println(assistantResponse); // Print the assistant response Serial1.println(assistantResponse); return response; // Return entire API response } else { return "Failed to parse JSON response."; } } return "WiFi not connected!"; } void setup() { // Start Serial Monitor Serial.begin(115200); Serial1.begin(9600, SERIAL_8N1, /*rx =*/17, /*tx =*/16); pinMode(led0, OUTPUT); pinMode(led1, OUTPUT); // Connect to Wi-Fi WiFi.begin(ssid, password); Serial.print("Connecting to WiFi..."); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.print("."); } Serial.println(" Connected to WiFi"); // Print ESP32 Local IP Address Serial.print("ESP32 IP Address: "); Serial.println(WiFi.localIP()); // Serve HTML content server.on("/", HTTP_GET, []() { server.send_P(200, "text/html", index_html); }); // Handle POST request from the web page server.on("/getQuestion", HTTP_POST, []() { if (server.hasArg("plain")) { String body = server.arg("plain");

Wio 終端代碼 :

將以下代碼上傳到 Wio 終端,從 Beetle 獲取數(shù)據(jù)并在屏幕上打印出來(lái)。

#include
#include// Include the graphics library (this includes the sprite functions)        


        
// Create a SoftwareSerial object on pins 2 (RX) and 3 (TX)        
SoftwareSerial mySerial(2, 3); // RX, TX        


        
// Initialize the TFT screen        
TFT_eSPI tft = TFT_eSPI();  // Create object "tft"        


        
// Screen dimensions        
#define SCREEN_WIDTH 320        
#define SCREEN_HEIGHT 240        


        
void setup() {        
  Serial.begin(115200);        
  mySerial.begin(9600);        


        
  // Initialize the TFT screen        
  tft.begin();        
  tft.setRotation(3); // Set the screen orientation (1 for landscape mode)        
  tft.fillScreen(TFT_BLACK); // Clear the screen with black color        
  tft.setTextColor(TFT_WHITE); // Set text color to white        
  tft.setTextSize(2); // Set text size        


        
  // Print initial message to the screen        
  tft.drawString("Waiting for data...", 10, 10);        
}        


        
void loop() {        
  while (mySerial.available()) {        
    String str = mySerial.readString(); // Read the incoming data as a string        
    str.trim();        
    Serial.println(str);        


        
    // Clear the screen and display the new data with text wrapping        
    tft.fillScreen(TFT_BLACK); // Clear the screen with black color        
    printWrappedText(str, 10, 10, SCREEN_WIDTH - 20, 2);        


        
    mySerial.println("initialization done.");        
  }        
}        


        
// Function to print wrapped text on the screen        
void printWrappedText(String str, int x, int y, int lineWidth, int textSize) {        
  tft.setCursor(x, y);        
  tft.setTextSize(textSize);        


        
  int cursorX = x;        
  int cursorY = y;        
  int spaceWidth = tft.textWidth(" ");        
  int maxLineWidth = lineWidth;        


        
  String word;        
  for (int i = 0; i < str.length(); i++) {        
    if (str[i] == ' ' || str[i] == '
') {        
      int wordWidth = tft.textWidth(word);        


        
      if (cursorX + wordWidth > maxLineWidth) {        
        cursorX = x;        
        cursorY += tft.fontHeight();        
      }        


        
      tft.drawString(word, cursorX, cursorY);        
      cursorX += wordWidth + spaceWidth;        


        
      if (str[i] == '
') {        
        cursorX = x;        
        cursorY += tft.fontHeight();        
      }        


        
      word = "";        
    } else {        
      word += str[i];        
    }        
  }        


        
  if (word.length() > 0) {        
    int wordWidth = tft.textWidth(word);        
    if (cursorX + wordWidth > maxLineWidth) {        
      cursorX = x;        
      cursorY += tft.fontHeight();        
    }        
    tft.drawString(word, cursorX, cursory);        
  }        
}

串行終端響應(yīng):

2d1e788a-f4fd-11ef-9310-92fbcf53809c.jpg

然后在 Web 瀏覽器中打開 IP 地址。

2d3e0f1a-f4fd-11ef-9310-92fbcf53809c.jpg

接下來(lái),輸入提示符。

2d569238-f4fd-11ef-9310-92fbcf53809c.jpg

您可以在 Wio 終端屏幕中看到響應(yīng)。

2d6f5e30-f4fd-11ef-9310-92fbcf53809c.jpg

如果您想查看整個(gè) API 響應(yīng),只需按網(wǎng)站上的 Debug log 按鈕即可。這將顯示完整的 API 響應(yīng)以進(jìn)行調(diào)試。

2d8f41a0-f4fd-11ef-9310-92fbcf53809c.jpg

結(jié)論

通過(guò)此項(xiàng)目,您已經(jīng)使用 Beetle ESP32 和 Wio Terminal 創(chuàng)建了一個(gè)基本的聊天機(jī)器人。可以通過(guò)添加更多功能(例如更多交互式網(wǎng)頁(yè)、高級(jí)錯(cuò)誤處理或集成其他 API)來(lái)進(jìn)一步擴(kuò)展此設(shè)置。DFRobot Beetle ESP32 C6 的緊湊尺寸和多功能功能,結(jié)合強(qiáng)大的 Wio 終端,使其成為各種物聯(lián)網(wǎng)應(yīng)用的絕佳選擇。

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 移動(dòng)終端
    +關(guān)注

    關(guān)注

    1

    文章

    216

    瀏覽量

    25168
  • ESP32
    +關(guān)注

    關(guān)注

    21

    文章

    1012

    瀏覽量

    18951
  • DeepSeek
    +關(guān)注

    關(guān)注

    1

    文章

    784

    瀏覽量

    1469

原文標(biāo)題:創(chuàng)客項(xiàng)目秀|基于ESP32和Wio Terminal的DeepSeeek終端

文章出處:【微信號(hào):ChaiHuoMakerSpace,微信公眾號(hào):柴火創(chuàng)客空間】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。

收藏 人收藏

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    《電子發(fā)燒友電子設(shè)計(jì)周報(bào)》聚焦硬科技領(lǐng)域核心價(jià)值 第2期:2025.03.3--2025.03.7

    E907 RISC-V MCU,能夠提供高效的計(jì)算能力。 基于ESP32Wio TerminalDeepSeeek移動(dòng)
    發(fā)表于 03-07 18:03

    WIO Terminal +MCP2515 實(shí)現(xiàn)車輛OBD的速度監(jiān)控

    WIO Terminal +MCP2515 實(shí)現(xiàn)車輛OBD的速度監(jiān)控
    發(fā)表于 06-14 11:05

    Wio Terminal是什么?

    有人知道Wio Terminal是什么嗎,能簡(jiǎn)單做一下介紹嗎,它都能做些什么?
    發(fā)表于 10-07 07:11

    esp32 例程 藍(lán)牙_wifi&amp;藍(lán)牙MCU 該不該選ESP32

    ESP32是了國(guó)內(nèi)樂(lè)鑫科技推出的Wifi&藍(lán)牙物聯(lián)網(wǎng)MCU,而最近項(xiàng)目正好在用ESP32,所以我們今天就來(lái)分享下,如何讓你的ESP32跑起來(lái),并應(yīng)用于更多實(shí)際
    發(fā)表于 12-06 20:06 ?31次下載
    <b class='flag-5'>esp32</b> 例程 藍(lán)牙_wifi&amp;藍(lán)牙MCU  該不該選<b class='flag-5'>ESP32</b>

    ESP32/STM32電源系統(tǒng)開源項(xiàng)目

    電子發(fā)燒友網(wǎng)站提供《ESP32/STM32電源系統(tǒng)開源項(xiàng)目.zip》資料免費(fèi)下載
    發(fā)表于 07-13 09:27 ?13次下載
    <b class='flag-5'>ESP32</b>/STM32電源系統(tǒng)開源<b class='flag-5'>項(xiàng)目</b>

    ESP32低成本板開源項(xiàng)目

    電子發(fā)燒友網(wǎng)站提供《ESP32低成本板開源項(xiàng)目.zip》資料免費(fèi)下載
    發(fā)表于 07-18 11:20 ?4次下載
    <b class='flag-5'>ESP32</b>低成本板開源<b class='flag-5'>項(xiàng)目</b>

    ESP32開源項(xiàng)目分享

    電子發(fā)燒友網(wǎng)站提供《ESP32開源項(xiàng)目分享.zip》資料免費(fèi)下載
    發(fā)表于 08-04 14:52 ?8次下載
    <b class='flag-5'>ESP32</b>開源<b class='flag-5'>項(xiàng)目</b>分享

    使用ESP32制作ESP RainMaker IoT項(xiàng)目

    電子發(fā)燒友網(wǎng)站提供《使用ESP32制作ESP RainMaker IoT項(xiàng)目.zip》資料免費(fèi)下載
    發(fā)表于 10-24 10:54 ?9次下載
    使用<b class='flag-5'>ESP32</b>制作<b class='flag-5'>ESP</b> RainMaker IoT<b class='flag-5'>項(xiàng)目</b>

    使用Wio終端擴(kuò)展Arduboy

    電子發(fā)燒友網(wǎng)站提供《使用Wio終端擴(kuò)展Arduboy.zip》資料免費(fèi)下載
    發(fā)表于 11-03 09:24 ?0次下載
    使用<b class='flag-5'>Wio</b><b class='flag-5'>終端</b>擴(kuò)展Arduboy

    ESP32房間項(xiàng)目

    電子發(fā)燒友網(wǎng)站提供《ESP32房間項(xiàng)目.zip》資料免費(fèi)下載
    發(fā)表于 11-08 09:23 ?1次下載
    <b class='flag-5'>ESP32</b>房間<b class='flag-5'>項(xiàng)目</b>

    使用ESP32進(jìn)行游戲仿真的開放項(xiàng)目

    電子發(fā)燒友網(wǎng)站提供《使用ESP32進(jìn)行游戲仿真的開放項(xiàng)目.zip》資料免費(fèi)下載
    發(fā)表于 11-17 10:20 ?1次下載
    使用<b class='flag-5'>ESP32</b>進(jìn)行游戲仿真的開放<b class='flag-5'>項(xiàng)目</b>

    使用Wio Terminal和Tensorflow Lite創(chuàng)建智能氣象站

    電子發(fā)燒友網(wǎng)站提供《使用Wio Terminal和Tensorflow Lite創(chuàng)建智能氣象站.zip》資料免費(fèi)下載
    發(fā)表于 06-25 10:30 ?0次下載
    使用<b class='flag-5'>Wio</b> <b class='flag-5'>Terminal</b>和Tensorflow Lite創(chuàng)建智能氣象站

    基于ESP32的開源項(xiàng)目

    電子發(fā)燒友網(wǎng)站提供《基于ESP32的開源項(xiàng)目.zip》資料免費(fèi)下載
    發(fā)表于 07-03 10:29 ?6次下載
    基于<b class='flag-5'>ESP32</b>的開源<b class='flag-5'>項(xiàng)目</b>

    Seeed Wio終端開源分享

    電子發(fā)燒友網(wǎng)站提供《Seeed Wio終端開源分享.zip》資料免費(fèi)下載
    發(fā)表于 07-12 10:04 ?0次下載
    Seeed <b class='flag-5'>Wio</b><b class='flag-5'>終端</b>開源分享

    ESP32開源項(xiàng)目

    電子發(fā)燒友網(wǎng)站提供《ESP32開源項(xiàng)目.zip》資料免費(fèi)下載
    發(fā)表于 07-13 10:47 ?7次下載
    <b class='flag-5'>ESP32</b>開源<b class='flag-5'>項(xiàng)目</b>
    主站蜘蛛池模板: 性夜黄 a 爽免费看 性夜黄a爽影免费看 | 一区一精品 | 在线欧美成人 | 日本不卡视频免费 | ts人妖系列在线专区 | 天天摸天天看 | 午夜日韩在线 | 天堂中文在线www | 免费人成在线观看视频播放 | 2021天天躁狠狠燥 | 国产精品久久久久久久午夜片 | 狠狠去| 天天干天天天天 | 萌白酱香蕉白丝护士服喷浆 | 无遮挡一级毛片视频 | 一级特色黄大片 | 美女性爽视频国产免费 | 天堂在线视频 | 日韩在线三级 | 黄网站播放| 日本v片免费一区二区三区 日本www.色 日本wwwwww | 国产精品天天看大片特色视频 | 色视频网站免费 | 农村的毛片丨级 | h视频免费高清在线观看 | 日本在线一本 | 亚洲丁香网| 国产在线麻豆自在拍91精品 | 五月婷婷俺也去开心 | 天天色成人 | 四虎影院免费视频 | 久青草免费视频 | 丁香婷婷在线观看 | 中文字幕一区二区三区永久 | 国模视频一区 | 奇米一区二区 | 性欧美精品久久久久久久 | 日本欧美视频 | 综合免费一区二区三区 | 快乐你懂的在线视频免费观看 | 国产一卡二卡≡卡四卡无人 |