Community project

Pocket AI Vision Assistant

Photo of Pocket AI Vision Assistant

Mohd Zubair

Published November 30, 2026

The Pocket AI Vision Assistant is a compact, battery-powered device that captures images and sends them to cloud AI services for analysis, displaying results on a small OLED screen. Built around an ESP32 microcontroller with an integrated camera module, it draws power from a rechargeable LiPo battery managed by a smart charger-booster module, making it truly portable for on-the-go vision tasks.

This guide provides a complete parts list, wiring diagram, and step-by-step assembly instructions to get the device running. The included firmware handles camera initialization, WiFi connectivity, image encoding, and cloud API communication, so builders can focus on soldering connections and testing the system before final enclosure assembly.

Wiring diagram

Wiring diagram for Pocket AI Vision Assistant
Loading diagram…

Gather all the parts

QtyComponent
1

SH1106 OLED

1.3 inch 128x64 OLED display with I2C interface using the SH1106 controller

1

LiPo 3.7V 1000mAh Battery

Protected single-cell 1000mAh pack; rated for at least 1A discharge

Single-cell LiPo pack, nominal 3.7 V, 1000 mAh. Default rechargeable choice for portable ESP32 / Pico projects. Pair with a TP4056 charger for safe USB recharging.

1

SmartElex 5V 1A LiPo Charger Booster Module with ON/OFF switch

MCP73831 single-cell charger and PAM2401 5V booster. Use the onboard switch; charge only while switched off. Functional terminal names below refer to battery connector and 5V output pads, not connector position.

Assemble it in 4 steps

1. Check the power module before soldering

Use the specified SmartElex single-cell 5V 1A charger booster with its ON/OFF switch. Identify the battery connector polarity and 5V output polarity from its markings. The schematic names BAT+/BAT- and OUT+/OUT- describe their jobs, not connector positions. Check with a meter that OFF removes output power and ON gives about 5V before connecting the ESP32-CAM.

  • Use only one protected 3.7V cell. Never put cells in series. Verify connector polarity; reversed battery wiring can cause fire. Do not use a module whose switch does not disconnect the load.

2. Solder the screen wires

With the battery disconnected, solder OLED VCC to ESP32-CAM 3V3 (screen power), GND to GND (return), SDA to GPIO13 (data), and SCL to GPIO14 (clock). Keep wires short and insulate joints. Leave the microSD slot empty; these pins are used by the screen instead.

3. Connect switched power

Solder charger 5V output positive to ESP32-CAM 5V and output negative to GND. Connect the protected battery only after checking all joints. Battery must support at least 1A discharge and the module's charging current; confirm that current is within the battery manufacturer's rating.

  • Charge only with the device switched OFF; charge termination under load is not verified. Never connect programmer power and booster output at the same time. Do not solder directly to a pouch cell.

4. Fit the enclosure after an open-case test

Measure the actual boards, battery, lens height and connectors before printing. Target 70 x 45 x 20 mm is provisional, not a guaranteed fit. Place OLED at front, camera and ZUBAIR branding at back, module switch at side and charging port at bottom. Use matte charcoal number 252A32. Provide insulated mounts, battery clearance, a reinforced keyring loop and antenna clearance. No breadboard or capture button is needed.

  • Use thin insulated soldered wire and removable enclosure screws. Leave access to programming pads. The ESP32-CAM needs an external USB serial programming adapter or compatible programming base for Deploy; the charger port is charging only.
  • Do not squeeze or puncture the pouch battery. Keep it away from hot regulator and charger components. Charge supervised on a nonflammable surface. AI identification is not a food or poisonous-plant safety test.

Review all connections

1. Connections between "oled" and "ESP32"

FunctionoledESP32
powerVCC3V3
groundGNDGND
i2cSDAGPIO 13
i2cSCLGPIO 14

2. Connections between "battery" and "ESP32"

FunctionbatteryESP32
power+V → SmartElex 5V 1A LiPo Charger Booster Module with ON/OFF switch BAT+EXT
groundGND → SmartElex 5V 1A LiPo Charger Booster Module with ON/OFF switch BAT-EXT

3. Connections between "charger" and "ESP32"

FunctionchargerESP32
powerOUT+5V
groundOUT-GND

Deploy the firmware

