Chat freely about anything...

User avatar
By WStan
#22934 1.
My Home Internet Config:
Internet ->Router -> Wireless Router LinkSys WRTU54G ( setting as Bridge) -> Home Computers with WiFi Cards
2.
Adding #include <ESP8266WiFi.h> nothing changes .
This is Arduino.ide for ESP and if program is succesfully compiled without additional includes adding them is unnecessary ( I think)
3.
Why do I have to set wifi.mode if the ESP does not need to connect to the wifi in my program?
User avatar
By tytower
#22936 So you are saying the router ,only when on ,interferes with the chips operation in some way ?
Have you looked at the configuration of the routers wireless access point via your browser by going to 192.168.0.1 or whatever your router uses .

If the time taken to reset increases to 50 seconds when you have "wdt_disable (); " in your code rather than 30 seconds without it in , then it's telling you its having an effect on the problem . My understanding is that the watchdog timer resets after 1 second of inactivity in the chip. You would have to go to the wiki on this page -see above , which will lead you to the expressive data sheet and read up on the wdt. Perhaps its resetting because it expects to connect to an access point and it is not doing so in a set time limit ? I don't know . I only use the chip when I need connectivity.

I use a .01uF capacitor across XPD pin and RESET and use the function "ESP.deepSleep(sleepTimeS * 1000000);" where "const int sleepTimeS = 20;// Time to sleep (in seconds):". So this keeps the chip powered down sucessfully for 20 seconds and when it resets the program starts from the start again . Perhaps something above is helpful.
User avatar
By burkmurray
#22956 Wifi.mode has a tendency to persist, even after you've flashed new code. In the current release, if you've ever connected to an AP, the ESP will retain the SSID and try to log you in unless you explicitly set Wifi.mode. So, setting
Code: Select allWiFi.mode(WIFI_OFF);

may ease your problem, but I don't think it will totally solve it.

How are you powering your ESP? One of the most common causes of WDT resets is insufficient current. It's tricky, because the chip will run fine until it tries to transmit, then it'll choke when it needs (for instance) 250mA and your power supply can only provide 200mA.

Your code runs fine for me, for many minutes, even when my ESP connects to my AP. But I'm running it from a 1A power supply through a regulator.

If you're using your PC's USB port (or, worse yet, the 3V output from a serial converter) you may find that you don't have enough juice.
User avatar
By WStan
#22961 Configuration:
ESP8266.jpg


Ok, let's change program that works with WiFi router:
HelloServer (from examples in Arduino.ide):
Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
 
const char* ssid = "@HomeCA72";
const char* password = "";
MDNSResponder mdns;
int Count=0;
const int led = 0;
ESP8266WebServer server(80);

void handleRoot() {
  digitalWrite(led, 1);
  server.send(200, "text/plain", "hello from esp8266!");
  digitalWrite(led, 0);
}

void handleNotFound(){
  digitalWrite(led, 1);
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++){
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
  digitalWrite(led, 0);
}
void setup(void){
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
 
  if (mdns.begin("esp8266", WiFi.localIP())) {
    Serial.println("MDNS responder started");
  }
 
  server.on("/", handleRoot);
  server.on("/inline", [](){
  server.send(200, "text/plain", "this works as well");
  });

  server.onNotFound(handleNotFound);
 
  server.begin();
  Serial.println("HTTP server started");
}
 
void loop(void){
  Count++;
  server.handleClient();
  Serial.print("Count=");
  Serial.println(Count);
  digitalWrite(led, 1);   
  delay(200);               
  digitalWrite(led, 0);   
  delay(200);   
}


Result:
1. WWW page 192.168.1.102
hello from esp8266!
2. Serial Port
Code: Select allConnected to @HomeCA72
IP address: 192.168.1.102
MDNS responder started
HTTP server started
Count=1
Count=2
Count=3
Count=4
Count=5
Count=6
Count=7
Count=8
Count=9
Count=10
Count=11
Count=12
Count=13
Count=14
Count=15
Count=16
Count=17
Count=18
Count=19
Count=20
Count=21
Count=22
Count=23
Count=24
Count=25
Count=26
Count=27
Count=28
Count=29
Count=30
Count=31
Count=32
Count=33
Count=34
Count=35
Count=36
Count=37
Count=38
Count=39
Count=40
Count=41
Count=42
Count=43
Count=44
Count=45
Count=46
Count=47
Count=48
Count=49
Count=50
Count=51
Count=52
Count=53
Count=54
Count=55
Count=56
Count=57
Count=58
Count=59
Count=60
Count=61
Count=62
Count=63
Count=64
Count=65
Count=66
Count=67
Count=68
Count=69
Count=70
Count=71
Count=72
Count=73
Count=74
Count=75
Count=76

 ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x40100000, len 28780, room 16
tail 12
chksum 0xae
ho 0 tail 12 room 4
load 0x3ffe8000, len 1548, room 12
tail 0
chksum 0x9d
load 0x3ffe8610, len 3016, room 8
tail 0
chksum 0x72
csum 0x72
r?
..
Connected to @HomeCA72
IP address: 192.168.1.102
MDNS responder started
HTTP server started


and the situation repeats itself