1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Esp8266 works for a few days then will not connect till reprogrammed

Discussion in 'Microcontrollers' started by dr pepper, May 28, 2017.

  1. dr pepper

    dr pepper Well-Known Member

    Joined:
    Oct 6, 2008
    Messages:
    4,648
    Likes:
    246
    Location:
    North west UK
    As per the title, I have a esp8266 01, and a wemos D1 R1, both boards I can program and they will work fine, they host a webpage no problem, in fact I can have 20 pages open at once and it works fine.
    But after a few days everything web wise stops, the esp still 'talks' over the serial port and controls stuff with its i/o ports but it will not connect to a browser, even if I power down for a few mins and power up - no connection, the only way to make these things work again is to re-program then, and I start over.
    It might well be something in my sketch (arduino ide), but finding this one wont be easy, unless someone here knows whats up.
     
  2. dr pepper

    dr pepper Well-Known Member

    Joined:
    Oct 6, 2008
    Messages:
    4,648
    Likes:
    246
    Location:
    North west UK
    Ok i have some more info, at least I know why comms just quits and a reprogram resets things, I think.
    The router changes its gateway address, it was on 192.168.1.1, then it went to 192.168.1.4, then .6 etc, can the routers ip address change that that if its working normally?, can the gateway be configured as dhcp?
    After doing a bit of google research I sorta think that connection.stay alive has something to do with this, not sure why that affects this router at work(which the only other use is for security cams), but not the one at home.
    Any lessons in router setup welcome (yes I know this is borderline for this forum).

    Edit: I think I sussed it, the IP I was using for the esp8266 was 192.168.1.13, there was another connection to the router 192.168.1.130, as soon as I deleted this things started working better, odd as 130 is an illegal IP address, and once deleted the router wouldnt let me put it back again.
    Turns out the lan gateway is static on 192.168.1.1, but the wan gateway is dynamic and times out after a period, ah well at leat I know the router a little better now.
     
    Last edited: Jun 4, 2017
  3. manalis

    manalis New Member

    Joined:
    Jun 29, 2017
    Messages:
    1
    Likes:
    0
    Hi dr Pepper,
    I am also trying opening the webpage using ESP and arduino, I have also used FTDI board with ESP, following this ESP8266 Getting started tutorial. So is this board is necessary? And can you please share your Arduino code for my webpage to work.
    I have checked the IP issues with the router, IPs are doing fine and you are right Gateway IP is static, previously I also thought that my gateway is changing IP with every restart of router but its not the case.
    Any help appreciated.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. dr pepper

    dr pepper Well-Known Member

    Joined:
    Oct 6, 2008
    Messages:
    4,648
    Likes:
    246
    Location:
    North west UK

    Welcome.

    The Ftdi is absolutely necessary as it allows the Ide to communicate and therefore program the esp, I gave up using a Usb to serial board as it was a right pain, I got one of these which does the same thing as the ftdi but also powers the esp and switches i/o 0 for you, I suggest you get one too, it'll save a lot of trouble:
    http://www.ebay.co.uk/itm/ESP-01-ES...871464?hash=item4b1485f8a8:g:SnYAAOSwhQhY25-2

    Ok then my code probably isnt any use to you, besides the actual code I'm talking about strictly speaking belongs to me employers as its written for them.
    What is eaxctly your problem, are you struggling to connect the esp to the net?, or having difficulties in programming.
    Did you get the blink sketch to work, if not then thats the first priority, getting the esp to talk to the Ide can be a real pain, I used the espressive tool as well to recover a bad esp but I do have one that will not come back, however the Ide usally recovers a messed up esp.
    Presuming you are able to program the esp try burning one of the examples, like the advanced web server, obviously you will need to change the defines in the sketch for your router ssid and password, you'll also need to find it a empty Ip address, you can do that by burning the Dhcp address printer sketch which is also in the esp examples, it displays via the serial monitor the ip that your router has assigned to it.
    Run the text terminal in the Ide just before you program the esp, then when it finishes programming you'll get reports via serial from the esp as to what its doing, you should get the 'connected' message probably followed by the ip address its using, then just type this Ip address into your browser and away you go.
    Dont forget you need to reserve this ip just mentioned and setup port forwarding on your router if you want to access the esp from another computer not on the same local net. The Ip you would then use to access from another pc would be your wanip, you can find this by typing whats my wanip into google.
    If you report your findings I'll see what I can do you get you going.
     
    Last edited: Jun 29, 2017
  6. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,214
    Likes:
    640
    Location:
    Derbyshire, UK
    Nice, far better (and smaller) than the board I made for programming the ESP-01 with an FTDI board - so I've ordered one :D

    However, for many applications it's easier to use a Wemos Mini, which makes more of the I/O available, and includes built-in USB.
     
  7. dr pepper

    dr pepper Well-Known Member

    Joined:
    Oct 6, 2008
    Messages:
    4,648
    Likes:
    246
    Location:
    North west UK
    Dont forget to unplug when you switch over Nige, allthough if you just progged a chip it will boot and run the code, still might be a bit of an issue if you have hardware in i/o 0.
    Certainly saves me a lot of trouble.
    The wemos mini is more££, but then you get a load more i/o, spi and of course usb, and the wemos has a lot more spiffs storage than the '01.
     

Share This Page