Problem with ESP32-S3-DevKitC-1

Công Thịnh
Posts: 1
Joined: Fri Dec 06, 2024 7:48 am

Problem with ESP32-S3-DevKitC-1

Postby Công Thịnh » Fri Dec 06, 2024 8:08 am

I am new to the ESP32 world and recently purchased an ESP32-S3-DevKitC-1. However, I am facing several problems with my project. Here is the list of issues:

Wi-Fi Connection Problem:
I am having trouble connecting to Wi-Fi. I always need to press my finger on the top part of the ESP32-S3 for it to connect. If I don’t, it stays stuck in a loading mode. Moreover, even when it connects to Wi-Fi (by pressing my finger), the connection drops as soon as I remove my finger.

5V Pin Issue:
I am unable to use the 5V pin. I need to supply 5V to some sensors, but I can’t get any output from the 5V pin. I tested it with an LED, but the LED doesn’t light up.

Wi-Fi Handling Issue:
I often encounter problems with Wi-Fi handling. With the code I’m using (I’ve commented out most parts for testing), it runs fine as long as I don’t touch the top part of the ESP32-S3 with my finger. However, if I touch it, it connects to Wi-Fi but immediately reboots the program (the first serial print statement, “Ask your question: …,” gets printed right before the reboot).

I know I’m new and might be making mistakes. Please feel free to point out anything I’m doing wrong. I am open to learning and improving. Thank you for your help!

Code: Select all

#include <Arduino.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <Audio.h>

#define I2S_DOUT 37
#define I2S_BCLK 36
#define I2S_LRC  35

const char* ssid = "ssid";
const char* password = "password";
const char* chatgpt_token = "my token";
String res = "";
Audio audio;
void setup() {
  Serial.begin(115200);

  WiFi.mode(WIFI_STA);
  WiFi.disconnect();


  while (!Serial);

  // wait for WiFi connection
  WiFi.begin(ssid, password);
  Serial.print("Connecting to ");
  Serial.println(ssid);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }
  Serial.println("connected");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
  audio.setVolume(21); // 0...21
  Serial.println("Enter text to convert to speech:");

}

void loop() {
  
  Serial.print("Ask your Question : ");
  while (!Serial.available()) {
    audio.loop();
  }
  while (Serial.available()) {
    char add = Serial.read();
    res = res + add;
    delay(1);
  }
  int len = res.length();
  res = res.substring(0, (len - 1));
  Serial.println(res);

  res += " answer in 15 words";

  // HTTPClient https;

  // if (https.begin("https://api.openai.com/v1/chat/completions")) {  // HTTPS
  //   https.addHeader("Content-Type", "application/json");
  //   String token_key = String("Bearer ") + chatgpt_token;
  //   https.addHeader("Authorization", token_key);

  //   // Create JSON payload using ArduinoJson
  //   DynamicJsonDocument doc(1024);
  //   doc["model"] = "gpt-4o-2024-11-20";
  //   JsonArray messages = doc.createNestedArray("messages");
  //   JsonObject message = messages.createNestedObject();
  //   message["role"] = "user";
  //   message["content"] = res;
  //   doc["max_completion_tokens"] = 30;

  //   String payload;
  //   serializeJson(doc, payload);

  //   int httpCode = https.POST(payload);

  //   Serial.println(httpCode);
  //   Serial.println(payload);
    
  //   if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
  //     String response = https.getString();
  //     Serial.print(response);
  //     DynamicJsonDocument responseDoc(2048); // Increased size to accommodate larger JSON
  //     deserializeJson(responseDoc, response);

  //     JsonObject choices_0 = responseDoc["choices"][0];
  //     JsonObject message = choices_0["message"];
  //     String Answer = message["content"].as<String>();

  //     Serial.print("Answer : "); Serial.println(Answer);
  //     audio.connecttospeech(Answer.c_str(), "en");
  //   } else {
  //     Serial.printf("[HTTPS] GET... failed, error: %s\n", https.errorToString(httpCode).c_str());
  //   }
  //   https.end();
  // } else {
  //   Serial.printf("[HTTPS] Unable to connect\n");
  // }

  // Serial.println("Wait 10s before next round...");
  // res = "";
  //delay(10000);
}

void audio_info(const char *info) {
  Serial.print("audio_info: "); Serial.println(info);
}

Who is online

Users browsing this forum: MatthewRes and 78 guests