ESP32 Range extender / Antenna modification

Place your projects here
Post Reply
User avatar
PeterN
Posts: 366
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 171 times
Been thanked: 203 times
Contact:

ESP32 Range extender / Antenna modification

Post by PeterN »

When experimenting with ESP32 modules, especially the ESP32 CAMs, I wish I had a little more WIFI range reserve.
This could be achieved by adding an external antenna - but not all modules are prepared for the connection of an external antenna.
To keep it simple but effective, I added a half-wave antenna wire to the original onboard antenna of the ESP32 module.
0480BE99-94B4-408F-A7A5-3298D46F595C.jpeg

The original print antenna is a meander-shaped, inverted F antenna with 1/4 wavelength. It is a compromise between size, omnidirectional antenna pattern if possible, and power efficiency. I found a very helpful source of information about such kind of antennas at https://www.nxp.com/docs/en/application-note/AN2731.pdf

My thought now was to increase the WIFI range of the module by a strong coupling between the on-board antenna and a newly added external half-wave antenna wire (AWG24 switch wire 0.5mm with 62mm length). However, no irreversible changes or soldering should become necessary. So I hot glued the additional antenna wire directly on the board . Note that half of the isolated antenna wire is exactly following the meandering shape of the printed F-antenna, while the other half is mounted "free". This results in a good inductive and capacitive coupling.
I did some experiments where the free end of the antenna wire ran straight or was run up at a 90 degree angle. This changed the resulting antenna pattern, which could surely be investigated much more to optimize the result in a given mounting environment

My hopeful design was now to prove!
To show the effect of my design, I mounted a modified module next to an unmodified one so that both modules should have nearly the same receiving conditions.
4F5DE265-712E-44A3-9C22-9F7AD5685E21.jpeg

I have written ANNEX32 code that plots the WIFI field strength measured by both modules simultaneously on a single graph.
Module 1 (with additional antenna) logs its own WIFI RSSI and additionally requests a string with the logged RSSI from the second (unmodified) module.



I tested the effect of the additional antenna and recorded the WIFI strength under different conditions. Here I can show only an abstract of my experiments and results.
38EC685E-3EF7-41F7-975E-C005305A2E27.jpeg
0A81B065-AC62-45A3-8C5C-528CB197483E.jpeg


It turns out that the signal is improved by at least 3 dB overall on the modified modules with a elongated non-angled antenna wire. Under very reflective conditions, I had an improvement of almost 10 dB.
One of the reasons for the better gain is certainly the modified antenna pattern; another might be the strong coupling to a larger and somewhat more effective antenna.
Under given unfavorable conditions, this simple external antenna cannot work wonders, but it can increase the range of the ESP module or improve a less stable WIFI connection.

I modified an ESP32 CAM as described here and now have a much better signal and a very stable video connection in a place that was previously quite critical.
0CDB048A-D078-4856-BB65-91C738C8747D.jpeg

Code: [Local Link Removed for Guests]


'######## WIFI-GRAPH-LOGGER ####################################
'  Allows to compair the two ESP-Modules which have different antennas
'
' Displays  a graphical logging of two WIFI-signals in dB 
' -  the OWN WIFI-connection to the WIFI access point
' -  the WIFI-connection of a remote ESP32  to the same AP
'

' TX = 1  => this ESP-Module  returns the string with its 
'            WIFI-LOG-RESULT-STRING  on request at http://MY_IP/msg?x=1
TX         = 1   

' RX = 1 => This ESP-Module regularly requests the WIFI-LOG-RESULT-STRING 
'            from remote module with http://REMOTE_IP/msg?x=1
RX         = 0

REMOTE_IP$ = "192.168.0.141"

X_Num      = 100 'Number of WIFI-MESSURES to display  in the graph
WIFI_REMOTE$  = ""

onhtmlreload  WEBPAGE
gosub         WEBPAGE

if TX = 1 onurlmessage RETURN_WIFI_STRING
IF RX = 1 onwgetasync RECEIVE_REMOTE_STRING

timer0 500, LOG_MY_WIFI_CONNECTION

if RX = 1 timer1 1000, GET_REMOTE_WIFI_LOG_STRING
wait

'###############################################################

