~bfiedler/website

bbcbbc95b045ad9a60fcd7aad6bb852938f78cf1 — Ben Fiedler 5 months ago e8d491e
Add antenna post
A content/blog/build-your-own-wi-fi-antenna.md => content/blog/build-your-own-wi-fi-antenna.md +146 -0
@@ 0,0 1,146 @@
---
title: "Build Your Own Wi-Fi Antenna"
date: 2020-11-28T02:01:10+01:00
draft: true
tags: math, diy
---

Building a wireless antenna is not hard. While the underlying physics and
protocols are relatively complex, an antenna's job is very simple: it captures
or creates electromagnetic waves.

There exist a multitude of different antenna designs, each with different
characteristics. The simplest type is the *isotropic* antenna, which sends or
receives from all (three dimensional) directions approximately equally well.
Closely related is the *omnidirectional* antenna, which receives equally well
from all compass directions, but is sensitive to the vertical angle of incoming
electromagnetic waves. The WiFi antennas used in laptops and smartphones are
often (close to) omnidirectional, as it would be really impractical if
orientation had an effect on signal strength!

Antennas which are sensitive to the angles of incoming radio waves are called
*directional*. Common uses of directional antennas are at space observatories
station, but also satellite TV antennas or military and civilian radars.
Directional antennas come in different forms. A well-known one is the
*parabolic* antenna, which uses a parabolic dish to focus the electromagnetic
waves to a single point.

