Chat freely about anything...

User avatar
By piontec
#7135 Hi,
I was trying to develop a simple temperature and humidity logger using esp8266 and dht22. Everything went smoothly, I had a version which worked for over 2 weeks and logged everything nicely, going into deep sleep between readings. Than, I started to add new features and suddenly my esp stopped connecting to the wi-fi network. As far as I can tell, radio is working, but IP address is not requested from the DHCP server. I thought, that maybe my binary is to big or something like that - anyway, I got back to the source version, which was working OK for me. And the problem didn't stop! No matter what software version I flash (I even tried other firmwares), my ESP is starting (I can see DBG messages from my init function, but never connects to the INternet. The actual log is
Code: Select alladd if0
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
add if1
bcn 100
scandone
add 0
aid 2
pm open phy_2,type:2 0 0
cnt
DBG: reset counter 0/1
DBG: reset counter 0/2
Continuing normal boot
starting config mode
TCP config server init, conn=0x3ffea018
rm match
pm close 7 0 0/4240083
reconnect
scandone
add 0
aid 2
pm open phy_2,type:2 0 0
cnt
rm match
pm close 7 0 0/4007647
reconnect
...

and so on. What can be wrong? Any ideas? How can I debug this further? How do you cope with error handling at all?

Thanks for any help.
User avatar
By Athena
#7153 How about this :
void wifi_config()
{
// Wifi configuration
char ssid[32] = SSID;
char password[64] = PASSWORD;
struct station_config stationConf;

//Set station mode
wifi_set_opmode( 0x1 );

stationConf.bssid_set = 0;

//Set ap settings
os_memcpy(&stationConf.ssid, ssid, 32);
os_memcpy(&stationConf.password, password, 64);
wifi_station_set_config(&stationConf);

}

//Init function
void user_init()
{
wifi_config();
}
User avatar
By piontec
#8751 Hi guys,
Thanks for your support. But...

Both of your hints are useful, the thing with
Code: Select allstationConf.bssid_set = 0;

maybe even more so, as it is really required to be cleared.
But, I added that line in my code, flashed it - and it didn't help. OK, so I used the second hint, flashed default settings, and - unfortunately - changed something in my code or something else I'm not sure about - and it worked. At least, for some time, because suddenly yesterday the same bug occurred. This time I got
Code: Select allstationConf.bssid_set = 0;

in my code, I flashed default settings and nothing helps - esp is connecting to my wifi, but there is no line showing what IP address it got - it seems again as it is not getting the IP from DHCP server (which works perfect for all other devices in the network).
Here's the code I'm developing:
https://github.com/piontec/esp_rest/blob/master/user/config.c
please have a look at lines 56 (processWifiSet()) and 123 (processRestart()).
The output I'm getting is:
Code: Select allSoftware version: 0.1, config version: 1
mode : sta(18:fe:34:9e:5e:d5)
add if0
scandone
DBG: reset counter 0/1
DBG: reset counter 0/2
Starting normal mode
DBG: DHT22 ready
DBG: Timer ready
Initialization complete, starting main task
add 0
aid 1
pm open phy_2,type:2 0 0
cnt
rm match
pm close 7 0 0/4108959
DBG: sensors enabled
DBG: DHT read done
DBG: Temp = 32.20 *C, Hum = 34.09 %
 DBG: TCP connecting...
reconnect
scandone
add 0
aid 1
pm open phy_2,type:2 0 0
cnt
rm match
pm close 7 0 0/4036757
reconnect
scandone
add 0
aid 1
pm open phy_2,type:2 0 0
cnt
rm match
pm close 7 0 0/4042822
reconnect
scandone
add 0
aid 1
pm open phy_2,type:2 0 0
cnt
rm match
pm close 7 0 0/4074041
reconnect
scandone


Any help please?