Home | Software | Rules and About | Atom feed
Admin | Edit
published: Sunday 23 December 2018
modified: Sunday 23 December 2018
author: Hales
markup: textile

Long range wifi with helical antennas

For the last few months I have been in a rural Greek mountainside village, using internet from a shared wifi AP (access point) in another village 1.2km away.

To connect over this distance I used a variety of home-made antennas:

Ignore the bad mounting position shown here, you don't want metal veranda poles in the way of your antenna :)

Summary

I have found 2.4GHz helical antennas are both very easy to make and very effective:

Rain affects your reception. I'm only certain of some of the reasons as to why:

Cheap modern $6 USB wifi sticks from eBay are a mixed blessing:

Aiming and configuring long-range wifi has a few tricks to it:

Ethics vs Practicality of Directional Wifi Antennas

Using a directional wifi antenna can create interference problems for other wifi users (and more). A common solution is to reduce your transmit power, which many wireless chipsets & drivers allow you to do, but I am sceptical of whether or not they actually honour this instruction.

I recommend reading up on some basic antenna theory before you attempt making or using your own directional wifi antennas. This allows you to predict and avoid potential problems you might cause for your neighbours.

In most countries you are permitted to use radios (such as wifi devices) only under certain rules and conditions. Most people are not aware of this (and in the modern consumer world you mostly don't have to be), but it becomes important when you start doing unusual things like using directional antennas.

Many countries have limits on the EIRP of an antenna. In simple terms: if your antenna is directional then you have to reduce your transmit power, otherwise you risk blasting your neighbours with a signal so strong it causes them notable interference. A directional antenna is a bit like a magnifying glass: the total power out remains the same as a less directional antenna, but some poor ant now gets more of it than the others.

Confirming you have actually reduced your transmit power is unfortunately very hard. I have found that whilst many wifi chipsets + drivers accept power reduction commands, they then leave you with no way of confirming if anything has actually changed in the real world. The only "proper" way to test is to use an RF anechoic chamber with calibrated equipment ($$$$$), something beyond what most hobbyists have access to.

In my experiments I have tried to 'hedge my bets' by also trying to minimise my chances of causing interference in other ways. Notably I'm:

I was on a steep mountain hillside with clear LOS (line of sight) to the target village, making this easier for me. I'm eager to see what other people think of my mitigations.

More fun: off-the-shelf high-gain antennas and wifi devices

Buying a directional antenna off the shelf does not avoid these problems. Remember: cheap phone and laptop chargers are known to damage phones & laptops, start fires and not meet local regulations. Why would cheap imported antennas meet local regs when other devices do not?

I am also very suspicious of the performance of many off-the-shelf directional antennas. How many customers actually test them in an anechoic chamber to make sure they are anywhere as good as they claim? Also note how much bigger the antennas in my article are than most of these off-the-shelf products.

What works

Helical Antennas

Both of these helical antennas performed "about the same", as best as I could tell, even though one is bigger than the other:

Helix antennas have a two modes of operation (side-firing and front-firing, we want the latter) and their output patterns vary depending on the dimensions you make them. Notable resources I recommend reading:

I recommend reading AB9IL's construction guide. My notes below cover details I think he missed or need further clarification.

Additional construction details

Normal (about 40-50mm diameter) plastic drain pipe, commonly used for sinks, is a good choice for the main stem according to most sites. I didn't try anything else.

Coppen's calculator will give you a minimum reflector size (the flat metal bit of the antenna) and in practice I found making it a lot bigger gave no noticeable benefit. I don't think the exact shape (square or round) matters too much either, both worked for me.

When it comes to the winding pitch (distance between turns) I didn't notice any difference between the easier to measure 2.5cm recommendation from one source or a 2.38cm calculation from somewhere else. Stick to what's easiest.

For the winding wire I ignored the thickness recommendations and used whatever I could get. I held the wire onto the main stem using hot glue.

The number of turns of wire (length of main stem) is a surprisingly unimportant consideration once you are above a certain number of turns. The equations linked above show that you get diminishing improvement by adding more and more turns. In practice I found my longer antenna wasn't noticeably better than the short one, so about 10 turns is a probably a convenient starting point to use.

Bill Slade's 'Basics of Quadrifilar Helix Antennas' [PDF] claims that (during antenna use) current levels are high in the first few windings of the antenna (near the reflector) and levels reduce in the windings as you travel toward the antenna's end. This model suggests that adding extra turns to the end is of limited benefit because these extra turns are only getting the small 'leftovers' of electrical signal to play with and radiate. In other words: the first few turns of a helical antenna are the most important ones.

This also suggests that reflections (an RF problem) from the end of the antenna are probably not important, because they are so small. When making my antennas I was concerned about whether or not I should finish my turns at the same angle as I started (or some multiple of a wavelength), but I suspect it really does not matter provided you have enough turns in the first place.

Connecting the antenna to your wifi card

Most often you screw an RP-SMA antenna onto a wifi card (external) or connect a tiny cable with a tiny UFL connector (inside laptops):

My USB wifi cards had RP-SMA connectors and my Orange Pi Zero board had a UFL connector, so I ended up trying both.

RP-SMA leads can be found by cutting open cheap router antennas (like the ones in the photo above). It takes quite a bit of nibbling to get to the wire, but they cost nothing if you have any discarded wifi APs. The salvaged cables are typically quite short (<10cm).

UFL leads can similarly be had for cheap by pulling them out of broken old laptops. Most/all laptops use them between the internal wireless cards and the lid-mounted antennas. These are typically very long (>30cm).

The wires attached to these connectors are coaxial. You want to split the shield and the core wires from each other before you connect them to the antenna. This is a bit of a pain and requires patience with either scissors, wire cutters or wire strippers.

I suggest drilling a hole in the reflector to pass the wires through. Keep the connector on the outside, pass the wires through the hole to the inside (where the plastic tube is) and connect them there. Here is the rear of one of my antennas:

To connect the coax centre wire conductor to the spiral: I used solder.

To connect the coax shield to the reflector: I used a self-tapping screw (which you can see sticking out at the top of the photo above). Nothing fancier than that.

You want to keep the amount of coax you have separated apart as short as possible.

I'm not sure if it matters exactly where you feed or attach the coax shield to the reflector or not. Attaching at the centre of the reflector looks like it would make the most sense, but in AB9IL's guide he attaches the wires off-centre (near the spiral start) for convenience like I show in the photo above. I think this is wise, as centre feeding is difficult to do without also having centimetres of exposed coax wire OR unmatched wire lengths, which would be a noticeable chunk of a wavelength at 2.4GHz (12.5cm). I'm interested in other people's opinions on this.

Using an Orange Pi Zero H2 as a receiver

My Orange Pi SBC (single-board computer) was a much more durable option to the USB wifi sticks I tried (more on them later). Here it is inhabiting a white feta-cheese container for improved weatherproofing:

There's a little $1 DC-DC buck module in there converting the 12V I fed over some long wires into the 5V the oPi likes to eat. Mmm, oranges and feta.

Manually changing wireless settings when needed

I found some wireless chipsets/drivers would work fine for a few minutes, then suddenly stop passing packets. It looked like the cards were changing modulation modes/speeds and their decisions were occasionally bad. In these situations I found forcing certain settings helped.

Example linux commands:

iwconfig --help
iwconfig wlan0 rate 2M

This advice is heavily situation dependant. I'm sure not all cards/drivers have this problem.

Also: higher-rate modes can sometimes perform better in bad reception situations, because a lot changes between the different modulation schemes. Ideally you want to stay at as high of a speed mode as possible, even if you are not using that much bandwidth, because you will also use less air-time and cause less interference for other people.

Rain coats for your antenna

When it started raining my wireless link would die.

Rain fade is apparently not supposed to be too much of a problem at 2.4GHz. This left me puzzled.

I eventually discovered that drying off the base of the spiral of my helical antennas returned most of the performance. My hypothesis is that the conductive water was changing the geometry of my antenna.

Most commercial antennas are made entirely of metal, or have an evenly distributed plastic coating. This means that a thin coating of something conductive on their surface (eg rain) is unlikely to change the antenna's shape by any large amount.

Solution: a big black plastic garbage bag over the antenna. Beware baggy antennas.

Overall: this didn't completely fix my reception problems during or after rain. I suspect the rain is also heavily changing how the environment looks to my signals. Wet trees, wet walls, etc.

Aiming assistance

Initial aiming can be done by eye, but after this you need the assistance of actual measurements.

I designed my helicals to have a hole in the centre if the reflector so I could look "through" the tube to aim them. This turned out to be completely silly. The antennas are not that accurate in the first place and I even suspect their radiation pattern is a hollow cone rather than a solid one (ie they have a blind spot in the centre). Not too sure.

Curiously re-aiming the antenna was necessary after a certain number of days or (more interestingly) after power blackouts. The AP I was connecting to was changing which 2.4GHz channel it was using, something I assumed would be a negligible problem, but it's my best guess as to the cause.

To aim the antennas I used two stages of assistance:

Statistics before you connect

My first wireless cards supported "monitor mode", allowing me to use tools like kismet to see signal strengths. Unfortunately many of my others didn't, so I had to invent my own techniques.

(1) Find what frequency your AP is on.

iw dev wlan0 scan | grep -B6 SSID 

(2) Monitor the signal strength of the beacons you receive from it.

while true; do iw scan dev wlan0 freq <yourfreq> ssid <yourssid> | grep signal; done 

Limiting the scanning to a single frequency (channel) makes the scans super-fast. I was getting about 4-5 results per second doing this.

Statistics after you connect

The first and most obvious things to monitor are "signal quality" and "signal level". The tools 'iwconfig' and 'iw' report these numbers. I found different drivers used these numbers differently.

The most fun way I used these numbers was to make script that played different pitches of beep depending on my signal quality:

#!/bin/bash

device="${1:-wlp0s20u2}"

while true
do
	mess="$(iwconfig "$device" 2>&1)"
	
	cat <<< "$mess"

	if ( grep -q 'Access Point: Not-Associated' <<< "$mess" )
	then
		aplay swish.wav &>/dev/null &
	elif ( grep -q 'No such device' <<< "$mess" )
	then
		aplay swish.wav &>/dev/null &
	else
		siglevel="${mess##*Link Quality=}"
		#siglevel="${mess##*Signal level=}"
		siglevel="${siglevel%%/*}"
		
		# Adjust these numbers depending on what range of numbers your drivers report
		pitch=$(( (siglevel - 20) * 40 ))  
		
		play -q beep.wav pitch $pitch &>/dev/null &
	fi
	
	sleep 0.2
done

This script won't work on your computer without some modifications. You will need some .wav files for a start, and the output of iwconfig might be different on your system. You need to install 'sox' to get the 'play' utility.

I hope this inspires you to have some fun using sound to aim your antennas -- it's a million times more convenient than having to look at a laptop screen, especially when on a balcony.

Unfortunately I found these signal strength/quality numbers reported by the various wireless drivers were often absolute junk. Higher quality (hint: the numbers are often negative) links were sometimes worse performing than lower quality links.

We have computers, we should be doing real tests.

As it turns out: the good old GNU 'ping' utility has a lot of options useful for us. Notably it can send packets of arbitrary size and it can try to 'flood' pings with zero delay. I kept upping the packet size until packet drops were occurring, then I aimed my antenna to minimise these drops.

Again sound was useful for this. GNU 'ping' supports a flag to play pc speaker style beeps, but my laptop does not have one of those. Instead I put together another shell script that played a beep.wav every time a ping came back. Aiming was as simple as trying to make the beeps happen as often as possible.

#!/bin/bash

url="${1:-192.168.1.1}"
packsize="${2:-500}"
interval="${3:-0.2}"

while true
do
	ping $url -s $packsize -i $interval 2>&1 | while read line
	do
		echo "$line"
		
		if ( echo "$line" | grep -q 'unreach' )
		then
			aplay swish.wav &>/dev/null &
			break;
		fi
	
		aplay beep.wav &>/dev/null &
	done
	sleep 0.5
done

Setting up a second wireless network for local use

Initially we were using USB wifi sticks plugged directly into the antenna. We would then plug our laptops in. Not ideal or shared, but a long USB cable helped and overall it worked fine.

Later on I setup an ordinary household wireless router as an indoor AP for us to use. This AP was connected to my Orange Pi single-board-computer via a long ethernet cable. The Orange Pi then had its internal wifi card plugged into the helical antenna, handling the 1.2km connection. Anyone in the house could now access the internet.

Only some household wireless routers are suitable for this. You need to be able to change what 'gateway' they tell clients to use (over DHCP) or you need to be able to disable their DHCP server feature entirely. If you don't do this then they will tell everyone that they are the route to the internet. Which they won't be.

In my case I disabled DHCP on the consumer router and ran my own DHCP server (dnsmasq) on the oPi instead.

To tell the oPi to connect to the 1.2km away AP: I used wpa_supplicant directly. Its configuration files are very simple and I'm used to using it directly on my laptop anyway. I recommend anyone who has troubles in daily like with NetworkManager or Wicd give it a go.

I set the oPi up as a NAT. This simplifies things noticeably. The alternatives (the various flavours of wifi bridging) are complicated and full of non-standard fun. Using a NAT means I could connect the oPi to the distant network "normally" without any headaches.

What went badly

Cheap USB wifi sticks have appalling build quality

These things:

After about a week of use they would start becoming flaky or die (tilting them would sometimes get them temporarily working again). I ended up going through about 2 or 3 of them.

Externally these devices have the same case, but internally I came across two different variants with different chipsets. More variants probably exist. One even identified itself with the name of the silicon fab that made it, so I think these things are made in short runs and are "very" modern (hence why they performed so well).

I suspect the problems with these devices are mostly mechanical. Have a look inside one:

In order to try and cram as much as possible into a tiny space they are:

I suspect the strain is leading to solder, track and/or part fractures. I was unable to confirm this visually.

Here is a different chipset with the rest of the (identical) case removed:

So what do you do if you're stuck in a rural area with suspect solder fractures? Why not try to reflow your life away!

Here we have a little butane-canister burner. On top is an aluminium sheet with some sand for thermal mass. The old damaged coins have small amounts of solder on them, so I can visually see when the right temperature is hit. Some small pieces of rosin flux are scattered across the board.

I think I was a bit too over-zealous in the cooling step. The wifi cards never worked again :P

Yagi Uda antennas

Yagis are often used as TV antennas use on top of houses. Here are the two prototypes I made:

Performance was better than using a normal whip antenna, but it was not anywhere as good as the helicals. Likely reasons:

Making the yagis was a ton of fun, however. There are all sorts of calculators and tools out there, including the DOS-based Yagi Optimizer which changes your antenna to try and meet set goals:

Sex in less than 64K.

A final note is how hard it is for a beginner to learn how to attach his leads to a yagi. Most guides assume you know this already, and call one element in the yagi a 'reflector' even though you are not supposed to connect your ground there. Again, it's supposed to be balanced, there is no 'ground', yada yada. What do you mean you've never wired a balanced folded dipole before?

To confuse me even more I spotted a television yagi on someone's roof that appeared to be fed from the tip of the small end. I think I'm going mad.

Software on the Orange Pi Zero H2

The oPi comes in a really cute square form factor and is about 22 AUD shipped. This time I'm stealing a photo, because I left my unit in Greece:

It's the cheapest SBC I could find with with ethernet and there's even a version with two ethernet ports. Whilst only one USB port is installed, another two are hidden in the 2.54 pins on the side.

By luck I brought my oPi with me to Greece. It turned out to be a more stable solution than cheap wifi USB sticks. But only after some lengthy software battles.

Distro support

Less popular single-board computers like mine do not have abundant Linux distro support. This turned out to really suck.

The first distro I tried was Raspbian.

What I really wanted was something lightweight and predictable like OpenWRT. Unfortunately there's no OpenWRT build for this board. But the OpenWRT page did point me in the direction of a project called miZy

Oh my lord this was miles better:

It's no-where near perfect, however:

I really wanted to stick with Raspbian's because of its bigger software selection, so I started throwing a small single shellscript init replacement for systemd together, but this turned out to be redundant effort anyway because...

Distro-dependent wifi performance

I could connect to the AP 1.2km away using wpa_supplicant under miZy. I could not connect to it using wpa_supplicant under Raspbian.

I tried looking to see if miZy was doing any special magic. One thing it did was change txqueue length for the wireless interface. Repeating this process under Raspbian didn't fix the problem.

In the end: miZy was the only thing that worked, so I stuck with it. I still don't know what was being done differently.

Old laptop wireless cards are poor

These turn out to be no-where as good as the cheap $6 USB wifi adaptors off eBay. I had some intel ones, an atheros one and I think another brand (ralink?). When you can get the drivers working they are still completely deaf (can't see nor connect to weak networks) compared to the cheap USB sticks.

... but old laptops are a good source of UFL cables.

RP-SMA and SMA are not the same thing

Professional evil that will last us for generations. I salute whoever invented these.

Bonus points if you can work out how the hell these things are considered 'female'. Perhaps I need to be a prokaryote.

End notes

The final helical antenna setup I used was reliable enough for about 2-3MBit/s on good days. Watching youtube videos was possible most of the time. I was pretty impressed that this worked over the 1.2km link.

I can only imagine how good the performance would be with a helical antenna at both ends of the wireless link rather than just one. You could really ramp down the transmission power too.

Even since making these antennas I have been dreaming of running my own WISP with rooftop-to-rooftop helical antenna links. Internet in my area really sucks, if only for how bad the tech support is if you try to ring up and get a problem solved.

Unfortunately my triage is that it's not easily financially or legally practical here. Proper peering costs a lot and would require a lot of initial customers to make financial sense. I can't piggy-back home connections due to terms prohibiting this in the agreements. And the Australian Telecommunications Act 1997 has been some scary reading.

I hope this lengthy article has some useful or interesting information. Any comments or concerns? Please add them below.


andy - Friday 2 August 2019

Wouldn't removing the usbwifi adapters shell and soldering direct connection to the usb trace help with the pcb flex issue.
Also you could have used a router with its wifi connector to the homemade helical then used its ethernet cable to your other indoor AP.
Using a router with multiple antennas with MIMO with helicals might have helped.
And how does one connect to a homemade yagi ? Nice article enjoyed it.

Hales - (site author) - Friday 2 August 2019

> Wouldn't removing the usbwifi adapters shell and soldering direct connection to the usb trace help with the pcb flex issue.

Possibly. PCB flex was a hypothesis, I was not able to confirm it. Either way I was out of USB adaptors and stuck on a mountain :)

I tried doing this to recover one of the units, but it was already too late.


> Also you could have used a router with its wifi connector to the homemade helical then used its ethernet cable to your other indoor AP.

That would have been great. Unfortunately my supply of routers was limited to what I could find in the free junkpile of a few computer repair shops in a nearby town, and none of them were suitable.

Of the couple I was able to get control over: they used proprietary programs to handle all of their wifi AP stuff (ie not wpa_supplicant or hostapd). This meant they were stuck as "wifi access point only" devices, not "wifi clients" as I needed. The wifi router I ended up using was of this type.

Ideally I would have found a device that was supported by Openwrt. I got close (right model, wrong revision).


> And how does one connect to a homemade yagi ?

Poorly!

One of the bits of wire (second from the back) is supposed to be your "driven element". Yagis are balanced antennas, so this means your "driven element" is most often a dipole:

https://en.wikipedia.org/wiki/Dipole_antenna

Basically imagine: one bit of straight wire. Cut it in the middle (so it's now two pieces of wire). Attach your two antenna lead wires to either side of the cut.

In the photos above you will see I made a "folded dipole" (a big loop of wire) instead of a "dipole", this has some advantages in terms of impedance. Theoretically.

As mentioned in the article above: the yagi didn't work well. Primarily this is because I was attaching an unbalanced cable (coax) and wifi device to it. To skip lots of electrical and radio-physics explanations: the antenna is not made for this sort of cable and device. To properly attach a balanced cable/device to an unbalanced cable/device you need to use a "balun". If you don't do this then part of your cable turns into the antenna (or visa versa), completely ruining your antenna design (it becomes something else completely).


> Nice article enjoyed it.

Thanks Andy


Add your own comment:

Name:
Email (optional):
URL (optional):
Enter the word 'irrlicht' (antispam):
Leave this box blank (antispam):

Comment (plaintext only):

If you provide an email address: it will only be used for the site admin to contact you, it will not be made public.

If you provide a URL: your name will hyperlink to it.