5.ChatGPT Tutorial
Backend Setup
To make the LAFVIN ESP32S3 AIChatBot work properly, you need to register an OpenAI platform account and obtain an API key.
Warning
This project uses the OpenAI API, which is billed separately from ChatGPT subscriptions. You need an OpenAI account with paid API balance before you can create and use an API key. Pricing information is available at https://openai.com/api/pricing/.
Model Used in This Project
This project uses the gpt-realtime-mini model.
At the time of writing, the official pricing for this model is:
Input:
$0.60per 1M tokensOutput:
$2.40per 1M tokensCached input:
$0.06per 1M tokens
For the latest model details and pricing, see the official OpenAI model page: gpt-realtime-mini
1. Obtaining OpenAI API Key
First, visit https://platform.openai.com/api-keys, then click the Create new secret key button
Select the Owner, Name, Project, and permissions as needed, and then click Create secret key.
After generation, copy this API key and save it in a secure and accessible place. For security reasons, you will not be able to view or copy this API key again after closing this page.
Firmware Upload
Online Flashing (Recommended)
The recommended method is to use the LAFVIN Web Flasher. It runs directly in Chrome or Edge and does not require you to install a separate flashing tool.
Note
Online flashing is supported only in Chrome or Edge browsers.
Warning
Use a USB Type-C cable that supports data transfer. A charging-only cable may power the board but will not work for flashing.
Note
On Windows, connect the USB Type-C data cable to the ESP32-S3 UART port on the left side of the board before clicking Connect. On macOS, connect the cable to the ESP32-S3 USB port on the right side, then press and hold BOOT, press RESET while still holding BOOT, and enter download mode before clicking Connect. The screen will turn black after the device enters download mode; this is normal.
For detailed instructions on using the online flasher, see Online Flasher.
Open the LAFVIN Web Flasher.
Select your device model. For this kit, choose
ESP32S3 AI Chatbot Kit.
Select the ChatGPT firmware and the firmware version you want to flash.
Connect the development board to your computer using the correct USB Type-C port for your operating system, as described in the note above.
Click
Connect, select the serial port for your ESP32-S3 device in the browser pop-up window, and confirm the connection.
Click
Flashand wait for the flashing process to complete.
After flashing is complete, restart the development board.
Note
If this is your first time flashing the device, enable Erase Flash in the web flasher before clicking Flash.
Local Flashing (Alternative)
If you cannot use the web flasher, you can use Espressif Flash Download Tools as an alternative.
Double-click to open Flash Download Tools, then select the options as shown below:
|
Follow these steps to upload the firmware:
Click the “Select File” button to choose your downloaded firmware file (.bin format)
In the address input box after the bin file selection box, enter
0 or 0x0(indicating that the firmware will be downloaded to the starting position of the development board’s memory)Select the COM port corresponding to ESP32-S3 from the port selection dropdown menu (refer to the Driver Installation section for how to check the device manager for the specific port number)
Set the baud rate (we use 460800 here)
Click the “START” button to begin downloading the firmware to the ESP32-S3 development board
Network and API Configuration
Note
The ESP32-S3 supports only 2.4 GHz Wi-Fi networks. In addition, the Wi-Fi network you choose must be able to access OpenAI’s servers.
After the firmware is flashed, press the RST button on the development board. The board will automatically restart and enter network configuration mode, displaying the configuration AP and password on the screen.
Connect your phone to the hotspot named ESP32_Config. You can manually enter
http://192.168.4.1in your browser to access the configuration interface.
Select your Wi-Fi network, enter the password, and fill in the API key. The network you use must be able to access OpenAI’s servers.
The development board will automatically restart, connect to your Wi-Fi, and connect to the AI service. If it does not restart after 30 seconds, press the RST button again.
Common Setup Issues
If the device cannot complete the setup successfully, check the following common issues.
API Key Error
If the API key is invalid, missing, or entered incorrectly, the device will display an API key error message on the screen.
Please check the following:
Make sure the API key was copied completely.
Make sure there are no extra spaces before or after the API key.
Make sure the API key is still valid and has not been deleted.
Cannot Connect to OpenAI
If the Wi-Fi network cannot reach OpenAI’s servers, the device will display a network connection error on the screen.
Please check the following:
Make sure your Wi-Fi network can access OpenAI’s servers.
Try another Wi-Fi network if the current one blocks or restricts access.
Restart the device after confirming that the network is working properly.
Re-enter AP Configuration Mode
If the Wi-Fi settings or API key are entered incorrectly, you can use the following steps to enter AP configuration mode again:
Open the online flasher and connect to the device by following the steps above.
After the connection is successful, click
Serial Monitor.Enter
reset_configin the input box.After the command is sent, the device will restart and re-enter AP configuration mode.
Tip:
If you want to adjust the volume, double-click the UP or DOWN button at the bottom of the expansion board. The volume will increase or decrease in 10% steps, and the change will be shown on the display.
At this point, the basic configuration of the ChatGPT firmware is complete. You can now start talking with the device and experience the intelligent interaction powered by ChatGPT.
For flashing help, driver troubleshooting, or alternative flashing methods, see Online Flasher.
