Pull-up (and pull-down) revisited
Posted: Sat Mar 19, 2016 6:48 am
There have some amount of discussions about the necessity (or lack thereof) of pull-(down/up) resistors on (un)used pins. To that discussion I would like to add a short story of a real-life experience I had recently. It might change your point of view on this subject.
I have been struggling getting a good connection on WLAN-level since the start. Connection speed always falls down to ~10 mbps very quickly and when I start to send bigger amounts of data (larger packets, quick succession), the connection speed drops even more, to the point where it reaches "0" (according to my access point) and no data is sent or received at all. After some time the esp recovers and it starts all over again.
I have no reason to believe my access points are at fault, they're semi-professional ones and they have no problems with other devices.
Lately the problem has become such that the esp couldn't get a connection at all. Tried "everything", access point configuration (802.11g vs. 802.11n, speed hard wired, channel, etc.), no success. Finally attached the UART for debugging. Immediately got a connection. Coincidence I thought. Another try. And another. Connection, no problem. Removed the UART connection, no WLAN connection. Time after time. Connected the UART again, good WLAN connection, again, time after time. This was no coincidence.
I suspect the power, that the esp would be silently (also) fed by the cp210x. Measured the power, no problem. Added a large capacitor (2200 μF) to be sure, but no difference. Afterwards it appeared I didn't even connect the power line (which is as it should be) so power couldn't be the issue.
The only thing left was the impedance on the GPIO lines. I use my UART connection for programming as well, so it's connected to GPIO0 (boot select), RST, GPIO1 (UART) and GPIO3 (UART). Checked all of these without the UART connector inserted. GPIO0 and RST where already low-impedance, pulled up to 3.3V. That could never make the difference.
The GPIO1 and GPIO3 where high-impedance though (of course, if you think of it, nothing connected). I started with a pull-down. I used 1k for a strong pull but not too strong to damage the driver (1k = 3.3 mA). This made the pin going down all of the time, rendering the UART unusable and also made the esp not boot up. Then changed the resistors to pull-up and voilà, all working again.
Not only was the esp now booting properly, it also connected immediately, every time again and UART was also functioning as it should.
But the biggest surprise was the performance. Now I have a connection of 65 Mbps all of the time (the highest possible on the esp), I can send a flood ping of 1400 bytes sized packets to it with an interval of 5 milliseconds (didn't try less, actually) and none of them drop... The connection speed remains 65 Mbps.
It gets even better. I have an access point on another floor with the same SSID. I turned off the local access point and restarted the esp. I immediately connected to the other access point, also with a connection speed of 65 Mbps and also no packet loss with large packets.
A big mystery solved for me.
Lesson learned: always pull up or pull down I/O pins. Not only the one's you're not using (which I already did), simply every single one of them. The esp has very high impedance inputs combined with quite strong output drivers, so it requires and also can handle quite strong pull-ups.
Cause of the problem? I can never know for sure, but it looks some RF signal was leaking out of the IC over these pins and the unterminated lines were acting as an antenna. Very bad.
I have been struggling getting a good connection on WLAN-level since the start. Connection speed always falls down to ~10 mbps very quickly and when I start to send bigger amounts of data (larger packets, quick succession), the connection speed drops even more, to the point where it reaches "0" (according to my access point) and no data is sent or received at all. After some time the esp recovers and it starts all over again.
I have no reason to believe my access points are at fault, they're semi-professional ones and they have no problems with other devices.
Lately the problem has become such that the esp couldn't get a connection at all. Tried "everything", access point configuration (802.11g vs. 802.11n, speed hard wired, channel, etc.), no success. Finally attached the UART for debugging. Immediately got a connection. Coincidence I thought. Another try. And another. Connection, no problem. Removed the UART connection, no WLAN connection. Time after time. Connected the UART again, good WLAN connection, again, time after time. This was no coincidence.
I suspect the power, that the esp would be silently (also) fed by the cp210x. Measured the power, no problem. Added a large capacitor (2200 μF) to be sure, but no difference. Afterwards it appeared I didn't even connect the power line (which is as it should be) so power couldn't be the issue.
The only thing left was the impedance on the GPIO lines. I use my UART connection for programming as well, so it's connected to GPIO0 (boot select), RST, GPIO1 (UART) and GPIO3 (UART). Checked all of these without the UART connector inserted. GPIO0 and RST where already low-impedance, pulled up to 3.3V. That could never make the difference.
The GPIO1 and GPIO3 where high-impedance though (of course, if you think of it, nothing connected). I started with a pull-down. I used 1k for a strong pull but not too strong to damage the driver (1k = 3.3 mA). This made the pin going down all of the time, rendering the UART unusable and also made the esp not boot up. Then changed the resistors to pull-up and voilà, all working again.
Not only was the esp now booting properly, it also connected immediately, every time again and UART was also functioning as it should.
But the biggest surprise was the performance. Now I have a connection of 65 Mbps all of the time (the highest possible on the esp), I can send a flood ping of 1400 bytes sized packets to it with an interval of 5 milliseconds (didn't try less, actually) and none of them drop... The connection speed remains 65 Mbps.
It gets even better. I have an access point on another floor with the same SSID. I turned off the local access point and restarted the esp. I immediately connected to the other access point, also with a connection speed of 65 Mbps and also no packet loss with large packets.
A big mystery solved for me.
Lesson learned: always pull up or pull down I/O pins. Not only the one's you're not using (which I already did), simply every single one of them. The esp has very high impedance inputs combined with quite strong output drivers, so it requires and also can handle quite strong pull-ups.
Cause of the problem? I can never know for sure, but it looks some RF signal was leaking out of the IC over these pins and the unterminated lines were acting as an antenna. Very bad.