We built a basic parabolic receiving antenna using a 3D printer and a
female-female [N-connector](https://en.wikipedia.org/wiki/N_connector),
available in any well-stocked electronics store. The most important part is
the form of the parabola: it is described by the equation $y = x^2 / 4a$, where
$a$ is the *focal length*, i.e.  the distance from the center of the antenna to
the *focal point*, at which the signal is concentrated. Of course it is
infeasible to build an infinitely large antenna, so the parabola is cut off at
some point, resulting in a diameter $d$ and height $h$. These parameters are
important when printing the design, since they impact the stability and
feasibility of the print.

{{< figure class="invertable resizable" src="/blog/img/antenna-schema.png" alt="Plot of antenna parabola" >}}

Such a parabolic antenna has a theoretical gain $G$ of $η * (π * d / λ)²$, where
$λ$ is the wavelength of the measured signal and $η$ is the so-called *aperture
efficiency*, commonly between $0.5$ and $0.7$. It is a catch-all for uneven dish
surface, poor antenna placement and other blemishes. We chose a focal length of
100mm and diameter of 200mm. Since we are interested in building a Wi-Fi
antenna, the wavelength is 125mm[^2], which gives us a theoretical gain of $η *
25.26$ or about $10 * log10 η + 14 dBi$, a promising start.

A friend of mine helped us model and print the antenna using
[Fusion360](https://www.autodesk.com/products/fusion-360/personal) and his
[Prusa
MK3S](https://shop.prusa3d.com/en/3d-printers/181-original-prusa-i3-mk3s-3d-printer.html).
Of course, any decent 3D modeling software and printer will do here.
Unfortunately, the surface of 3D prints commonly has a rough texture, which
lowers the effectiveness of the antenna. We fixed this by taping sponge rubber
in the dish and covering the now smoother surface in aluminium tape. Both
materials can be bought cheaply in a hardware store.

{{< figure class="resizable" src="/blog/img/antenna-build.png" alt="The finished antenna build" >}}

And all set! In order to measure how good our DIY antenna is we compared it
against a professional so-called
[*cantenna*](https://en.wikipedia.org/wiki/Cantenna), another type of
directional antenna which can be built easily at home. We used a [TP-Link
WN722N](https://www.tp-link.com/us/home-networking/usb-adapter/tl-wn722n/) USB
wifi adapter as sending station, and the [Alfa
AWUS036NH](https://www.alfa.com.tw/products/awus036nh) USB adapter as receiver.
Getting the driver of the TP-Link stick to work was quite the pain, but we
managed and set out to measure the different antennas.

We are interested in the antenna gain, i.e. how much the antenna amplifies a
signal when receiving. Genereally the unit decibels-isotropic (dBi) is used,
which compares the received signal strenth to an idealized isotropic antenna.

When using a source transmitting with constant signal strength it suffices to
measure the received signal strength only - we can infer the gain from the
source strength and our measurements. This is measured in decibel-milliwats
(dBm), which measures the change in power level per milliwatt increase.

It is important to consider the right environment when measuring antenna gain:
there should be no reflective surfaces such as building walls, bridges or
similar close by. Also be sure to have line-of-sight between both antennas, as
any objects between them disturb the measurements. We chose an open field near
us.

We measured the signal strength once for increasing distances between 1m and
100m, and another time in a 360° radius at 20m, using 20° increments using three
antennas: Our DIY parabolic antenna, the professional cantenna, and the 5dBi
omnidirectional antenna which came included with the Alfa adapter.

For our test setup we created a Wi-Fi network on the TP-Link adapter and
connected to it from the Alfa adatper. We measured the signal strength using
`iwconfig`, which natively displays this metric.

# Distance measurements

{{< figure class="invertable resizable" src="/blog/img/antenna-dist.png" alt="Signal strength with varying distance" >}}

Surprisingly, the omnidirectional antenna outperforms both our antenna (which
was probably to be expected), but also the professional cantenna. For our
antenna, a few explanations come to mind: during transport I accidentally bent
the copper wire a bit, and we did not manage to bend it back as good as shown
above. Furthermore our antenna dish is not a perfect parabola, but contains
blemishes from the underlying sponge rubber.

# Directionality measurements

{{< figure class="invertable resizable" src="/blog/img/antenna-angle.png" alt="Signal strength with varying angle" >}}

Unsurprisingly, the omnidirectional antenna is not sensitive to orientation,
while the other two antennas are. The cantenna displays a beautiful profile of
directionality: Good signal strength when pointing directly towards the source,
then decreasing until hitting the minimum around 180°. Our parabolic antenna
is also directional, but the graph is less consistent. In addition to the
reasons listed above the copper wire may also be responsible: Since it extends
beyond the focal length in both directions signals which are reflected close to
the focal point hit the copper wire as well, reducing directionality.

# Conclusion

Our DIY antenna is a success: while it is not as good as an off-the-shelf
omnidirectional antenna it is certainly good enough to receive Wi-Fi signals
over a range of 100m, comparable to a non-DIY cantenna. It displays some form of
directionality, if not a very good one. Coming back to antenna gain it seems
that our antenna's gain is not even close to the theoretical maximum of 14 dBi,
maybe even negative.

There are many possible improvements to this design. The easiest way to increase
antenna gain (and directionality) is to increase its diameter. While 200mm is
close to the maximum of the Prusa MK3S, it would for example be possible to
split the design into quarters. Using a smoother material to cover the inside of
the dish may also help. Finally, replacing the copper wire with a receiver only
at the focal length of 100mm should increase directionality, at cost of a
significantly more complex model.

A variety of other DIY antenna models also exists, such as the
[cantenna](https://en.wikipedia.org/wiki/Cantenna),
[Wok-Fi](https://en.wikipedia.org/wiki/WokFi) (using woks or similar dishes),
and many more. Hopefully this post showed you that building a Wi-Fi antenna is
doable using only a 3D printer and some inexpensive hardware store/electronics,
and can be a fun side project! 

If you have any questions or comments feel free to reach
out to me via my [public inbox](https://lists.sr.ht/~bfiedler/public-inbox).

[^2]: for the 2.4 GHz bands

A content/blog/img/antenna-angle.png => content/blog/img/antenna-angle.png +0 -0
A content/blog/img/antenna-build.png => content/blog/img/antenna-build.png +0 -0
A content/blog/img/antenna-dist.png => content/blog/img/antenna-dist.png +0 -0
A content/blog/img/antenna-schema.png => content/blog/img/antenna-schema.png +0 -0