ESP8266 takes long time to connect - arduino

I am using an ESP8266 for a project which requires the ESP to establish a connection to the Access Point , with as less delay as possible, but as of now it takes a minimum of 4-5 mins for establishing the connection which is too much delay. I have tried to set a static ip, gateway, subnet and DNS by passing them as parameter to WiFi.config() function, still no success. Would someone help me regarding this issue ?

I have seen lengthy delays on ESP8266 WiFi connection if the WiFi is persisting its configuration to the flash memory. Anywhere from a few seconds to a minute or so.
Try to call WiFi.persistent( false ) before you call WiFi.mode() and WiFi.begin().
At the very least, that will help you narrow down the cause of the problem.

Ensure access point frequency is 2.4Ghz (not 5Ghz). This will cause prolonged connection time (never connecting).
"The ESP8266 is not designed for 5 GHz." Source
NodeMCU V1.0 (as pictured) uses an ESP8266's (ESP-12E) chip, Antenna is configured for 2.4 Ghz only.

I think the library <ESP8266WiFi.h> you are using have problems, you can use older versions of it.

Related

Problems connecting to nodemcu via johnny-five

I'm really having trouble connecting to my ESP8266. I was working with this setup for long time now and I didn't have to flash my boards. Now after having to use a different wifi i needed to flash the board. After doing the following
Updating to the newest ConfigurableFirmata
Using FirmataBuilder to download fitting firmata
Uploading the Firmata to the ESP8266
I can't connect via Johnny-Five anymore (getting the usual timeout error). I couldn't narrow down what it exaclty is (and I have been trying all day) but these are things that I have noticed (Using ConfigurableFirmata directly as well as using firmatabuilder and StandardWifiFirmata, all with the same behaviour)
an open Hotspot gets created even though I'm in Client Mode
when scanning for ports I do find the Module connected to my Wifi (Serial Monitor in Debug tells me the same too) but no open port is found, even though it's specified in the firmata.
I just can't narrow down the reason. I hope you guys can.
OK,
this was a simple user mistake. But since I lost a whole day searching for the error and I think others might too, I'll share my mistake here.
As I pointed out I created the Firmata as Client (thinking its a client to my Hotspot). But you will have to create it as a server (as you want to connect to the board)
It's as simple as that. If you are on http://firmatabuilder.com/ make sure you choose TCP Server if you want to connect to your board.

Slow internet connection requires forced reset of network adapter?

Computer is connected directly to modem via ethernet. Upon boot, an online speed test is consistently 10 Mb/s. This is significantly less than my service is supposed to be (50+). As soon as I disable and enable the ethernet adapter I can run another speed test at 60+ Mb/s. The connection appears to be stable at this point.
Additional information: Ethernet adapter is Realtek PCIe GBE Family Controller. Drivers are up to date. Tried rolling back drivers. Tried an old modems. Tried flushing DNS, resetting winsock, resetting IP. Tried changing the adapters speed from auto negotiation to 100 full.
I've got nothing. For the time being I've just got a batch file (using devmanview.exe) that resets the adapter on delay after boot but I'd like a more elegant solution. I've had hilarious conversations with my ISP support where I realize this is no longer on their script so they're no help.
Thanks for any help.
I stumbled upon a fix. Turns out the power output to wifi in my router settings was set to 100%. On a whim, I turned this down to 75%. This didn't seem to effect the wifi performance elsewhere in the house but it made my ethernet adapter resolve the connection speed correctly and perform more reliably.
The router is a Motorola Surfboard modem/router combo.

Arduino & ESP8266 - strange characters in response

I'm working on an Arduino Uno + ESP8266 project.
I try to use them as a web server on Wi-Fi network to control a motor that connects to Arduino - basically a trigger system that receives signals via Wi-Fi. Currently, I've successfully connected ESP8266 to my access point by sending AT commands from Arduino. Another client on the same network can statically access ESP8266's assigned IP address.
However, when I try to catch some HTTP queries (I want to use them as conditions to control the motor) I occasionally encountered the non-ASCII characters in HTTP request. I use serial comm to debug, please look at the screenshot in the link below:
Arduino - Computer serial communication for debugging
The line ",519:POST ..." should contain a complete number following "/?", but there's some strange characters instead. So I cannot determine the input data to control motor. Once in a blue moon, the expected format of request shows up as follows:
The correct data received
There's no issue with the HTTP response part, even though I got the uninterpretable request, I can still send the JSON error message back to client.
Attempt Note:
The Arduino uses different serial ports to talk to computer and ESP8266. Since the connection can be established, and the data being sent, I believe that the baud rate is simply correct on both side. (115200 for ESP8266, 9600 for computer - also tried 115200 for both and got the same result)
I use V3.3 from Arduino as power source for ESP8266. But I also use voltage regulator to smooth out the current as many people suggest that. The problem still remains.
I'm struggled with this issue for a few days, just want to know if anybody had the similar experience, or could give some clue for the next step.
After a considerable effort to stabilize the circuit, I switched to NodeMCU and got the system working perfectly. I assume that ESP8266 alone is somehow not robust enough without other components, which I unfortunately have no knowledge on.
So I'd like to close this thread with a short recommendation for anybody struggling with the same issue to switch to NodeMCU (which would replace both Arduino and ESP8266); if that could support the requirement.

