[GH-ISSUE #491] wifiManager.setSTAStaticIPConfig sink telegram connection #410

Closed
opened 2026-02-28 01:25:10 +03:00 by kerem · 2 comments
Owner

Originally created by @plcabgut on GitHub (Jan 24, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/491

hello
when i use wifimanager with static ip in this way

IPAddress ip (192, 168, 1, 59);
IPAddress gateway(192, 168, 1, 1);
IPAddress mask (255, 255, 255, 0);

wifiManager.setSTAStaticIPConfig(ip, gateway, mask);

The esp8266 nodemcu with static ip don't receives nothing from telegram using the universaltelegrambot library.
If I let wifimanager in dhcp mode then it works fine and receives every command from telelegram.
There might be an interaction between them I guess.
After several days trying diferents configurations i've found that with this instruction everything go wrong. it lost the connection.
I think that could be because of the secure client. but I'm not sure.
The instruction wifiManager.setSTAStaticIPConfig(ip, gateway, mask); works great indeed because it put the ip statically right but then the other library doesnt works properly


#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h> //https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot

//WIFIMANAGER
#include <DNSServer.h>            //Local DNS Server used for redirecting all rs to the configuration portal
#include <ESP8266WebServer.h>     //Local WebServer used to serve the configuration portal
#include <WiFiManager.h>          //https://github.com/tzapu/WiFiManager WiFi Configuration Magic

#define BOT_TOKEN_LENGTH 46
char BOTtoken[BOT_TOKEN_LENGTH] =  "----MYTOKEN----";  

WiFiClientSecure client_secure;
UniversalTelegramBot *bot;

int Bot_mtbs = 1000; //mean time between scan messages
long Bot_lasttime;   //last time messages' scan has been done


IPAddress ip     (192, 168,   1, 59);
IPAddress gateway(192, 168,   1,  1);
IPAddress mask   (255, 255, 255,  0);

void handleNewMessages(int numNewMessages) {
  for (int i = 0; i < numNewMessages; i++) {
    String chat_id = String(bot->messages[i].chat_id);
    String text_bot=bot->messages[i].text.substring(1,bot->messages[i].text.length());
    if (text_bot.equals("X")) {
      bot->sendMessage(chat_id, "X", "");
    }
    if (text_bot.equals("Y")) {
      bot->sendMessage(chat_id, "Y", "");
    }

    if (text_bot.equals("start") || text_bot.equals("help")) {
      String help= "/X \n";
      help+= "/Y";
      bot->sendMessage(chat_id, help, "");
    }
  }
}

void setup() {
  Serial.begin(115200);
  WiFiManager wifiManager;

 //IF I COMMENT NEXT LINE IT WORKS FINE OTHERWISE DON'T RECEIVES NOTHING
  wifiManager.setSTAStaticIPConfig(ip, gateway, mask);

  wifiManager.autoConnect("AP_door", "pwd");
  if (WiFi.status() == WL_CONNECTED) {
    bot = new UniversalTelegramBot(BOTtoken, client_secure);
    Serial.println("WiFi connected");
    Serial.print(WiFi.localIP());
    Serial.println("/");
  } 
}

void loop() {
  if (millis() > Bot_lasttime + Bot_mtbs)  {
    int numNewMessages = bot->getUpdates(bot->last_message_received + 1);
    while(numNewMessages) {
      Serial.println("got response");
      handleNewMessages(numNewMessages);
      numNewMessages = bot->getUpdates(bot->last_message_received + 1);
    }
    Bot_lasttime = millis();
  }
}
Originally created by @plcabgut on GitHub (Jan 24, 2018). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/491 hello when i use wifimanager with static ip in this way IPAddress ip (192, 168, 1, 59); IPAddress gateway(192, 168, 1, 1); IPAddress mask (255, 255, 255, 0); > wifiManager.setSTAStaticIPConfig(ip, gateway, mask); The esp8266 nodemcu with static ip don't receives nothing from telegram using the universaltelegrambot library. If I let wifimanager in _dhcp_ mode then it works fine and receives every command from telelegram. There might be an interaction between them I guess. After several days trying diferents configurations i've found that with this instruction everything go wrong. it lost the connection. I think that could be because of the secure client. but I'm not sure. The instruction _wifiManager.setSTAStaticIPConfig(ip, gateway, mask);_ works great indeed because it put the ip statically right but then the other library doesnt works properly ``` #include <ESP8266WiFi.h> #include <WiFiClientSecure.h> #include <UniversalTelegramBot.h> //https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot //WIFIMANAGER #include <DNSServer.h> //Local DNS Server used for redirecting all rs to the configuration portal #include <ESP8266WebServer.h> //Local WebServer used to serve the configuration portal #include <WiFiManager.h> //https://github.com/tzapu/WiFiManager WiFi Configuration Magic #define BOT_TOKEN_LENGTH 46 char BOTtoken[BOT_TOKEN_LENGTH] = "----MYTOKEN----"; WiFiClientSecure client_secure; UniversalTelegramBot *bot; int Bot_mtbs = 1000; //mean time between scan messages long Bot_lasttime; //last time messages' scan has been done IPAddress ip (192, 168, 1, 59); IPAddress gateway(192, 168, 1, 1); IPAddress mask (255, 255, 255, 0); void handleNewMessages(int numNewMessages) { for (int i = 0; i < numNewMessages; i++) { String chat_id = String(bot->messages[i].chat_id); String text_bot=bot->messages[i].text.substring(1,bot->messages[i].text.length()); if (text_bot.equals("X")) { bot->sendMessage(chat_id, "X", ""); } if (text_bot.equals("Y")) { bot->sendMessage(chat_id, "Y", ""); } if (text_bot.equals("start") || text_bot.equals("help")) { String help= "/X \n"; help+= "/Y"; bot->sendMessage(chat_id, help, ""); } } } void setup() { Serial.begin(115200); WiFiManager wifiManager; //IF I COMMENT NEXT LINE IT WORKS FINE OTHERWISE DON'T RECEIVES NOTHING wifiManager.setSTAStaticIPConfig(ip, gateway, mask); wifiManager.autoConnect("AP_door", "pwd"); if (WiFi.status() == WL_CONNECTED) { bot = new UniversalTelegramBot(BOTtoken, client_secure); Serial.println("WiFi connected"); Serial.print(WiFi.localIP()); Serial.println("/"); } } void loop() { if (millis() > Bot_lasttime + Bot_mtbs) { int numNewMessages = bot->getUpdates(bot->last_message_received + 1); while(numNewMessages) { Serial.println("got response"); handleNewMessages(numNewMessages); numNewMessages = bot->getUpdates(bot->last_message_received + 1); } Bot_lasttime = millis(); } } ```
kerem closed this issue 2026-02-28 01:25:10 +03:00
Author
Owner

@evbelda commented on GitHub (Apr 12, 2018):

Please, can you tell me why this issue is closed? There are any other thread solved about it?
I'm detecting same problem with WifiManager 0.12 and UniversalTelegrambot 1.1.0 and static IP

<!-- gh-comment-id:380775314 --> @evbelda commented on GitHub (Apr 12, 2018): Please, can you tell me why this issue is closed? There are any other thread solved about it? I'm detecting same problem with WifiManager 0.12 and UniversalTelegrambot 1.1.0 and static IP
Author
Owner

@tablatronix commented on GitHub (Apr 12, 2018):

Because there is no information about which esp lib or attempt to remove wifimanager and test with a basic esp static example. Also there is now a development branch to test against

<!-- gh-comment-id:380779136 --> @tablatronix commented on GitHub (Apr 12, 2018): Because there is no information about which esp lib or attempt to remove wifimanager and test with a basic esp static example. Also there is now a development branch to test against
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#410
No description provided.