# Esp32 cam only working and i can see the pictures when i am connected with the same wifi network

**URL:** <https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077>\
**Category:** General Guidance\
**Created:** [May 6, 2022, 7:14pm UTC](https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077 "2022-05-06T19:14:20Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmedk2](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@ahmedk2](https://forum.arduino.cc/u/ahmedk2)\
**Post date:** [May 6, 2022, 7:14pm UTC](https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077/1 "2022-05-06T19:14:20Z")

</div>

Hello  
I am using esp32 cam as a wifi cam but i only can see if i am at the same wifi network i want to see live streaming video from any where even if i am not conected with the same wifi network  
Please help me with a codes or how to achive that  
Thanks

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [May 6, 2022, 7:28pm UTC](https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077/2 "2022-05-06T19:28:43Z")

</div>

Your esp32 cam is connected to, and works, in Your wifi network.  
To see that video "world wide" You need to get a connection to the Internet.

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [May 6, 2022, 8:06pm UTC](https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077/3 "2022-05-06T20:06:10Z")

</div>

how do you connect to the live stream video so you can view it ?  
e.g. do you run a webserver on the ESP32-can and connect to it with a web client on a PC to view the video?  
if so you can set up your internet router to port forward HTTP port 80 requests to the ESP32 - you should then be able to view it from elsewhere on the internet by entering your routers external IP address

---

<div class="post-metadata">

**Author:** ![red\_car](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@red\_car](https://forum.arduino.cc/u/red_car)\
**Post date:** [May 6, 2022, 8:06pm UTC](https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077/4 "2022-05-06T20:06:35Z")

</div>

Assuming your local network is connected to the Internet?

If so being able to access a local server from the Internet, you need 2 things.

Either a “static public IP” address (assigned by your ISP), or some form of “Dynamic DNS”.

Then your router needs to “port forward” any requests from the Internet to your local IP.

Google these terms for more info.

---

<div class="post-metadata">

**Author:** ![ahmedk2](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@ahmedk2](https://forum.arduino.cc/u/ahmedk2)\
**Post date:** [May 6, 2022, 10:07pm UTC](https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077/5 "2022-05-06T22:07:10Z")

</div>

Is there is a video showing how to do it if i have stasic ip address??

---

<div class="post-metadata">

**Author:** ![Paul\_B](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_b/32/216376_2.png) [@Paul\_B](https://forum.arduino.cc/u/Paul_B)\
**Post date:** [May 6, 2022, 10:25pm UTC](https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077/6 "2022-05-06T22:25:31Z")

</div>

Maybe. 🤔

You need to research on the instructions for **your particular** router.

---

<div class="post-metadata">

**Author:** ![ahmedk2](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@ahmedk2](https://forum.arduino.cc/u/ahmedk2)\
**Post date:** [May 6, 2022, 10:40pm UTC](https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077/7 "2022-05-06T22:40:00Z")

</div>

Can any one try to help me with the way to do it?

---

<div class="post-metadata">

**Author:** ![Paul\_B](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_b/32/216376_2.png) [@Paul\_B](https://forum.arduino.cc/u/Paul_B)\
**Post date:** [May 6, 2022, 10:44pm UTC](https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077/8 "2022-05-06T22:44:42Z")

</div>

See #4 and #6. 🙄

---

<div class="post-metadata">

**Author:** ![ahmedk2](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@ahmedk2](https://forum.arduino.cc/u/ahmedk2)\
**Post date:** [May 6, 2022, 10:45pm UTC](https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077/9 "2022-05-06T22:45:43Z")

</div>

Its already connected to wifi and internet but it gives me local ip address to see the pic but ican only see it when i am at the same wifi connection i need to see it whenever

---

<div class="post-metadata">

**Author:** ![Idahowalker](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/idahowalker/32/238858_2.png) [@Idahowalker](https://forum.arduino.cc/u/Idahowalker)\
**Post date:** [May 6, 2022, 10:49pm UTC](https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077/10 "2022-05-06T22:49:45Z")

</div>

The ESP32CAM is only going to give, under ideal situations, 5 frames a second. I FTP the images taken by the ESP32 cam to my website.

```cpp
#include "sdkconfig.h" // used for log printing
#include "esp_system.h"
#include "freertos/FreeRTOS.h" //freeRTOS items to be used
#include "freertos/task.h"
#include "certs.h"
#include "esp_camera.h"
#include "soc/soc.h" // Disable brownout problems
#include "soc/rtc_cntl_reg.h" // Disable brownout problems
#include "driver/rtc_io.h"
#include <WiFi.h>
#include <WiFiClient.h>
#include "ESP32_FTPClient.h"
//
WiFiClient wifiClient; // do the WiFi instantiation thing
ESP32_FTPClient ftp (ftp_server, ftp_user, ftp_pass, 5000, 2);
////
void IRAM_ATTR WiFiEvent(WiFiEvent_t event)
{
  switch (event) {
    case SYSTEM_EVENT_STA_CONNECTED:
      log_i("Connected to WiFi access point");
      break;
    case SYSTEM_EVENT_STA_DISCONNECTED:
      log_i("Disconnected from WiFi access point");
      break;
    case SYSTEM_EVENT_AP_STADISCONNECTED:
      log_i("WiFi client disconnected");
      break;
    default: break;
  }
} // void IRAM_ATTR WiFiEvent(WiFiEvent_t event)
////
void setup()
{
  WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
  ////
  if ( configInitCamera() )
  {
    xTaskCreatePinnedToCore( capturePhoto_sendFTP, "capturePhoto_sendFTP", 20000, NULL, 3, NULL, 1 );
  } else {
    log_i( "camera failed to initilize. Quitting programed operations." );
  }
} // void setup()
////
void capturePhoto_sendFTP( void *pvParameters )
{
  TickType_t xLastWakeTime = xTaskGetTickCount();
  const TickType_t xFrequency = 1000 * 5; //delay for mS
  for (;;)
  {
    log_i( "tick");
    if ( WiFi.status() == WL_CONNECTED )
    {
      camera_fb_t * fb = NULL; // pointer
      fb = esp_camera_fb_get();
      if (!fb)
      {
        log_i( "Camera capture failed" );
      } else {
        ftp.OpenConnection(); // try open FTP
        if ( ftp.isConnected() )
        {
          //try send file ftp
          ftp.ChangeWorkDir( ftp_path );
          // Delete existing file, create the new file, and send the image to the file
          ftp.DeleteFile( ftp_file_name );
          ftp.InitFile( ftp_file_type ); //"Type I"
          ftp.NewFile( ftp_file_name );
          ftp.WriteData( (unsigned char *)fb->buf, fb->len );
          ftp.CloseFile();
          ftp.CloseConnection();
        }
        esp_camera_fb_return(fb); //return the frame buffer back to the driver for reuse
      }
    } else {
      log_i( "In capturePhoto_sendFTP found WiFi not connected ");
      connectToWiFi();
    }
    xLastWakeTime = xTaskGetTickCount();
    vTaskDelayUntil( &xLastWakeTime, xFrequency );
  }
  vTaskDelete( NULL );
} //void capturePhoto_sendFTP( void *pvParameters )
////
void configureCameraSettings()
{
  sensor_t * s = esp_camera_sensor_get(); //see certs.h for more info
  s->set_brightness(s, -1); // -2 to 2 **************************
  s->set_contrast(s, 0); // -2 to 2
  s->set_saturation(s, 0); // -2 to 2
  s->set_special_effect(s, 0); // 0 to 6 (0 - No Effect, 1 - Negative, 2 - Grayscale, 3 - Red Tint, 4 - Green Tint, 5 - Blue Tint, 6 - Sepia)
  s->set_whitebal(s, 1); // 0 = disable , 1 = enable
  s->set_awb_gain(s, 1); // 0 = disable , 1 = enable
  s->set_wb_mode(s, 0); // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home)
  s->set_exposure_ctrl(s, 1); // 0 = disable , 1 = enable
  s->set_aec2(s, 0); // 0 = disable , 1 = enable
  s->set_ae_level(s, 0); // -2 to 2
  s->set_aec_value(s, 300); // 0 to 1200
  s->set_gain_ctrl(s, 1); // 0 = disable , 1 = enable
  s->set_agc_gain(s, 0); // 0 to 30
  s->set_gainceiling(s, (gainceiling_t)0); // 0 to 6
  s->set_bpc(s, 0); // 0 = disable , 1 = enable
  s->set_wpc(s, 1); // 0 = disable , 1 = enable
  s->set_raw_gma(s, 1); // 0 = disable , 1 = enable
  s->set_lenc(s, 1); // 0 = disable , 1 = enable
  s->set_hmirror(s, 0); // 0 = disable , 1 = enable
  s->set_vflip(s, 0); // 0 = disable , 1 = enable
  s->set_dcw(s, 1); // 0 = disable , 1 = enable
  s->set_colorbar(s, 0); // 0 = disable , 1 = enable
} //void configureCameraSettings()
////
bool configInitCamera()
{
  camera_config_t config = {}; // Stores the camera configuration parameters
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = GPIO_NUM_5; //Y2
  config.pin_d1 = GPIO_NUM_18; //Y3
  config.pin_d2 = GPIO_NUM_19; //Y4
  config.pin_d3 = GPIO_NUM_21; //Y5
  config.pin_d4 = GPIO_NUM_36; //Y6
  config.pin_d5 = GPIO_NUM_39; //Y7
  config.pin_d6 = GPIO_NUM_34; //Y8
  config.pin_d7 = GPIO_NUM_35; // Y9
  config.pin_xclk = GPIO_NUM_0; //XCLK
  config.pin_pclk = GPIO_NUM_22; //PCLK
  config.pin_vsync = GPIO_NUM_25; //VSSYNC
  config.pin_href = GPIO_NUM_23; // HREF
  config.pin_sscb_sda = GPIO_NUM_26; //SIOD
  config.pin_sscb_scl = GPIO_NUM_27; //SIOC
  config.pin_pwdn = GPIO_NUM_32; //PWDN
  config.pin_reset = -1; //RESET
  config.xclk_freq_hz = 20000000;
  config.pixel_format = PIXFORMAT_JPEG; //assuming default is has PSRAM
  config.frame_size = FRAMESIZE_UXGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA
  config.jpeg_quality = 10; //0-63 lower number means higher quality
  config.fb_count = 2;
  // Initialize the Camera
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    log_i("Camera init failed with error 0x%x", err);
    return false;
  } else {
    configureCameraSettings();
    return true;
  }
} //void configInitCamera()
////
void connectToWiFi()
{
  int TryCount = 0;
  while ( WiFi.status() != WL_CONNECTED )
  {
    TryCount++;
    WiFi.disconnect();
    WiFi.begin( SSID, PASSWORD );
    vTaskDelay( 4000 );
    if ( TryCount == 10 )
    {
      ESP.restart();
    }
  }
  WiFi.onEvent( WiFiEvent );
}
////
void loop() {}

```

---

<div class="post-metadata">

**Author:** ![Paul\_B](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_b/32/216376_2.png) [@Paul\_B](https://forum.arduino.cc/u/Paul_B)\
**Post date:** [May 7, 2022, 12:04am UTC](https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077/11 "2022-05-07T00:04:48Z")

</div>

> [@ahmedk2](#):
>
> I need to see it whenever

You need to understand "[port forwarding](https://en.wikipedia.org/wiki/Port_forwarding)".

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [November 3, 2022, 12:05am UTC](https://forum.arduino.cc/t/esp32-cam-only-working-and-i-can-see-the-pictures-when-i-am-connected-with-the-same-wifi-network/989077/12 "2022-11-03T00:05:26Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