Maximum file serving speeds capable by arduino? (TCP/FTP/WiFi/Bluetooth/RS232)

First up please note I am on the arduino forums but despite a few weeks of researching and experimentation I've not had much luck. I've greatly benefited from this forum in C# so thought I'd try my luck with an arduino question.
I'm very interested to know the maximum transfer speeds that have been achieved by an Arduino acting as a file server using the various network protocols such as RS232 vs Bluetooth vs TCP vs FTP vs Wifi. If someone has done a proper comparison I'd love to see it.
I've been scouring the net over the last few weeks and have found various webserver examples, and implemented a few myself, but I still can't seem to get the transfer speeds I need. The BEST rate I've got so far is 80kB/s via ethernet webserver, and about 20kB/s via WiFi. I've read of people getting 240kB/s via ethernet on custom light FTP servers so I know it's got to be possible to improve my speeds. I'm guessing it's my newb SPI and buffering code that might be inefficient. I've outlined some summary info below. I'd really appreciate any input on this from the pros!
And just to clarify - the arduino is the file server not the client for this scenario, and is serving files from the SD card to a client computer. Both are sharing the SPI bus.
My Setup
Ethermega (ATMega256)
SD Card (via SPI)
ATWINC1500 WiFi (IEEE 802.11 b/g/n running on SPI).
File Serve Method: HTTP Webserver accessed by a client browser
(Console access for RS232).
MAXIMUM SPEEDS ACHIEVED
RS232: 14kB/s
Via console I can serve large files direct from the SD card at around 14KB/s at 115200 baud (which is essentially the bit rate in short distance digital serial comms). As expected.
Bluetooth: ?
Not tested yet. I understand the bluetooth protocol supports up to 50Mbit/s in theory, however in reality Bluetooth 4.1 you can get about 1Mb/s (125kB/s) and the upcoming Bluetooth 5 is touted for 2Mb/s (333kB/s) max throughput (wikipedia). I suspect performance may also be severely constrained on a microcontroller like arduino. I'm guessing you might double 114200baud speeds to say 30kB/s?
HTTP webserver - Ethernet (TCP/IP): 80kB/s
I implemented [Sean Ashton's WebDAVNav][2] web based file server and modified it to server HTML not XML. Got it serving files from the SD card at 80kB/s. Tried to get [sirleech's Webduino][3] server going to no avail.
HTTP webserver - WiFi (TCP/IP): 20kB/s
I modified standard WiFi Webserver and coded SPI handling to share the SPI Wifi and SD card to serve files via HTTP GET method. It worked but is horrendously slow. After optimising my loops as best as possible, using a 1024 byte buffer, low level C calls to bypass the DigitalWrite/Read methods, I managed to get 20kB/s. I also looked at the [Jaycar example][4] of a WiFi webserver, however it uses the older style WiFi shield that uses serial, not SPI. So it's limited to serving at 500bytes/second.
Ethernet FTP fileserver (TCP/IP): ?
Not tested. I haven't implemented a light FTP server. I've read of people claiming 255kB/s transfer speeds using a Due. This is impressive.
Basically I'm trying to get the best possible wireless transfer speeds from an 8bit embedded microcontroller (ATMEGA256), such as an Arduino Ethermega, preferably by hosting a simple WiFi HTTP file server so the client browser can connect to it as a hotspot and rapidly download files from the SD card.
Any help would be appreciated and I hope this question is of relevance to the community.
Dan

Ethernet begin blocks for 60 seconds if there's no Ethernet cable

I'm building a clock. I want to set the clock by plugging an Ethernet cable into the clock. Most of the time the clock would not be plugged into the Internet.
I have an Arduino board and an Ethernet shield that can successfully connect to a time server and read the time (See the UdpNtpClient example file under Examples > Ethernet).
The problem is that to configure the Ethernet shield, the Ethernet.begin() call blocks for 60 sec if the shield is not connected to the Internet. I would like the clock to tell the time and periodically check to see if it has an Ethernet cable plugged in, and if so, make any corrections to the time. Most of the time this check is going to have a negative result, however, so I can't have the clock freeze for 60 sec each time.
Is it is possible to detect if the cable is connected in a quicker way than the Ethernet.begin() function? Is it possible to write a "multithreading" solution, where Ethernet.begin() is non-blocking?
Looking at the stock Ethernet library, it's not possible to prevent it from blocking.
I'm guessing you're using DHCP? This appears to be where the blocking comes from. Do you get the same problem when using a static IP address?
There's a number of blog posts available on Google covering this exact issue, including some forks of the Ethernet library that would allow you to do this in a non-blocking fashion.
In the DHCP.h header file you can find the class definition for a new DHCP connection.
Then you can see that there is a default timeout value of 60000ms.
(helpful hint: if you get past the initial effort, and start using eclipse to manage your adruino projects, its really great because you can just press F3 on a functions like Ethernet.begin and take a bit of a trip through the libraries to find these types of settings)
Its difficult to know how long the timeout should be. But a minute seems like a really long time. Of course you don't want to go to short.
I wouldn't go less than 15 seconds.
/David Cox

Resources