-->
Page 1 of 1

Noob Networking Issues

PostPosted: Tue Nov 22, 2016 6:33 pm
by gavspav
I have three Esp8266 connecting to a Belkin router in Station Mode.
The router isn't connected to the internet - the network is just for sketch uploading and control messages via udp.
I'm having issues though and not sure how to debug either.
I have assigned static ip addresses to the boards, mainly to rule out conflicts but also so I know which is which.

Basically sometimes one or all of the boards loses connection to the wifi and if I cycle the power to it it won't reconnect to the network. The only way to sort it out is to cycle the power to the router.

I'm imagining (guessing) this is something to do with DHCP. The lease time is set to 'forever' on the router. The smallest time period is half an hour.

My code is largely taken from the Basic OTA arduino sketch. (see below)

I know I haven't given you alot to go on but I'm not really sure what is happening. Has anyone got any ideas for a method to get to the bottom of this? Or anything I'm missing?

Edit***I know that the static ip should override dhcp but I was wondering if perhaps the router was either saving the ip address after initial connection, perhaps because it didn't know the connection had been lost. Guesswork again!

Code: Select all#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

WiFiUDP port;
char packetBuffer[255];
unsigned int localPort = 9999;

// config static IP
IPAddress ip(192, 168, 42, 23); // where xx is the desired IP Address
IPAddress gateway(192, 168, 42, 254); // set gateway to match your network
IPAddress subnet(255, 255, 255, 0); // set subnet mask to match your network

const char* ssid = "lalalala";
const char* password = "notrealobvs";

//this bit is in setup
  WiFi.mode(WIFI_STA);
  WiFi.config(ip, gateway, subnet);
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! No Network...");
    delay(5000);
    //ESP.restart(); I commented this out cos I want the code to run if the network doesn't exist
    break;


Re: Noob Networking Issues

PostPosted: Tue Nov 29, 2016 12:30 pm
by mrburnette
Edit***I know that the static ip should override dhcp but I was wondering if perhaps the router was either saving the ip address after initial connection, perhaps because it didn't know the connection had been lost.


Static DHCP on the router will honor a client DHCP request but will verify the static table before assigning. If the MAC is found in the table for a client's MAC requesting DHCP, then the router will return the previously stored TCP/IP address for the LAN.

Personally, I would work through this scenario since static DHCP is not the best way of doing client identification. If you step on one of your client devices and it smashes, the replacement unit will have a different MAC. Bummer ... off to that HTML configuration page.



Ray