Chat freely about anything...

User avatar
By SentinelAeon
#88487 A very strange problem ...

So, i am currently running 3 ESP8266 wemos d1 boards, each controling its own system. They do certain tasks and also run a server so i can access their data through wifi. All worked great for almost a year.

Yesterday i was playing around with wifi settings to see if i can improve transfer between phone and computer over the home network. So i changed a few settings, wasn't happy with them so i did a hard reset of the modem/router, reseting to ISPs defaults, which appear to be what i had to begin with, when i got the modem/router.

What confuses me is that i suddenly cannot access the ESP8266 servers anymore. The code is simply so i have no idea what could cause this. Also what is really funny is ... i can suddenly see all 3 ESP8266 boards on my mobile phone as access points - i can actualy connect to them. I dont know if that was like this before but i never noticed it.

Here is the code, not sure it has anything to do with the situation though since its been working for a year.

Code: Select allvoid connectToWifi() {

  Serial.begin(9600);
 
  WiFi.begin("SSID", "PASSWORD");

  for(int i=0;i<30;i++) {

     if(WiFi.status() == WL_CONNECTED) break;
     delay(30);
   
  }
   
  server.on("/", handleRootPath);
  server.on("/data.html", handleRootPath);     
  server.begin();
  IPAddress ip(192,168,64,51);   
  IPAddress gateway(192,168,64,1);   
  IPAddress subnet(255,255,255,0);   
  WiFi.config(ip, gateway, subnet); 
     
}


Let me again state that this worked for a year. I tried different channels. What is strange though is that right now my router/modem is on channel 6, while those ESP8266's are on channel 1, at least that is what the wifi analyzer on my phone shows me. I tried changing router/modem to channel 1, does't make any difference.

I left the ESP8266's turned off over the night, same with router/modem - made no difference. The only other thing i can note is .. i tried changing the wifi bandwidth on modem/router. The problem is, i cant remember what the default value was. It gives me options auto, 20 or 40. Right now it is set to 20 and even if i change it to auto or 40, it still remains on 20.
User avatar
By SentinelAeon
#88493 Just to let everyone know and maybe help someone ...

My SSID has 9A1EF4 in its name. And in all 3 ESP8266 boards, i set it as such. But it seems that the default SSID of modem/router actualy has 9a1ef4 in it, that is, small letters. I checked the documentation from ISP and there are small letters also.

Sadly i cannot remember what the SSID was when i got the router/modem, was it small or big letters. It IS possible that during the time of usage of modem/router, i tried to set some custom SSID and then wrote back the default one and used big letters instead of small ones. I remember once setting the custom SSID and i remember ESPs obviously wouldnt connect so i said i wont bother changing their code and just set it back to default. But that would mean i set it to the same one i got ...

So it is possible that the router/modem that i got had big letters in them, but the default software on modem/router was with big letters.

Anyway, at least now i know SSID is case sensitive, i wasn't sure before. And another thing i learned ... if in your code of ESP8266 you write a SSID that doesn't exist, then the ESP8266 will just make its own wifi network. I was able to connect to it with my mobile phone. So i was wondering, could i somehow use this to my advantage ? So i could connect to ESP8266 directly over wifi without needing to use the microusb cable to connect ?
User avatar
By SentinelAeon
#88529 I will play around with that.

Btw ... i am working on another project using esp8266 wemos d1 and using arduino IDE. And i am working with strings and printing them on server. It has been a while since i used c language doing any serious work, probably about 6 years ago in college.

Anyway, i am working with string and i remember from those c lessons that it was a hassle with strings in c, wasn't as simple as in java for instance. So i went browsing a bit how i could optimise my code and found some esp8266 pages or rather arduino pages with some very clean code. Alright so i went around and implemented it, so i did something like this:



Code: Select allString myString =



    "Temperature1: " +

        String(sensor1_temperature) + "C" +

        "\nHumidity 1: " +

        String(sensor1_humidity) +  "%";


Do you see where i am going with this ? Only after i wrote it i realised that this certanly isn't pure c. C as i remember it, simply does not have the ability to concat strings using + sign. And that String() method for converting ints and floats into strings, i dont remember that either. I completely forgot about it but, isn't it along the lines that arduino ide actualy uses some custom c that is friendlier ? Google returns that it supports c and c++, but that it also has custom rules. Would anyone care to elaborate a bit on that ? I would love to know what i am actualy using. I can't belive i was able to make a few not so small projects without even knowing what exactly i am using, the programming language that is.