LOG_MY_WIFI_CONNECTION:
  w=0
  for i  = 1 to 50
  w = wifi.rssi + w
  next i
  w=W/(i-1)   ' Thanks for the hint Fernando !
  WIFI_LOCAL$= trim$(WIFI_LOCAL$ + " " +str$(wifi.rssi,"%2.1f")) 
  c = word.count(WIFI_LOCAL$," ")
  p = instr(1, WIFI_LOCAL$, " ")
  P = len(WIFI_LOCAL$) - p
  If c  > X_NUM then WIFI_LOCAL$ = right$(WIFI_LOCAL$, p )
  'wlog WIFI_LOCAL$ , c
  jscall |traceme(0,"| + WIFI_LOCAL$ + |");|
 if WIFI_REMOTE$ <> "" jscall |traceme(1,"| + WIFI_REMOTE$ + |");|
return


'###############################################################
RETURN_WIFI_STRING:
URLMSGRETURN WIFI_LOCAL$
return


'###############################################################
GET_REMOTE_WIFI_LOG_STRING:
wgetasync ("http://" + REMOTE_IP$+ "/msg?x=1")
return

'###############################################################
RECEIVE_REMOTE_STRING:
WIFI_REMOTE$ = WGETRESULT$
return


'###############################################################
WEBPAGE:
cls
' loads the library
jsexternal "/xy.min.js"
cnt = 0

a$ = ""
a$ = a$ + |<p>WIFI Graph for two ESP32-modules .. <br> |
a$ = a$ + |GREEN = WITH additional antenna <br> RED === with original antenna |
a$ = a$ + |</p><canvas id="canvas1" width="800" height="400"></canvas>|
html a$
pause 500

' define che datasets 
A$ = ""
A$ = A$ + |var datasets = [|
A$ = A$ + |  {|
A$ = A$ + |    lineColor : 'rgba(20,100,100,1)',|
A$ = A$ + |    pointColor : 'rgba(20,20,20,1)',|
A$ = A$ + |    pointStrokeColor : '#fff',|
A$ = A$ + |    data : []|
A$ = A$ + |  },|
A$ = A$ + |  {|
A$ = A$ + |    lineColor : 'rgba(151,30,0,1)',|
A$ = A$ + |    pointColor : 'rgba(151,80,0,1)',|
A$ = A$ + |    pointStrokeColor : '#fff',|
A$ = A$ + |    data : []|
A$ = A$ + |  }|
A$ = A$ + |];|

A$ = A$ + |var ctx2 = document.getElementById('canvas1').getContext('2d');|
A$ = A$ + ||
A$ = A$ + |var xy = new Xy(ctx2, {rangeX:[0,| + STR$(X_NUM)+ |], rangeY:[-80,-45], smooth:0.05, pointCircleRadius:2, pointStrokeWidth:1 });|
A$ = A$ + ||

A$ = A$ + |function traceme(set, data){|
A$ = A$ + |  var s = data.split(" ");|
A$ = A$ + |  for (var i=0; i<s.length; i++) {|
A$ = A$ + |    datasets[set].data[i] = [i, s[i]];|
A$ = A$ + |  }|
A$ = A$ + |  xy.draw(datasets);|
A$ = A$ + |}|

jscript a$
A$ = "" ' clean memory

return
You do not have the required permissions to view the files attached to this post.
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: ESP32 Range extender / Antenna modification

Post by Fernando Perez »

Peter, I don't think it matters much but at the end of your for next loop (line 41), w equals 51, not 50.
I understand that at no time do you solder the cable, you just glue it to the surface of the module.
In theory, it will work the same for ESP8266 modules, right?
Brilliant. I'm going to check that.
User avatar
PeterN
Posts: 366
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 171 times
Been thanked: 203 times
Contact:

Re: ESP32 Range extender / Antenna modification

Post by PeterN »

You are right about both statements, Fernando.

For .. next - variable after loop ... I am ashamed of this almost classic error. :oops:


And the Antenna of the ESP8266 is indeed the same kind of F-Antenna
User avatar
PeterN
Posts: 366
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 171 times
Been thanked: 203 times
Contact:

Re: ESP32 Range extender / Antenna modification

Post by PeterN »

I elaborated the matter a bit more and placed it at ...

- https://peterneufeld.wordpress.com/2021 ... ification/
- https://www.elektormagazine.com/labs/es ... dification

And of cause I did not forget to mention the world-famous ANNEX there!!!
Post Reply