It's finally here - after months of teasing - I've actually finished a video on the range of ESP-Now
We've got some really interesting results.
But first, I'd like to thank PCBWay for sponsoring the channel. PCBWay offer PCB Production,
CNC and 3D Printing, PCB Assembly and much much more. They are great to deal with and
offer excellent quality, service and value for money. Check out the link in the description.
So, what is the real-world range of ESP-Now?
This question came up a lot in response to the walky-talky project.
You'd think this would be a simple question to answer,
but I think it's actually pretty complicated.
There are 3 things that we need to define before we can start:
What are the test conditions?
What equipment should we use?
And, what does it even mean to be in range?
Once we've answered these questions
We then need to work out how we're actually going to do the testing.
Let's break the questions down into a bit more detail and try and answer them
What are the test conditions?
Is it indoor going through multiple walls?
Or, is it outdoor?
Do we have a direct line of sight
or are there trees and other things in the way?
I've decided to do an outdoor test
I'm not sure there's too much value in trying to do an indoor test.
Everyone's house is different.
I could say "I've got coverage in the kitchen, bathroom and bedroom"
but that doesn't really mean anything to anyone else.
Everyone has a different shaped house and everyone has different walls and construction.
We look out on a very convenient bit of open space
and have a handy balcony to place the base station on.
So an outdoor test is going to be quite straightforward to perform.
We'll have some trees in the way and a couple of fences.
But that will be a good test of the "real world" range...
On to the next question
What equipment should we use?
Just looking around my desk I can see at least 5 different ESP32 devices
and if I looked through my boxes I'd probably get 10-20 different ones
including some of my own custom boards...
Do we want to use an external antenna in our tests?
Or do we want to build some crazy antenna amplifier using pringle cans?
Or should we just stick to a standard PCB antenna?
I've chosen what's convenient for me.
For the mobile station, I'm using a TTGO display
this makes it easy for me to check that everything is functioning correctly while I'm doing the test.
For the base station, I'm using a TinyPico - this isn't driven by any particular reason,
it was just conveniently on my desk when I was testing the code.
Neither of these devices supports an external antenna
and I think that using the built-in antennas is a more realistic real-world test.
I'm going to be powering both of these devices with USB power banks.
Finally, our last question
What does it even mean to be in range?
I'm going to answer this question with another question:
What is an acceptable packet loss for your project?
Do you need completely reliable communication?
Or are you happy with a lot of packets being lost and retransmitted?
Are you with the range if you transmit 100 packets and one of them gets through?
Or do you need 100% of my packets to get through?
In this experiment, I'm going to try and generate the data needed
to give you an idea of what you can expect at different distances.
So, onto the last part
how am I going to do it?
Most of these questions came from the walky-talky project
which was streaming audio data at around 64 packets per second.
I'm going to recreate this but in a more controlled way.
I'm going to create base station that will broadcast packets 64 times a second.
I'll then track how many of these packets the mobile station receives.
From this, we can work out how many packets have been lost.
I'll be using the broadcast mode of ESP-Now
so the base station will just be sending packets out without any acknowledgements or retransmissions.
For the mobile station, I've equipped it with a GPS and an SD Card for logging the data.
I've got videos on how to hook up both of these to an ESP32 on the channel.
We'll record the location along with the packet loss every second
and then process this data to work out the distance from the base station
For the base station things are lot a simpler - we just need the ESP32 board
and a USB power bank so that it can be put on the balcony.
With all this in place we can move onto the actual testing.
I've gone out for a walk over the past couple of mornings
with the mobile station in my backpack and collected a bunch of data.
This is real-world data sometimes I am walking towards the base station,
sometimes away or walking past
I've tried to get a few different angles to give the mobile station the best possible chance to pick up packets.
With the data collected and analysed, we get some interesting results.
We can get some packets through up to around 320 meters away
this is a pretty amazing result.
I'm not saying very many packets will get through
but under ideal conditions you will get some data transmitted.
320 meters seems to be the cut-off point between getting some data through
and receiving no packets.
Beyond that point, we no longer detect any data.
We can look at the data in more detail
I've plotted the distributions of packet loss over a set of distances.
0-50 meters you are very likely to get 100% of your packets delivered
but if you are unlucky or behind a tree you may lose 40 to 60 percent of your data.
50 to 100 meters we've still got reasonable coverage
but you are less likely to get 100% packets received
and you're more likely to get around 30% packet loss.
As we increase the distance it's more and more likely that we'll get 100% packet loss and no data will be received
until we finally reach the point where all packets are lost and you won't receive any data.
Now there is something interesting that requires a bit further investigation
there's a couple of cryptic lines of code in the esp-idf examples.
Using WIFI_PROTOCOL_LR will switch the ESP device into long-range mode.
However, this does come at the cost of bandwidth.
I've turned this option on in both the base station and the mobile station
and done another walk tests to see if it makes any difference.
Amazingly, we can now receive packets up to 500m away from the basestation!
Given that there are trees and all sorts of things getting in the way this is a fantastic result.
However, we are trading off range for bandwidth.
I've set up a simple experiment on my desk to test out what the bandwidth is.
I've set things up so that I'm transmitting packets as quickly as possible.
As soon as a packet is sent, I send another one.
On the receiving side, I'm logging how many packets come in per second.
With standard ESP-Now setup
I get a throughput of around 320 packets per second which works out at about 0.6Mbits/s.
With long-range mode enabled I get a throughput of around 95 packets per second
which works out at about 0.2Mbits/s.
So we get about a third of the throughput when we're running in long range mode
So there's definitely a trade off in switching over to this mode.
That's it for this video
it looks like you can achieve over 500m range with ESP-Now
which I find absolutely amazing.
With good antennas and line of sight without any obstructions,
I think you could extend this even more.
Anyway, I hope you found it interesting,
if you did then please hit the subscribe button. There are more videos in the pipeline.
Thanks for watching and I'll see you in the next video!