arduino-esp32 icon indicating copy to clipboard operation
arduino-esp32 copied to clipboard

DNS gets corrupted after a short time

Open gskjold opened this issue 1 year ago • 41 comments

Board

Custom board with ESP32-S2 mini

Device Description

Custom board (https://amsleser.no) for reading smart meters

Hardware Configuration

GPIO10 = Voltage divider GPIO13 = LED GPIO14 = LED GPIO16 = Serial RX

The following GPIO have been grounded to improve GND routing: 11, 12, 21, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46

Version

v2.0.9

IDE Name

PlatformIO

Operating System

Linux (Ubuntu)

Flash frequency

40MHz

PSRAM enabled

yes

Upload speed

460800

Description

It connects to the WiFi and has the correct IP for a little while. In my case it changes from 192.168.28.1 to 32.1.70.66 within 10 minutes of starting the code, but from what I hear from users of the project where this was brought to my attention, it seems like the time varies (https://github.com/UtilitechAS/amsreader-firmware)

This could be related to network configuration, but I am out of ideas on how to debug this.

Sketch

https://github.com/gskjold/esp32-wifi-problem


#include <WiFi.h>
#define SSID "SSID"
#define PSK "PSK"
unsigned long lastSysout = 0;

void setup() {
	Serial.begin(115200);
	Serial.setDebugOutput(true);
	WiFi.mode(WIFI_STA);
	WiFi.begin(SSID, PSK);
}
void loop() {
	unsigned long now = millis();
	if(now-lastSysout > 30000) {
		IPAddress dns1 = WiFi.dnsIP(0);
		Serial.printf("DNS: %s\n", dns1.toString().c_str());
		lastSysout = now;
	}
	yield();
}


### Debug Message

```plain
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0x11c
load:0x4004c000,len:0xa28
load:0x40050000,len:0x2740
entry 0x4004c174
[   519][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 0 - WIFI_READY
[   558][V][WiFiGeneric.cpp:340] _arduino_event_cb(): STA Started
[   559][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 2 - STA_START
[   561][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
[   634][V][WiFiGeneric.cpp:355] _arduino_event_cb(): STA Connected: SSID: no23-mob, BSSID: 82:ac:b9:61:3f:7c, Channel: 1, Auth: WPA2_PSK
[   635][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
[   658][V][WiFiGeneric.cpp:369] _arduino_event_cb(): STA Got New IP:192.168.28.100
[   659][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[   662][D][WiFiGeneric.cpp:1098] _eventCallback(): STA IP: 192.168.28.100, MASK: 255.255.255.0, GW: 192.168.28.1
DNS: 192.168.28.1
DNS: 192.168.28.1
DNS: 192.168.28.1
DNS: 192.168.28.1
DNS: 192.168.28.1
DNS: 192.168.28.1
DNS: 192.168.28.1
DNS: 32.1.70.66
DNS: 32.1.70.66
DNS: 32.1.70.66
DNS: 32.1.70.66
DNS: 32.1.70.66
DNS: 32.1.70.66
DNS: 32.1.70.66

Other Steps to Reproduce

Insert your SSID and PSK in the code, boot and wait at least 10min (maybe more)

I have checked existing issues, online documentation and the Troubleshooting Guide

  • [X] I confirm I have checked existing issues, online documentation and Troubleshooting guide.

gskjold avatar May 17 '23 17:05 gskjold