ESP8266 fixe IP in STA-Mode

Gast #5153990
Lesenswert?

Hallo Forum!

Ich versuche gerade einen ESP8266 mit meinem WLAN zu verbinden. Die 
Verbindung ist kein Problem, dauert ca 3sec und bekommt vom DHCP eine 
IP.

Nun möchte ich dem ESP eine fixe IP geben, das funktioniert nicht.
Sobald ich WiFi.config aktiv stelle, bekomme ich keine Verbindung mehr.
Ich programmiere mit der Arduino SDK -->

const char* ssid = "AP_Privat";

const char* password = "privat2017";

void setup(void){
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
 //WiFi.config(IPAddress(10,0,0,234), IPAddress(10,0,0,1), 
IPAddress(255,255,255,0), IPAddress(10,0,0,1));

Serial.println(WiFi.localIP());
}

Warum?
Danke!
Gast #5153998
Lesenswert?

Im SDK-Manual steht z.B.

"To set static IP, please disable DHCP first"

"Example"
1
wifi_set_opmode(STATIONAP_MODE);  //Set  softAP  +  station  mode
2
struct  ip_info  info;
3
wifi_station_dhcpc_stop();
4
wifi_softap_dhcps_stop();
5

6
IP4_ADDR(&info.ip,  192,  168,  3,  200);
7
IP4_ADDR(&info.gw,  192,  168,  3,  1);
8
IP4_ADDR(&info.netmask,  255,  255,  255,  0);
9
wifi_set_ip_info(STATION_IF,  &info);
10

11
IP4_ADDR(&info.ip,  10,  10,  10,  1);
12
IP4_ADDR(&info.gw,  10,  10,  10,  1);
13
IP4_ADDR(&info.netmask,  255,  255,  255,  0);
14
wifi_set_ip_info(SOFTAP_IF,  &info);
15

16
wifi_softap_dhcps_start();

Die Beispiele sind zwar öfters etwas obskur, helfen aber meist. Weiß 
aber nicht, wie das mit dem Arduino-Geraffel ist und was das im 
Hintergrund alles macht oder nicht macht...

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren