Smart receptionist system — Esp32 Cam simulation

by - VINAYAK SINGH

An interactive Esp32 Cam circuit simulation you can run free in your browser on Velxio, by adityarajbusiness714.

Components

Sketch code

#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <ESP32Servo.h>
#include "esp_camera.h"

// Velxio Wi-Fi. Real hardware par apne Wi-Fi credentials daalo.
const char* WIFI_SSID = "Velxio-GUEST";
const char* WIFI_PASSWORD = "";

// BotFather token aur Telegram chat ID daalo
const char* BOT_TOKEN = "8875924130:AAEO0biUjJ9sB_wBl067Yd7JovoUjs0W0rI";
const char* AUTHORIZED_CHAT_ID = "7830695766";

// Wiring
#define BUTTON_PIN  2
#define RELAY_PIN   12
#define SERVO_PIN   15
#define LCD_SDA     13
#define LCD_SCL     14

// Standard ESP32-CAM camera pins
#define CAM_PWDN    32
#define CAM_RESET   -1
#define CAM_XCLK     0
#define CAM_SIOD    26
#define CAM_SIOC    27
#define CAM_Y9      35
#define CAM_Y8      34
#define CAM_Y7      39
#define CAM_Y6      36
#define CAM_Y5      21
#define CAM_Y4      19
#define CAM_Y3      18
#define CAM_Y2       5
#define CAM_VSYNC   25
#define CAM_HREF    23
#define CAM_PCLK    22

LiquidCrystal_I2C lcd(0x27, 16, 2);
Servo doorServo;
WiFiClientSecure secureClient;

bool approvalPending = false;
long lastUpdateId = 0;
unsigned long lastTelegramPoll = 0;
unsigned long lastButtonLog = 0;

String telegramUrl(const String& method) {
  return "https://api.telegram.org/bot" +
         String(BOT_TOKEN) + "/" + method;
}

bool startCamera() {
  camera_config_t config = {};

  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = CAM_Y2;
  config.pin_d1 = CAM_Y3;
  config.pin_d2 = CAM_Y4;
  config.pin_d3 = CAM_Y5;
  config.pin_d4 = CAM_Y6;
  config.pin_d5 = CAM_Y7;
  config.pin_d6 = CAM_Y8;
  config.pin_d7 = CAM_Y9;
  config.pin_xclk = CAM_XCLK;
  config.pin_pclk = CAM_PCLK;
  config.pin_vsync = CAM_VSYNC;
  config.pin_href = CAM_HREF;
  config.pin_sccb_sda = CAM_SIOD;
  config.pin_sccb_scl = CAM_SIOC;
  config.pin_pwdn = CAM_PWDN;
  config.pin_reset = CAM_RESET;
  config.xclk_freq_hz = 20000000;
  config.pixel_format = PIXFORMAT_JPEG;

  // Velxio no-PSRAM camera settings
  config.frame_size = FRAMESIZE_QVGA;
  config.fb_location = CAMERA_FB_IN_DRAM;
  config.fb_count = 1;
  config.jpeg_quality = 12;
  config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;

  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed: 0x%x\n", err);
    return false;
  }

  Serial.println("Camera initialized");
  return true;
}

void sendTelegramMessage(const String& message) {
  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("WiFi disconnected; message not sent");
    return;
  }

  HTTPClient http;
  http.setTimeout(10000);

  if (!http.begin(secureClient, telegramUrl("sendMessage"))) {
    Serial.println("Could not start sendMessage request");
    return;
  }

  http.addHeader("Content-Type", "application/json");

  StaticJsonDocument<512> doc;
  doc["chat_id"] = AUTHORIZED_CHAT_ID;
  doc["text"] = message;

  String body;
  serializeJson(doc, body);

  int s

More projects by adityarajbusiness714