ماشین هوشمند دوربین دار
سلام در این جلسه قصد داریم با استفاده از برد esp32-cam و اپلیکیشن یک ماشین هوشمند دوربین دار بسازیم .
برد ESP32_CAM
تراشه esp32 تراشه جدیدتر نوع esp8266 هستش که امکانات و پایه های بیشتری داره همچنین بلوتوث هم به این برد اضافه شده.
ولتاژ تغذیه ماژول ۳.۳ ولت هستش و جریان مصرفیش با دوربین حدود ۲۵۰ میلی آمپر هستش.
این تراشه جز تراشه های کم مصرف هستش و بسیار در زمینه اینترنت اشیا کاربردی هستش.
شماتیک و اتصالات مدارپروگرام کردن:
شماتیک و اتصالات مدار ماشین هوشمند:
ما در این آموزش از درایور موتور L298 استفاده کردیم .
کد نویسی:
کد با آی پی استاتیک مخصوص هات اپات وایفای گوشی
۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ۱۰ ۱۱ ۱۲ ۱۳ ۱۴ ۱۵ ۱۶ ۱۷ ۱۸ ۱۹ ۲۰ ۲۱ ۲۲ ۲۳ ۲۴ ۲۵ ۲۶ ۲۷ ۲۸ ۲۹ ۳۰ ۳۱ ۳۲ ۳۳ ۳۴ ۳۵ ۳۶ ۳۷ ۳۸ ۳۹ ۴۰ ۴۱ ۴۲ ۴۳ ۴۴ ۴۵ ۴۶ ۴۷ ۴۸ ۴۹ ۵۰ ۵۱ ۵۲ ۵۳ ۵۴ ۵۵ ۵۶ ۵۷ ۵۸ ۵۹ ۶۰ ۶۱ ۶۲ ۶۳ ۶۴ ۶۵ ۶۶ ۶۷ ۶۸ ۶۹ ۷۰ ۷۱ ۷۲ ۷۳ ۷۴ ۷۵ ۷۶ ۷۷ ۷۸ ۷۹ ۸۰ ۸۱ ۸۲ ۸۳ ۸۴ ۸۵ ۸۶ ۸۷ ۸۸ ۸۹ ۹۰ ۹۱ ۹۲ ۹۳ ۹۴ ۹۵ ۹۶ ۹۷ ۹۸ ۹۹ ۱۰۰ ۱۰۱ ۱۰۲ ۱۰۳ ۱۰۴ ۱۰۵ ۱۰۶ |
#include "esp_camera.h" #include <WiFi.h> #include "camera_pins.h" // Select camera model //#define CAMERA_MODEL_WROVER_KIT //#define CAMERA_MODEL_M5STACK_PSRAM #define CAMERA_MODEL_AI_THINKER const char* ssid = "۴ADA"; const char* password = "@۴adateam@"; extern int leftmotor1 = ۲; // Left Motor extern int leftmotor2 = ۱۴; extern int rightmotor1 = ۱۵; // Right Motor extern int rightmotor2 = ۱۳; IPAddress staticIP383_10(۱۹۲,۱۶۸,۴۳,۱۶۷); IPAddress gateway383_10(۱۹۲,۱۶۸,۴۳,۵۵); IPAddress subnet383_10(۲۵۵,۲۵۵,۲۵۵,۰); extern String Camerafeed =""; void startCameraServer(); void setup() { Serial.begin(۱۱۵۲۰۰); Serial.setDebugOutput(true); Serial.println(); pinMode(leftmotor1, OUTPUT); pinMode(leftmotor2, OUTPUT); pinMode(rightmotor1, OUTPUT); pinMode(rightmotor2, OUTPUT); //initialize digitalWrite(leftmotor1, LOW); digitalWrite(leftmotor2, LOW); digitalWrite(rightmotor1, LOW); digitalWrite(rightmotor2, LOW); camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; config.ledc_timer = LEDC_TIMER_0; config.pin_d0 = Y2_GPIO_NUM; config.pin_d1 = Y3_GPIO_NUM; config.pin_d2 = Y4_GPIO_NUM; config.pin_d3 = Y5_GPIO_NUM; config.pin_d4 = Y6_GPIO_NUM; config.pin_d5 = Y7_GPIO_NUM; config.pin_d6 = Y8_GPIO_NUM; config.pin_d7 = Y9_GPIO_NUM; config.pin_xclk = XCLK_GPIO_NUM; config.pin_pclk = PCLK_GPIO_NUM; config.pin_vsync = VSYNC_GPIO_NUM; config.pin_href = HREF_GPIO_NUM; config.pin_sscb_sda = SIOD_GPIO_NUM; config.pin_sscb_scl = SIOC_GPIO_NUM; config.pin_pwdn = PWDN_GPIO_NUM; config.pin_reset = RESET_GPIO_NUM; config.xclk_freq_hz = ۲۰۰۰۰۰۰۰; config.pixel_format = PIXFORMAT_JPEG; //init with high specs to pre-allocate larger buffers if(psramFound()){ config.frame_size = FRAMESIZE_UXGA; config.jpeg_quality = ۱۰; config.fb_count = ۲; } else { config.frame_size = FRAMESIZE_SVGA; config.jpeg_quality = ۱۲; config.fb_count = ۱; } // camera init esp_err_t err = esp_camera_init(&config); if (err != ESP_OK) { Serial.printf("Camera init failed with error 0x%x", err); return; } //drop down frame size for higher initial frame rate sensor_t * s = esp_camera_sensor_get(); s->set_framesize(s, FRAMESIZE_CIF); WiFi.begin(ssid, password); WiFi.config(staticIP383_10, gateway383_10, subnet383_10); while (WiFi.status() != WL_CONNECTED) { delay(۵۰۰); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); startCameraServer(); Serial.print("Camera Ready! Use 'http://"); Serial.print(WiFi.localIP()); Camerafeed = WiFi.localIP().toString(); Serial.println("' to connect"); } void loop() { // put your main code here, to run repeatedly: } |
کد نویسی:
کد با آی پی استاتیک مخصوص مودم وایفای
۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ۱۰ ۱۱ ۱۲ ۱۳ ۱۴ ۱۵ ۱۶ ۱۷ ۱۸ ۱۹ ۲۰ ۲۱ ۲۲ ۲۳ ۲۴ ۲۵ ۲۶ ۲۷ ۲۸ ۲۹ ۳۰ ۳۱ ۳۲ ۳۳ ۳۴ ۳۵ ۳۶ ۳۷ ۳۸ ۳۹ ۴۰ ۴۱ ۴۲ ۴۳ ۴۴ ۴۵ ۴۶ ۴۷ ۴۸ ۴۹ ۵۰ ۵۱ ۵۲ ۵۳ ۵۴ ۵۵ ۵۶ ۵۷ ۵۸ ۵۹ ۶۰ ۶۱ ۶۲ ۶۳ ۶۴ ۶۵ ۶۶ ۶۷ ۶۸ ۶۹ ۷۰ ۷۱ ۷۲ ۷۳ ۷۴ ۷۵ ۷۶ ۷۷ ۷۸ ۷۹ ۸۰ ۸۱ ۸۲ ۸۳ ۸۴ ۸۵ ۸۶ ۸۷ ۸۸ ۸۹ ۹۰ ۹۱ ۹۲ ۹۳ ۹۴ ۹۵ ۹۶ ۹۷ ۹۸ ۹۹ ۱۰۰ ۱۰۱ ۱۰۲ ۱۰۳ ۱۰۴ ۱۰۵ ۱۰۶ |
#include "esp_camera.h" #include <WiFi.h> #include "camera_pins.h" // Select camera model //#define CAMERA_MODEL_WROVER_KIT //#define CAMERA_MODEL_M5STACK_PSRAM #define CAMERA_MODEL_AI_THINKER const char* ssid = "۴ADA"; const char* password = "@۴adateam@"; extern int leftmotor1 = ۲; // Left Motor extern int leftmotor2 = ۱۴; extern int rightmotor1 = ۱۵; // Right Motor extern int rightmotor2 = ۱۳; IPAddress staticIP383_10(۱۹۲,۱۶۸,۱,۱۰); IPAddress gateway383_10(۱۹۲,۱۶۸,۱,۱); IPAddress subnet383_10(۲۵۵,۲۵۵,۲۵۵,۰); extern String Camerafeed =""; void startCameraServer(); void setup() { Serial.begin(۱۱۵۲۰۰); Serial.setDebugOutput(true); Serial.println(); pinMode(leftmotor1, OUTPUT); pinMode(leftmotor2, OUTPUT); pinMode(rightmotor1, OUTPUT); pinMode(rightmotor2, OUTPUT); //initialize digitalWrite(leftmotor1, LOW); digitalWrite(leftmotor2, LOW); digitalWrite(rightmotor1, LOW); digitalWrite(rightmotor2, LOW); camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; config.ledc_timer = LEDC_TIMER_0; config.pin_d0 = Y2_GPIO_NUM; config.pin_d1 = Y3_GPIO_NUM; config.pin_d2 = Y4_GPIO_NUM; config.pin_d3 = Y5_GPIO_NUM; config.pin_d4 = Y6_GPIO_NUM; config.pin_d5 = Y7_GPIO_NUM; config.pin_d6 = Y8_GPIO_NUM; config.pin_d7 = Y9_GPIO_NUM; config.pin_xclk = XCLK_GPIO_NUM; config.pin_pclk = PCLK_GPIO_NUM; config.pin_vsync = VSYNC_GPIO_NUM; config.pin_href = HREF_GPIO_NUM; config.pin_sscb_sda = SIOD_GPIO_NUM; config.pin_sscb_scl = SIOC_GPIO_NUM; config.pin_pwdn = PWDN_GPIO_NUM; config.pin_reset = RESET_GPIO_NUM; config.xclk_freq_hz = ۲۰۰۰۰۰۰۰; config.pixel_format = PIXFORMAT_JPEG; //init with high specs to pre-allocate larger buffers if(psramFound()){ config.frame_size = FRAMESIZE_UXGA; config.jpeg_quality = ۱۰; config.fb_count = ۲; } else { config.frame_size = FRAMESIZE_SVGA; config.jpeg_quality = ۱۲; config.fb_count = ۱; } // camera init esp_err_t err = esp_camera_init(&config); if (err != ESP_OK) { Serial.printf("Camera init failed with error 0x%x", err); return; } //drop down frame size for higher initial frame rate sensor_t * s = esp_camera_sensor_get(); s->set_framesize(s, FRAMESIZE_CIF); WiFi.begin(ssid, password); WiFi.config(staticIP383_10, gateway383_10, subnet383_10); while (WiFi.status() != WL_CONNECTED) { delay(۵۰۰); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); startCameraServer(); Serial.print("Camera Ready! Use 'http://"); Serial.print(WiFi.localIP()); Camerafeed = WiFi.localIP().toString(); Serial.println("' to connect"); } void loop() { // put your main code here, to run repeatedly: } |