This is Hohenneuffen castle, about 10km away
from where the camera is at. And this here is an ESP32 connected to a cheap
OV2640 camera module. In the lab, this setup can transmit live pictures. I was wondering if this could work over a
distance of 10km and what kind of antenna I would need for that… Luckily, there are ways to calculate this. Let me introduce you to the Friis Equation. This equation can be used to estimate the
received signal strength, where lambda is the wavelength, P_t and P_r are signal powers
at the transmitter and at the receiver and G_t and G_r are their respective antenna gains. The antenna gain basically just tells us how
much the antenna focuses in the main radiation direction. An ideal isotropic radiator would have a gain
of 0 dBi, this typcial omnidirectional antenna has a toroidal radiation pattern and a gain
of 8dBi. The R in the Friis equation is what we actually
care about, the distance between the two antennas. At a first glance, this equation looks pretty
bad for us given that the R is in the denominator and gets squared. The good news is, that even consumer-grade
WiFi equipment is really good at decoding signals with less than femtowatts of signal
strength. So good actually, that we commonly use the
logarithmic decibel scale in order to describe tiny power power levels. In order to convert some power level into
decibel-milliwats, or dBm for short, you just have to take ten times the decadic logarithm
of the signal strength in milliwatts. This way, 100mW become 20dBm, 1mW becomes
0dBm and 1µW becomes -30dBm. If we apply this same idea to the Friis equation
and take 10 times the logarithm of both sides, the difficult multiplication gets replaced
by simple addition. Since all we care about is how much the power
level changes if we increase the distance between transmitter and receiver, we can also
write this as some constant value minus 20dB times the log of R.
So if we want to use the same setup to transmit over twice the distance, we have to double
R. By logarithmic identites, we find that this only contributes to a constant summand
of -20dB times log(2), which is approximately -6dB. To put it bluntly, every time we double the
distance between two antennas, we lose 6dB of signal strength. So what can we do against that? We can't just increase the transmit power
since most countries' laws prohibit that. A common misconception is the idea that a
better antenna at the transmitter will drastically increase our range. This is in fact not true if we abide by the
law. Regulations in most countries state that the
equivalent isotropically radiated power or EIRP for short must not exceed 20dBm. So adding a better antenna to the ESP32 won't
do any good, since that would force us to reduce the transmission power. Instead, we need to rely on a really good
antenna on the receiving end. While I'm preparing the receiver setup, some
friends of mine ascend the mountain towards Hohenneuffen castle. This historic location has the advantage of
being an easy to target landmark with perfect line of sight and no surfaces nearby that
could cause interference. After fixing some last-minute firmware bugs
in the castle courtyard, we were ready to transmit. On the receiving end I'm mostly using cheap
consumer-grade hardware such as this USB WiFi adaptor. The only uncommon gagdget is this 60€, 24dBi
directional 2.4GHz antenna. 24dBi implies that we should be able to cover
a distance of up to 16 times more than usual with this antenna. As it turns out, just manually pointing the
aerial in the general direction of the castle is enough to get decent signal strength. The image quality might not be the best, but
picking up signal from the ESP32 from a distance of 10km was no problem at all. At this point you might be wondering how it
is possible to only receive data from the ESP32 without sending anything. Well, I do have one confession to make: I'm
technically not abiding by the WiFi standard in this case. Typical WiFi specifies access points and stations
that need bidirectional communication. In my mode of operation, however, I'm using
the receiver in what is known as promiscuous or monitor mode while I'm exploiting functions
hidden in the ESP32's wifi stack in order to send arbitrary data. Nevertheless, it's just amazing how this little
WiFi chip can send data over such a long distance. If you want to learn more about how sending
arbitrary packets with the ESP32 works, there is more information in the video description