A conversational AI chatbot running on ESP32, powered by the Google Gemini API.
Communicates entirely through the Arduino Serial Monitor — no display or touchscreen required.
Maintains conversation history across 10 exchanges before auto-resetting to preserve memory.
Serial Monitor → ESP32 → Gemini API → Response → Serial Monitor
- ESP32 connects to WiFi (credentials entered at runtime — not hardcoded)
- User types a question in Serial Monitor
- ESP32 sends the question + conversation history to Gemini API over HTTPS
- Gemini response is parsed, cleaned, and printed back
- Token usage is displayed after every reply
| Component | Details |
|---|---|
| ESP32 Board | Any variant (DevKit, NodeMCU) |
| USB Cable | For power and code upload |
| PC / Laptop | Arduino IDE + Serial Monitor |
| Library | Source |
|---|---|
WiFi |
Built-in (ESP32 core) |
HTTPClient |
Built-in (ESP32 core) |
WiFiClientSecure |
Built-in (ESP32 core) |
ArduinoJson |
Arduino Library Manager |
Install ArduinoJson by Benoit Blanchon via Library Manager (
Sketch → Include Library → Manage Libraries)
- Visit Google AI Studio
- Generate a Gemini API key
- Open the
.inofile and paste your key:
const char* key = "YOUR_API_KEY_HERE";
⚠️ Never commit your API key to GitHub.
The key field is intentionally left blank ("") in this repository.
See Key Safety below.
All tunable parameters are at the top of the .ino file:
| Parameter | Default | Description |
|---|---|---|
key |
"" |
Your Gemini API key |
maxOutputTokens |
2000 |
Maximum length of Gemini's reply |
temperature |
0.7 |
Response creativity (0.0 strict → 1.0 creative) |
WiFi credentials (SSID + password) are entered at runtime via Serial Monitor — they are never stored in the code.
Getting these wrong is the most common reason input is never received.
| Setting | Value |
|---|---|
| Baud Rate | 115200 |
| Line Ending | Newline |
- The
keyfield in both versions is left as""— safe to clone and share - Never paste your key and push to GitHub — it will be exposed publicly
- If you accidentally commit a key: revoke it immediately at Google AI Studio and generate a new one
- For future projects consider using a
secrets.hfile — already covered in.gitignorehere
| Feature | v1 | v2 |
|---|---|---|
| Comment Style | Basic (// ---) |
Box-style (//==== headers) |
| User Label | Your Question Asked: You : | Your Question Asked: You : |
| Reply Label | Your Answer: Gemini : | Your Answer: Gemini : |
| Token Display | Plain text | Clean structured output |
| Formatting | Raw API output | Markdown cleaned |
| Markdown Handling | ❌ No cleaning | ✅ Removes ** * # ` |
| Newline Handling | ❌ Not processed | ✅ Converts \n to real line breaks |
| History Reset Message | Simple text | Clear “History is RESET” message |
| Memory Reset | After 10 Qs | After 10 Qs (better handling) |
→ API testing reference: POSTMAN_GUIDE.md
- SSL certificate verification is disabled (
setInsecure()) — acceptable for embedded hobby projects - Conversation history is stored as a raw String — resets every 10 exchanges to prevent memory overflow
- No persistent storage — history is lost on reset or power cycle
MIT License — free to use, modify, and distribute with attribution.