#include <Arduino.h>
#include <Wire.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <HTTPClient.h>
#include <Adafruit_SH110X.h>
#include <ArduinoJson.h>
#include "esp_camera.h"
#include "img_converters.h"
#include "mbedtls/base64.h"
#include <time.h>
#include "config.h"
#include "trust.h"
Adafruit_SH1106G oled(128,64,&Wire,-1);
bool screen=false, cameraOK=false;
String shown;
void show(String s) {
 if(s==shown) return; shown=s; Serial.println(s);
 if(!screen)return;
 oled.clearDisplay(); oled.setTextSize(1); oled.setTextColor(SH110X_WHITE); oled.setCursor(0,0); oled.println("ZUBAIR Smart Vision"); oled.println(); oled.print(s); oled.display();
}
bool initCamera(){
 camera_config_t c={};
 c.ledc_channel=LEDC_CHANNEL_0; c.ledc_timer=LEDC_TIMER_0;
 c.pin_d0=5;c.pin_d1=18;c.pin_d2=19;c.pin_d3=21;c.pin_d4=36;c.pin_d5=39;c.pin_d6=34;c.pin_d7=35;
 c.pin_xclk=0;c.pin_pclk=22;c.pin_vsync=25;c.pin_href=23;c.pin_sccb_sda=26;c.pin_sccb_scl=27;c.pin_pwdn=32;c.pin_reset=-1;
 c.xclk_freq_hz=20000000;c.pixel_format=PIXFORMAT_JPEG;c.frame_size=FRAMESIZE_QVGA;c.jpeg_quality=14;c.fb_count=1;
 return esp_camera_init(&c)==ESP_OK;
}
uint8_t previous[192], baseline[192]; bool havePrev=false,haveBase=false;
uint32_t lastSample=0,lastCall=0; int stable=0; bool pending=true;
bool signature(camera_fb_t *fb,uint8_t *out){
 uint8_t *rgb=(uint8_t*)ps_malloc(fb->width*fb->height*3);
 if(!rgb)return false;
 bool ok=fmt2rgb888(fb->buf,fb->len,fb->format,rgb);
 if(ok)for(int y=0;y<12;y++)for(int x=0;x<16;x++){
  int i=(((y*fb->height/12)+fb->height/24)*fb->width+x*fb->width/16+fb->width/32)*3;
  out[y*16+x]=(rgb[i]+rgb[i+1]+rgb[i+2])/3;
 }
 free(rgb);return ok;
}
int distance(const uint8_t*a,const uint8_t*b){int n=0;for(int i=0;i<192;i++)n+=abs(int(a[i])-int(b[i]));return n/192;}
bool identify(camera_fb_t *fb){
 show("Identifying...\nImage sent to Google");
 size_t size=4*((fb->len+2)/3)+1, written=0;
 char *enc=(char*)ps_malloc(size); if(!enc){show("Not enough memory");return false;}
 if(mbedtls_base64_encode((unsigned char*)enc,size,&written,fb->buf,fb->len)){free(enc);return false;}enc[written]=0;
 String body="{\"contents\":[{\"parts\":[{\"text\":\"Identify the main object or plant. Use plain ASCII, at most 100 characters including name and one short description. Say uncertain if unclear. Never claim a plant is edible or safe.\"},{\"inline_data\":{\"mime_type\":\"image/jpeg\",\"data\":\"";
 body+=enc; free(enc); body+="\"}}]}],\"generationConfig\":{\"maxOutputTokens\":256}}";
 WiFiClientSecure tls;tls.setCACert(TRUST);tls.setTimeout(30000);
 HTTPClient http; http.setTimeout(30000);
 String url=String("https://generativelanguage.googleapis.com/v1beta/models/")+GEMINI_MODEL+":generateContent";
 if(!http.begin(tls,url)){show("HTTPS setup failed");return false;}
 http.addHeader("Content-Type","application/json");http.addHeader("x-goog-api-key",GEMINI_KEY);
 int code=http.POST(body);body="";
 if(code!=200){show(String("Cloud error ")+code+"\nCheck key/model/quota");http.end();return false;}
 String response=http.getString();http.end();
 JsonDocument doc; auto err=deserializeJson(doc,response);
 if(err){show("Cloud reply unreadable");return false;}
 String answer;
 for(JsonObject part:doc["candidates"][0]["content"]["parts"].as<JsonArray>()){
  if(!(part["thought"]|false))answer+=part["text"].as<String>();
 }
 answer.trim(); if(!answer.length()){show("No identification\nTry another view");return false;}
 if(answer.length()>105)answer=answer.substring(0,102)+"...";
 show(answer);return true;
}
void setup(){
 Serial.begin(115200);Wire.begin(13,14);screen=oled.begin(0x3c,true);show("Starting camera...");
 if(!psramFound()){show("PSRAM missing\nCheck camera board");return;}
 cameraOK=initCamera();if(!cameraOK){show("Camera init failed");return;}
 if(String(WIFI_SSID)=="YOUR_WIFI_NAME"||String(GEMINI_KEY)=="YOUR_GEMINI_API_KEY"){
  cameraOK=false;show("Set Wi-Fi and API key in config.h");return;
 }
 WiFi.mode(WIFI_STA);WiFi.begin(WIFI_SSID,WIFI_PASSWORD);configTime(0,0,"time.google.com","pool.ntp.org");show("Connecting Wi-Fi...");
}
void loop(){
 delay(20);if(!cameraOK)return;
 if(WiFi.status()!=WL_CONNECTED){show("Wi-Fi unavailable\nReconnecting...");static uint32_t retry=0;if(millis()-retry>15000){retry=millis();WiFi.reconnect();}return;}
 if(time(nullptr)<1700000000){show("Syncing secure clock");return;}
 if(millis()-lastSample<600)return;lastSample=millis();
 camera_fb_t *fb=esp_camera_fb_get();if(!fb){show("Camera capture error");return;}
 uint8_t now[192];if(!signature(fb,now)){esp_camera_fb_return(fb);show("Image decode failed");return;}
 if(havePrev&&distance(now,previous)<5)stable++;else stable=0;
 memcpy(previous,now,192);havePrev=true;
 if(!haveBase||distance(now,baseline)>18)pending=true;
 if(pending&&stable>=3&&(lastCall==0||millis()-lastCall>=30000)){
  lastCall=millis();bool ok=identify(fb);
  if(ok){memcpy(baseline,now,192);haveBase=true;pending=false;}stable=0;
 }
 esp_camera_fb_return(fb);
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik