WiFiManager

no connection.
blynk does not see the token.
how to send a token correctly?

First of all, probably not a good idea to post your Auth code online. You may want to pull a new one.

Are you calling Blynk.connectWiFi(SSID,PASSWORD) after Blynk.config()?

but, connection with WIFI is installed! This was done by WIFImanager.

when I write manually: Blynk.config (“8b43d5 … d0c940992c3b”); everything is working!

Can you supply details please…

What hardware, what server (Local or Cloud), connecting using a router, hotspot, carrier pigeon, etc.

Can you clarify… what do you mean ‘manually’

Paste (not screenshot) your whole code here (block out any auth codes, passwords, etc… otherwise we are just guessing.

Format after pasting, as per requirements for proper viewing:

Blynk - FTFC

   char blynk_token[34] = "YOUR_BLYNK_TOKEN";
  
  //clean FS, for testing
  //SPIFFS.format();

  //read configuration from FS json
  Serial.println("mounting FS...");

  if (SPIFFS.begin()) {
    Serial.println("mounted file system");
    if (SPIFFS.exists("/config.json")) {
      //file exists, reading and loading
      Serial.println("reading config file");
      File configFile = SPIFFS.open("/config.json", "r");
      if (configFile) {
        Serial.println("opened config file");
        size_t size = configFile.size();
        // Allocate a buffer to store contents of the file.
        std::unique_ptr<char[]> buf(new char[size]);

        configFile.readBytes(buf.get(), size);
        DynamicJsonBuffer jsonBuffer;
        JsonObject& json = jsonBuffer.parseObject(buf.get());
        json.printTo(Serial);
        if (json.success()) {
          Serial.println("\nparsed json");

          strcpy(blynk_token, json["blynk_token"]);
          
  
          

        } else {
          Serial.println("failed to load json config");
        }
      }
    }
  } else {
    Serial.println("failed to mount FS");
  }
  //end read



  // The extra parameters to be configured (can be either global or just in the setup)
  // After connecting, parameter.getValue() will get you the configured value
  // id/name placeholder/prompt default length
   WiFiManagerParameter custom_blynk_token("blynk", "blynk token", blynk_token, 34);

  //WiFiManager
  //Local intialization. Once its business is done, there is no need to keep it around
  WiFiManager wifiManager;

  //set config save notify callback
  wifiManager.setSaveConfigCallback(saveConfigCallback);

  //set static ip
  //wifiManager.setSTAStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
  
  //add all your parameters here
  wifiManager.addParameter(&custom_blynk_token);

  //reset settings - for testing
  wifiManager.resetSettings();

  //set minimu quality of signal so it ignores AP's under that quality
  //defaults to 8%
  wifiManager.setMinimumSignalQuality(30);
  
  //sets timeout until configuration portal gets turned off
  //useful to make it all retry or go to sleep
  //in seconds
  wifiManager.setTimeout(120);

  //fetches ssid and pass and tries to connect
  //if it does not connect it starts an access point with the specified name
  //here  "AutoConnectAP"
  //and goes into a blocking loop awaiting configuration
  if (!wifiManager.autoConnect("AutoConnectAP", "password")) {
    Serial.println("failed to connect and hit timeout");
    delay(3000);
    //reset and try again, or maybe put it to deep sleep
    ESP.reset();
    delay(5000);
  }

  //if you get here you have connected to the WiFi
  Serial.println("connected...yeey :)");

  //read updated parameters
  strcpy(blynk_token, custom_blynk_token.getValue());

  //save the custom parameters to FS
  if (shouldSaveConfig) {
    Serial.println("saving config");
    DynamicJsonBuffer jsonBuffer;
    JsonObject& json = jsonBuffer.createObject();
    json["blynk_token"] = blynk_token;
    
    
    File configFile = SPIFFS.open("/config.json", "w");
    if (!configFile) {
      Serial.println("failed to open config file for writing");
    }

    json.printTo(Serial);
    json.printTo(configFile);
    configFile.close();
    //end save
  }

  Serial.println("local ip");
  Serial.println(WiFi.localIP());
  
//Blynk.config(blynk_token); // not connects to Blynk
  Blynk.config("8b43d57472c4....................92c3b"); //connects to Blynk
  
  //Serial.println(blynk_token);

the value of the variable blynk_token checked

Still missing relevant code (showing libraries, defines, etc…), and you haven’t answered any of the other questions…

Have you tried loading and connecting with a sketch that is perhaps just a wee little bit simpler first? :wink:

/**************************************************************

 Connection:
 DHT22: VCC-5v, OUT-D3;
 BH1750: VCC-3.3v, SCL-D1, SDA-D2;
 RELE: Heater-D6, Light-D7;
 Status connection Blynk (LED)-D5;

 *************************************************************/
// Comment this out to disable prints and save space
//#define BLYNK_PRINT Serial 

#include <FS.h>                   //this needs to be first, or it all crashes and burns...
#include <SPI.h>
#include "DHT.h"
#include <BH1750.h>
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>
#include <ArduinoJson.h> 
#include <BlynkSimpleEsp8266.h>
#include "settings.h"


/////////////////////////////////////////////////////////

bool statusButtLight, statusButtHeater = false;
bool statusRelayLight, statusRelayHeater = false;
bool statusTimerLight, statusThermostat  = false; 
bool timerOn,thermostatOn = false;
int setTemperature;
float t, h; 
unsigned int lux;
bool connectBlynk = false;

DHT dht(DHTPIN, DHTTYPE);
BH1750 lightMeter;
BlynkTimer timer;

//flag for saving data
bool shouldSaveConfig = false;

//callback notifying us of the need to save config
void saveConfigCallback () {
  Serial.println("Should save config");
  shouldSaveConfig = true;
}

//Send data to the server Blynk
void SendData(int pinV, float currentData){
  float oldData;
    if (!currentData)
	Serial.println("Failed to read from DHT sensor!");
    else {
  		if (currentData != oldData){
  		Blynk.virtualWrite(pinV, currentData);
  		oldData = currentData;
  		}
   }
}
void SendData(int pinV, unsigned int currentData){
  float oldData;
    if (!currentData)
	Serial.println("Failed to read from BH1750 sensor!");
    else {
  		if (currentData != oldData){
  		Blynk.virtualWrite(pinV, currentData);
  		oldData = currentData;
  		}
   }
}

//SimpleTimer
void Timer(){
  h = dht.readHumidity();
  SendData(V2, h);
  t = dht.readTemperature();
  SendData(V3, t);
  lux = lightMeter.readLightLevel();
  SendData(V4, lux);
  connectBlynk = Blynk.connected();
  if (connectBlynk) digitalWrite(pinConnect, HIGH);
  else digitalWrite(pinConnect, LOW);
 }

void setup() {
  Serial.begin(115200);
  Serial.println();
  #include "autoConnect.h"
  //Blynk.begin(auth, ssid, pass);
  //Blynk.config(auth);
  //Serial.println("hhhhhhhhhhhhhhhhhhhhhh");
  
  
  
  //Serial.println(auth);
    
  pinMode(pinRelayLight, OUTPUT);
  pinMode(pinRelayHeater, OUTPUT);
  pinMode(pinConnect, OUTPUT);
  Blynk.syncAll();
  dht.begin();
  lightMeter.begin();
  timer.setInterval(interval, Timer);	
}

// Function on/off widget
void onOffWidget (int buttonV, int widgetV, bool statusWidget, bool statusRelay){
    if(statusWidget){
    Blynk.setProperty(buttonV, "color", "#191D1E");//off
    Blynk.setProperty(widgetV, "color", "#21C48D");//on
    }
  else {
    Blynk.setProperty(widgetV, "color", "#191D1E");
    Blynk.setProperty(buttonV, "color", "#21C48D");
    Blynk.virtualWrite(buttonV, statusRelay);//sync batton
    }
}

// Function on/off relay
bool onOffRelay(int numberPin, bool statusWidget, int ledPin){
  digitalWrite(numberPin, statusWidget);
  WidgetLED led(ledPin);
  bool statusRelay;
    if(statusWidget)  {
      led.on();
      statusRelay=HIGH;
    }
    else {
      led.off();
      statusRelay=LOW;
    }
  return statusRelay;
}

// Function on/off thermostat
 bool OnOffThermostat(){
  if (t<setTemperature) {
    statusThermostat = HIGH;
    }
  else {
    statusThermostat = LOW;
    }
  if((thermostatOn) && (statusThermostat != statusRelayHeater)){
    statusRelayHeater = onOffRelay(pinRelayHeater, statusThermostat, V11);
    }
  }

// Automatic button timer (on/off) 
BLYNK_WRITE(V6)
{
  timerOn = param.asInt();
  onOffWidget (V5, V7, timerOn, statusRelayLight);
  }
  
// Manual button light
BLYNK_WRITE(V5) 
{
  statusButtLight = param.asInt();
  if((!timerOn) && (statusButtLight != statusRelayLight)){
    statusRelayLight = onOffRelay(pinRelayLight, statusButtLight, V1);
  }
 }

// Timer light 
BLYNK_WRITE(V7)
{
  statusTimerLight = param.asInt();
  if((timerOn) && (statusTimerLight != statusRelayLight)){
    statusRelayLight = onOffRelay(pinRelayLight, statusTimerLight, V1);
  }
 }

// Manual button heater
BLYNK_WRITE(V8) 
{
  statusButtHeater = param.asInt();
  if((!thermostatOn) && (statusButtHeater != statusRelayHeater)){
    statusRelayHeater = onOffRelay(pinRelayHeater, statusButtHeater, V11);
  }
}

// Automatic button thermostat (on/off) 
BLYNK_WRITE(V9)
{
  thermostatOn = param.asInt();
  onOffWidget (V8, V10, thermostatOn, statusRelayHeater);
  }
  
// Widget set temperature thermostat
BLYNK_WRITE(V10)
{
  setTemperature = param.asInt();
  }

void loop() {
  Blynk.run();
  timer.run(); // Initiates SimpleTimer
  OnOffThermostat();

}

I don’t have a ton of experience with Blynk but I believe you need to reorder/change some of your Blynk commands that are commented out.

In setup:

Blynk.config(auth);
Blynk.connect(); -your right that you shouldn’t need WiFi credentials here with wifimanager
Blynk.syncAll();

In Loop:
Blynk.run();

Thank you! problem solved.
WiFiManagerParameter custom_blynk_token(“blynk”, “blynk token”, blynk_token, 32);
replaced by
WiFiManagerParameter custom_blynk_token(“blynk”, “blynk token”, blynk_token, 33);
although taken from the library

I was going to mention the null termination of the string as I have posted about it before but when I checked your code for the bug I saw:

Should have been big enough.