Skip to main content

Documentation Index

Fetch the complete documentation index at: https://learn.pcbcupid.com/llms.txt

Use this file to discover all available pages before exploring further.

ESP32 Voice Chatbot

Think of this as your own mini Alexa/Google Assistant, but built by you. You press a button, speak something, and the AI replies back through the speaker.

How it Works? (The Simple Version)

Even though it’s small, your ESP32 is performing a complex workflow:
  1. ESP32 records your voice when you press the button.
  2. That audio is sent to Deepgram → converts speech to text.
  3. The text is sent to n8n → acts like a middleman.
  4. n8n sends it to Groq AI → generates a reply.
  5. The reply is sent back to Deepgram → converted into audio.
  6. ESP32 receives the audio and plays it through the speaker.

What You Need

Before starting, make sure you have everything ready.

Hardware Required

  • ESP32-C3 board (your main device).
  • I2S microphone (to capture your voice).
  • Small speaker (to hear responses).
  • USB cable (for power + uploading code).
Circuit Diagram
Basically: input (mic) → processing (ESP32) → output (speaker)

Software

  • VS Code with PlatformIO extension.
  • Node.js (v18 or v20).
  • n8n: Workflow automation.
  • Deepgram Accounts: For voice (speech ↔ text).
  • Groq Accounts: For AI responses.
Keep your API keys safe! Without them, your device won’t “understand” or “talk”.

Software Setup

Step 1: Install Everything

Take this step slow — this is your foundation.
  1. Install VS Code: This is where everything will happen.
  2. Install PlatformIO: Open VS Code → go to Extensions → Search PlatformIO and install it.
  3. Install Node.js (v18 or v20): Required to run n8n.
  4. Install n8n: Open your terminal and run:
    npm install -g n8n
    

Step 2: Get API Keys

Now you’re connecting your project to real services.
  1. Go to Deepgram → create account → copy API key.
  2. Go to Groq → create account → copy API key.
Think of API keys like passwords that allow your device to use these services.

Step 3: Setup n8n (The Brain)

n8n is what connects everything together.
  1. Start n8n: Run this in your terminal:
    n8n start
    
    Open in browser: http://localhost:5678
  2. Import Workflow:
    • Go to Workflows → Click Import.
    • Copy the JSON code below and paste it into the import box.
    • Click Save and turn it Active (ON).
Workflow
  1. Add Your API Keys:
    • Open Groq node → Replace the existing key with yours.
    • Open Deepgram node → Replace with your key.
  2. Test It (curl command): Run this command in your terminal:
    curl -X POST http://YOUR_IP:5678/webhook/esp32-voice -d '{"query":"Hello"}'
    
    • If you get audio → everything is working!

Step 4: Setup ESP32 Code

Now we move to the device itself.
  1. Create Project Structure: Your folder should look like this:
    voice-chatbot/
    ├── lib/
    │   └── PCBCUPID_NAU8325/   <-- Add the library here
    ├── src/
    │   └── main.cpp            <-- Your Arduino code
    └── platformio.ini          <-- Settings file
    
  2. Configure platformio.ini:
    [env:esp32-c3-devkitm-1]
    platform = espressif32
    board = esp32-c3-devkitm-1
    framework = arduino
    monitor_speed = 115200
    
  3. Add Required Library: Download the NAU8325 library and place it inside lib/. Without this, your speaker won’t work.
  4. Full Arduino Source Code: Copy the code below into your main.cpp file.
  1. Update Your Settings: Inside main.cpp, update:
    const char* WIFI_SSID = "YOUR_WIFI";
    const char* WIFI_PASSWORD = "YOUR_PASSWORD";
    const char* N8N_HOST = "YOUR_SERVER_IP";
    const int N8N_PORT = 5678;
    const char* DEEPGRAM_API_KEY = "YOUR_KEY";
    

Step 5: Upload Code to ESP32

Now bring your device to life.
  1. Connect ESP32 using USB.
  2. Open project in VS Code.
  3. Click Upload (or run pio run --target upload).

Step 6: First Boot & Monitor

Open the Serial Monitor (115200 baud). You should see: [READY] Hold BOOT to speak 👉 This means WiFi is connected and the AI is ready to listen!

Step 7: How to Use

Voice Mode (Main Feature)

  1. Hold the BOOT button.
  2. Speak clearly into the microphone.
  3. Release the button.
  4. Wait a second for the AI response.
Keep your voice commands short (1–2 seconds) for the fastest response!

Text Mode (Testing)

Type your message in the Serial Monitor and press Enter. Result Result

❗ Common Issues (Quick Fixes)

IssueCheck
No SoundCheck speaker wiring & amplifier logs.
No ResponseEnsure n8n is running & WiFi is connected.
Not UnderstandingSpeak louder, hold button longer, check Deepgram API key.
Server Not OpeningCheck http://YOUR_IP:5678 - fix server first.

Customization (Make It Yours)

Change AI Personality

Inside n8n, update the prompt: "You are a smart assistant. Reply in one short sentence."

Adjust Volume

Inside your code, locate and change:
#define VOL_BOOST 6
Have fun with your mini AI Assistant!