ESP_GEM is an ESP32-S3-based AI camera project that captures images, analyzes them using Google's Gemini AI, and provides a web interface for viewing results. It supports real-time chat with the AI about captured images and logs conversations.
- Image Capture: High-quality image capture using ESP32-S3-EYE with OV2640/OV3660 camera.
- AI Analysis: Upload images to Gemini API for detailed descriptions and analysis.
- Serial Chat: Interact with Gemini via serial commands, including image context.
- Web Server: Built-in web server to view captured images and chat logs.
- Persistent Storage: Saves images and logs to LittleFS, with unique filenames(using Time API).
- LED Indicator: Visual feedback during capture using GPIO2.
- Command System: Supports CAPTURE, CHAT, RESET, and CLEAR commands via serial.
- ESP32-S3-EYE Development Board: Includes camera, LCD, and microphone (camera module used here).
- USB Cable: For programming and power.
- Optional: External LED on GPIO2 for visual feedback.
- PlatformIO: For building and uploading the project.
- Arduino Framework: ESP32 board support.
- Libraries:
- ArduinoJson
- esp32-camera
- ESP32Async/AsyncTCP
- ESP32Async/ESPAsyncWebServer
- Preferences (built-in ESP32)
-
Clone the Repository:
git clone https://github.com/niru124/ESP32S3-Gemini.git cd ESP_GEM -
Install PlatformIO: If not installed, follow PlatformIO installation guide.
-
Configure Gemini API:
- Obtain a Gemini API key from Google AI Studio.
- In
src/config.cppor environment variables, setGEMINI_API_KEYandGEMINI_MODELandRegionfor Time API.
-
WiFi Setup:
- Update
ssidandpasswordin the code for your network.
- Update
-
Build and Upload:
pio run -t upload
-
Monitor Serial:
pio device monitor
-
Power On: The ESP32 connects to WiFi and starts the web server.
-
Capture Image:
- Send
CAPTURE:via serial monitor. - Image is saved to LittleFS and uploaded to Gemini.
- Send
-
Chat with AI:
- Send
CHAT:<message>to query Gemini, including the last captured image context.
- Send
-
Web Interface:
- Access
http://<ESP32_IP>/for the main page. http://<ESP32_IP>/api/imageslists .jpg files.http://<ESP32_IP>/api/fileslists .md logs.- Direct links:
http://<ESP32_IP>/<filename>.
- Access
- CAPTURE: Captures and uploads an image to Gemini.
- CHAT: Sends a message to Gemini, including image context.
- RESET: Resets the image counter in Preferences.
- CLEAR: Deletes all files in LittleFS.
- Camera Settings: Adjusted in
src/camera.cpp(brightness, contrast, etc.). - LED Pin: GPIO2 in
src/main.cppandsrc/serial.cpp. - File Storage: LittleFS for images (.jpg) and logs (.md).
- Time API: Used for timestamped filenames; falls back to counters using Preferences.h.
- Camera Not Working: Check camera pins in
include/camera.h. Ensure PSRAM is enabled. - WiFi Issues: Verify credentials and network.
- Gemini Errors: Check API key and quota.
- Image Quality: Adjust lighting or camera settings.
- Web Server: Hard refresh browser if images don't update.
- Serial Issues: Ensure correct line endings (CRLF).
src/: Main source files (main.cpp, camera.cpp, serial.cpp, etc.).include/: Headers (camera.h, config.h, etc.).lib/: Custom libraries if any.test/: Test files.platformio.ini: Build configuration.
- Neovim PlatformIO.
- ESP32 community and Espressif.
- Google Gemini API.
- PlatformIO for tooling.