DIY Projects

ESP32-CAM. Solder the external antenna to improve the range and stability of the video stream

esp32-cam solder ipex wifi antenna strength improved

You have most certainly already experienced loss of video stream or freezing of the picture with the ESP32-CAM. Several solutions are possible to improve things. We will see how to activate the IPEX connector on generic boards to connect an external antenna and optimize the Arduino code.

 

Warning. Modifying the circuit of the ESP32-CAM may cause irreversible damage to the card. The modification is made at your risk and results in the loss of warranty of the material. Even though the modification has been tested, I cannot guarantee that your WiFi signal will improve for all equipment on the market.

The modification was tested on a generic ESP32-CAM module.

Activate the external antenna (IPEX) of ESP32-CAM (ESP32-S)

Generic ESP32-CAM or ESP-EYE cards generally use an ESP32-S module. This module has an antenna engraved on the PCB as well as an IPEX connector which allows the use of an external amplified antenna.

It is not possible to use both antennas simultaneously. The antenna selection (PCB or IPEX) is done using a resistor.

The problem is that you have to manually modify the circuit … and for that, you will have to play with a soldering iron, and that’s not easy to do!

Better to be well equipped. The ideal would be to have a hot air soldering iron and a tweezers but you can get there with a simple soldering iron, a good magnifying glass and a little patient

To activate the external antenna (and deactivate the PCB antenna), it is “enough” to unsolder the resistor and move it to the pad of the IPEX connector. No need to lie to each other, given the size of the resistance, it risks sticking to the soldering iron tip … that’s what happened to me. I simply replaced the resistor with a copper wire recovered from a Jumper. It’s not ideal but it works.

Manufacturers of ESP32-CAM boards, including those * who deliver an external antenna as a kit, do not modify the circuit. So the PCB antenna is always active most of the time

(*) Unless the manufacturer has explicitly indicated it but it is very rare

PCB antenna activated External antenna activated

Testing WiFi signal strength and video stream stability

Here is a small piece of code that you just need to insert into your ESP32-CAM project to test the WiFi signal strength as soon as the WiFi connection is established. The average signal strength is calculated based on 10 measurements taken 200ms apart.

  long logrssi = 0 ;
  for (size_t i = 0; i < 10; i++)
  {
    long rssi = WiFi.RSSI();
    logrssi = logrssi + rssi;
    Serial.printf("measured rssi = %d dBm \n", WiFi.RSSI());
    delay(200);
  }
  
  Serial.printf("Mean rssi = %0.1d dBm \n", logrssi / 10);

Here are the results obtained with 3 different antennas.

The signal strength is constantly changing depending on the network load (of other connected devices). For testing, there was only my laptop connected to a Netgear WiFi hotspot.

PCB IPEX 2 dBi antenna IPEX 6 dBi antenna
61 dBm 63 dBm 60 dBm

On paper, the flexible 2dBi antenna clearly does not add much. An antenna with a gain of at least 6dBi seems a minimum to start improving the signal.

  • Prices in $
  • Prices in €

The improvement may seem small, but it is sufficient to improve the stability of the video stream and reduce the compression rate. To be more rigorous, it would be necessary to continue the test over a longer period and see

However, empirically, with the PCB antenna, I had trouble converting the flow without reducing the resolution and increasing the compression rate (and therefore reducing the quality of the image). With the external antenna, I was able to switch the resolution to UXGA (1600×1200) and reduce the compression ratio to 10 (out of 63).

Here are 3 small demonstration clips. The speed of the video is real.

FYI, here is what we can expect to do depending on the strength of the signal.

WiFi signal strength Quality
-30 dBm Maximum signal strength, you are probably right next to the access point.
-50 dBm Excellent signal strength
-60 dBm Correct and reliable WiFi signal for most services including HD video
-67 dBm Reliable signal. Sufficient for basic voice or video streaming.
-70 dBm Very weak signal. Sufficient for reading and sending emails or light internet browsing (text)
-80 dBm Network connection possible but little chance of being able to use it
-90 dBm The chances of even logging in are very low at this level

Source

Buy a card with SMA or IPEX connector for external antenna ready to use

You should succeed without damaging the ESP32-S which is well protected by a protective cover. If you don’t have the material, you can fall back on a ready-made template. Here are a few.

M5Stack Timer Camera

The M5Stack Timer Camera is a development board equipped with the OV3660 optical sensor to achieve a resolution of 3MP as well as a BM8563 RTC clock. The card is equipped with a 3D WiFi antenna.

The M5Stack Timer Camera can also be used to connect I2C Grove 4-pin accessories. ESP32 pins IO04 and IO13 are exposed. The Grove connector is used to connect M5Stack or SeeedStudio sensors and actuators .

No need to put the camera in “bootloader” mode each time you want to upload a new program, the card is equipped with a USB-C connector as well as a UART / USB converter CP2104. The M5Stack Timer Camera is ideal for getting started. Programming can be done by assembling blocks (blocky language).

TTGO T-Camera, T-Camera Plus or T-Journal from LilyGo

LilyGo, the manufacturer of TTGO development boards, offers us 3 ESP32-CAM development boards.

The ESP32-CAM TTGO T-Camera and T-Camera Plus cards are equipped with a 3D WiFi antenna as well as an IPEX connector. A priori, it is not necessary to intervene on the circuit to connect an external antenna. However, the 3D WiFi antenna should provide a good signal in most situations, indoors at least.

The T-Journal is fitted with a double SMA + IPEX connector (soldered to the base of the SMA connector). No antenna is engraved on the PCB, so you must use an external antenna.

Function TTGO T-Camera TTGO T-Camera Plus T-Journal
ESP32 ESP32-WROVER-B ESP32-DOWDQ6 ESP32-PICO-D4
PSRAM memory 8Mo 8Mo ?
Flash memory 4Mo 4Mo 4Mo
Microphone

MSM261S4030H0

SD card reader
BME280 (temperature + humidity + atmospheric pressure) Integrated
I2C Connector Connector
Screen OLED SSD1306

0,96″ (128×64)

IPS ST7789

1.3 “

OLED SSD1306

0,96″ (128×64)

Camera OV2640 OV2640 OV2640
THE BRIDGE

AS312

User button

UART / USB CP2104 CP2104 CP2104
Connector micro usb micro usb micro usb
JST connector for LiPo battery
3D WiFi antenna  
IPEX uFL connector
SMA connector
Dimension 69.13*28.41*8.45mm 64.57mm * 23.98mm
Resources Read Read Read

TTGO T-Camera with PIR motion detection

TTGO T-Camera Plus with microphone, BME280, 1.3″color TFT screen and SD card reader

Too bad the motion detector has been replaced by a push button, probably to make selphis! It would have been perfect for a surveillance camera with its microSD card reader.

TTGO T-Journal

The TTGO T-Journal is directly fitted with an SMA connector. An IPEX connector (uFL) is also present at the base of the SMA connector. Good idea !

  • Prices in $
  • Prices in €

Optimizing Arduino code

If, despite the external antenna, you still have an image freeze, you can adjust the acquisition parameters. O can act on 3 parameters:

Enable PSRAM support

PSRAM is a memory chip accessible on the SPI bus that the ESP32 can use to augment its own RAM. This allows you to create a larger video buffer. This is the first thing to do, especially if your card is equipped with PSRAM. Otherwise, the PSRAM will be useless!

Here is an example of a typical configuration to integrate into the setup()

if(psramFound()){
    config.frame_size = FRAMESIZE_UXGA;  // 1600x1200
    config.jpeg_quality = 10;
    config.fb_count = 2; // Si > 1, active le bus I2S
  } else {
    config.frame_size = FRAMESIZE_SVGA; // 800x600 
    config.jpeg_quality = 12;
    config.fb_count = 1;
  }

Camera resolution, config.resolution parameter

Here are the available resolutions (in pixels)

FRAMESIZE_QQVGA, 160x120
FRAMESIZE_QQVGA2, 128x160
FRAMESIZE_QCIF, 176x144
FRAMESIZE_HQVGA, 240x176
FRAMESIZE_QVGA, 320x240
FRAMESIZE_CIF, 400x296
----------- Acceptable resolutions for video surveillance ------------
FRAMESIZE_VGA, 640x480
FRAMESIZE_SVGA, 800x600
----------- Ideal resolutions for video surveillance ------------
FRAMESIZE_XGA, 1024x768
FRAMESIZE_SXGA, 1280x1024
----------- Rather to take photos at regular intervals (timelaps) ------------
FRAMESIZE_UXGA, 1600x1200
FRAMESIZE_QXGA, 2048x1536
config.frame_size = FRAMESIZE_UXGA;

Increase the compression ratio of the image

The rate can vary from 0 (no compression) to 63 (almost unreadable).

config.jpeg_quality = 10;

Updates

12/11/2020 Publication of the article

Version française

Thanks for reading.

Click to rate this post!
[Total: 1 Average: 5]
Exit mobile version