ESP8266 and WiFi Manager

Hello Blynker,

I am very happy because there is this community with you and give advices and help :slight_smile:

I would like to know if you can help me with this because i am new in the programming and i know little things…

I use this code esp8266 ds18b20 · GitHub ,
and I would like to add the WiFiManager so that to add ssid,pass,auth from my phone (connect esp WiFi → 198.168.4.1 → ssid,pass,auth) without change in my code and then If i want to reset the wifi,pass,auth to I press “rst” button on my esp8266 to delete only ssid,pass and auth token. I had try to do this a lot of times without result :confused:
Thank you a lot for your time :slight_smile:

Well, to begin with, the code you’re starting with is awful. It breaks all the rules of Blynk.

You should read this and implement a Blynktimer and remove your delay,

You should also set your Blynktimer up so that it takes temperature readings at a sensible frequency - say every 5 to 10 seconds.

Once you’ve done that, I’d suggest that you then try to add-in the WiFiManager code yourself, and share the results that you are getting. That way, you’re much more likely to get help.

It’s also better if you post your code, and your serial monitor output, directly to the forum rather than linking to your GitHub page.
Code and serial output should be posted with triple backticks at the beginning and end.
Triple backticks look like this (copy and paste them if needed)…
```
Code posted without triple backticks will be deleted.

Pete.

ok thanks you very match… I wil do all of this and then i post again :slightly_smiling_face:

Hello Blynkers,
I have this code with wifimanager and I would like from you if you want to and some think in code so that to I can add and auth token such as ssid and pass from the IP (192.168.4.1). I am new in this world and I try my best to develop this code but this, with auth token its complicated. Thanks you a lot for your time

[Unformatted code removed by moderator]

Please format your code properly with triple BACKTICKS on a separate line or copy these. ```

@apo8ira7 I’ve merged your two topics on the same subject into one, and as promised I’ve deleted your unformatted code, because despite me giving you triple backticks to copy/paste you used different characters instead.

Pete.

sorry!! i used triple BACKTICKS but the first lines of my code dont changed :confused: I will try to post it again

and this is the resault sorry blynkers :slightly_frowning_face: :slightly_frowning_face: :slightly_frowning_face:

[Unformatted code removed by moderator]

@apo8ira7 do you know what copy and paste means, and how to do it?
If not, then maybe you should learn how to do that before getting into programming.

Pete.

Sorry Pete, I did copy paste… ‘’’ code ‘’’

But you used different characters instead of triple backticks, which doesn’t work.
I gave you some examples triple backticks, and suggested several times that you should copy and paste them if you’re struggling to find this character on your keyboard - but you don’t seem happy to take that advice.

Pete.

Sorry Pete you have right :slightly_smiling_face: I find it … Also i have add blynk timer which you say it and thanks toy very much for this now tho blynk work normaly

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_PRINT Serial

#include <WiFiManager.h> 
#include <Ticker.h>
Ticker ticker;

#ifndef LED_BUILTIN
#define LED_BUILTIN 13 
#endif

int LED = LED_BUILTIN;

/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#include<DallasTemperature.h> 
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
BlynkTimer timer;

float temp0;
float temp1;
float temp2;
unsigned long lst_milis = 0;

BLYNK_CONNECTED()  //sygxronizei to esp otan bgei apo to reuma stis leitoyrgies poy eixe stamatisi
{
 Blynk.syncAll();
}



void tick()
{
  //toggle state
  digitalWrite(LED, !digitalRead(LED));     // set pin to the opposite state
}

void configModeCallback (WiFiManager *myWiFiManager) {
  Serial.println("Entered config mode");
  Serial.println(WiFi.softAPIP());
  Serial.println(myWiFiManager->getConfigPortalSSID());
  ticker.attach(0.2, tick);
}

void setup() {
  WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
  // put your setup code here, to run once:
   Serial.begin(115200);
   
   DS18B20.begin();
   timer.setInterval(2000L,getSendData);
  
  Serial.begin(115200);
  pinMode(LED, OUTPUT);
  ticker.attach(0.6, tick);   // start ticker with 0.5 because we start in AP mode and try to connect
  WiFiManager wm;  
  //wm.resetSettings();  //reset settings - for testing
  wm.setAPCallback(configModeCallback);
  
  if (!wm.autoConnect()) {
    Serial.println("failed to connect and hit timeout");
    ESP.restart();
    delay(1000);
  }

  Serial.println("connected...yeey :)");
  ticker.detach();
  //keep LED on
  digitalWrite(LED, LOW);
}

void loop() 
{
      getSendData();
    Blynk.run();
    delay(10); //for stability

}

/***************************************************
 * Send Sensor data to Blynk
 **************************************************/
 
void getSendData()
{
  DS18B20.requestTemperatures(); 
  temp0 = DS18B20.getTempCByIndex(0); // Sensor 1 will capture Temp in Celcius
  temp1 = DS18B20.getTempCByIndex(1); // Sensor 2 will capture Temp in Celcius
  temp2 = DS18B20.getTempCByIndex(2); // Sensor 3 will capture Temp in Celcius
  
  Blynk.virtualWrite(1, temp0); //virtual pin V1
  Blynk.virtualWrite(2, temp1); //virtual pin V2
  Blynk.virtualWrite(3, temp2); //virtual pin V3
} ```

You’ve ignored this advice and gone for every 2 seconds instead…

and ignored this advice…

You’ve also left the code in the loop which calls getSendData() every time the void loop executes, instead of allowing BlynkTimer to call getSendData().

and, you’re missing timer.run(); in your void loop, so the BlynkTimer is never being serviced.

You’re also missing lots of WiFiManager code from your sketch.

Pete.