it happens with this code:
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <OneWire.h>
#define boiler 14
#define OnLed 4
#define systemLED 5
void buttonLedWidget();
void Temperature();
void LEDtoggle();
void OnTime();
void countTime();
int minutse = 0;
unsigned long minTime = 0;
unsigned long work2 = 0;
unsigned long nowTime = 0;
float ESP201ADCVref=1.10;
unsigned long count = 0;
unsigned int myConnectionTimeout = 5000; // Connection Timeout (CT)
unsigned int blynkcheckInterval = 60000; // Check Server Frequency (CSF)
unsigned long mytimeout = 3000; // 3.0s timeout
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
WidgetLED led1(0);
WidgetLED led5(3);
//WidgetLED led4(16);
SimpleTimer timer;
OneWire ds(2); // on pin 2 between VCC&DATA (a 4.7K resistor is necessary)
const int btnPin = 17;
WidgetLED led3(V3);
bool dudon = false;
bool dune = true;
bool manual = false;
bool Connected2Blynk = false;
int work = 0;
char auth[] = "1e0fc8aa350c47e88bbb078dc1f6302a";
char server[] = "blynk-cloud.com";
char ssid[] = "Nir&Rotem";
char pass[] = "11335577";
//************ Menu widget *************
//
BLYNK_WRITE(V1)
{
int getTime = 0;
switch (param.asInt())
{
case 1: // Item 1
Serial.println("off");
getTime = 0;
break;
case 2: // Item 1
Serial.println("30 minuts");
getTime = 30;
break;
case 3: // Item 2
Serial.println("45 minuts");
getTime = 45;
break;
case 4: // Item 3
Serial.println("60 minuts");
getTime = 60;
break;
case 5: // Item 4
Serial.println("75 minuts");
getTime = 75;
break;
case 6: // Item 5
Serial.println("90 minuts");
getTime = 90;
break;
case 7: // Item 6
Serial.println("120 minuts");
getTime = 120;
break;
default:
Serial.println("off");
getTime = 0 ;
}
work = getTime;
// OnTime();
}
void setup()
{
Serial.begin(115200);
Blynk.connectWiFi(ssid, pass);
Blynk.config(auth,server);
checkBlynk();
// Blynk.begin("1e0fc8aa350c47e88bbb078dc1f6302a", "LEDANI_2.4", "0522941258");
// Blynk.begin("1e0fc8aa350c47e88bbb078dc1f6302a", "Nir&Rotem", "11335577");
// Blynk.begin("5a2d531baafa4c16855dfac4cbbc1275", "NIR", "11335577");
// Blynk.begin("1e0fc8aa350c47e88bbb078dc1f6302a", "hereO", "kgpswifi");
// Blynk.begin("1e0fc8aa350c47e88bbb078dc1f6302a", "iPhone", "123456789");
// attachInterrupt(digitalPinToInterrupt(0), pushButtton, CHANGE);
pinMode(boiler, OUTPUT);
pinMode(OnLed, OUTPUT);
pinMode(systemLED, OUTPUT);
digitalWrite(OnLed,HIGH);
digitalWrite(systemLED,LOW);
digitalWrite(boiler,HIGH);
timer.setInterval(200L, pushButtton);
timer.setInterval(10000L,Temperature);
timer.setInterval(10000L,countTime);
timer.setInterval(10000L,OnTime);
timer.setInterval(10000L,sendTime);
timer.setInterval(60000L, CheckConnection); // check if still connected every 11 seconds
timer.setInterval(30000L, checkBlynk); // every 5s check if connected to server
// while (Blynk.connect()==false){}
Serial.println("start");
led1.on();
//led4.on();
led5.on();
Blynk.virtualWrite(V1, "pick", 0);
}
bool lastbutton = 0;
void loop()
{
if(Blynk.connected()) // only process Blynk commands if connected to server
{
Blynk.run();
}
timer.run();
}
int state = LOW; // the current state of the output pin
int reading; // the current reading from the input pin
int previous = LOW;
void pushButtton()
{
bool button = digitalRead(0);
Blynk_Delay(1);
bool button2 = digitalRead(0);
button = button && button2;
if(button && !lastbutton)
{
Serial.println("pressed");
if (state == HIGH)
{
state = LOW;
work = 130;
}
else
{
state = HIGH;
work = 0;
}
}
digitalWrite(V3, state);
lastbutton = button;
}
void Temperature()
{
Serial.println("Tempfunc");
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;
if ( !ds.search(addr)) {
//Serial.println("No more addresses.");
// Serial.println();
ds.reset_search();
delay(250);
return;
}
ds.reset();
ds.select(addr);
ds.write(0x44, 1); // start conversion, with parasite power on at the end
Blynk_Delay(1000);
// delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.
present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
for ( i = 0; i < 9; i++) // we need 9 bytes
{
data[i] = ds.read();
}
int16_t raw = (data[1] << 8) | data[0];
if (type_s)
{
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10)
{
// "count remain" gives full 12 bit resolution
raw = (raw & 0xFFF0) + 12 - data[6];
}
}
else
{
byte cfg = (data[4] & 0x60);
// at lower res, the low bits are undefined, so let's zero them
if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
//// default is 12 bit resolution, 750 ms conversion time
}
celsius = (float)raw / 16.0;
Serial.print("celsius: ");
Serial.println(celsius);
Blynk.virtualWrite(V5,celsius);
}
void OnTime()
{
unsigned long tout;
if((!dudon && dune) || work == 0 || (work == 130 && !dudon) )
{
work2 = work;
if(count < (work*6))
{
BoilerOn();
}
}
if((count >= (work*6)) && dudon)
{
Serial.println("tout");
BoilerOff();
}
Serial.print("work2: ");
Serial.println(work2);
if (dudon)
{
minTime = work2 - count/6;
Serial.print("minTime: ");
Serial.println((minTime));
nowTime = (count/6);
sendTime();
}
}
void sendTime()
{
unsigned long timeLeft = 0;
if(dudon &&((minTime > 0) && (work != 130))) timeLeft = (minTime);
if(minTime <= 0 )timeLeft = 0;
if(dudon && (minTime == 130))
{
Blynk.virtualWrite(V2,"ON");
Blynk.virtualWrite(V1, "pick", 0);
}
else Blynk.virtualWrite(V2,timeLeft);
if(dudon &&((nowTime > 0))) Blynk.virtualWrite(V4,nowTime);
else
{
nowTime = 0;
Blynk.virtualWrite(V4,nowTime);
}
Serial.print("timeLeft: ");
Serial.println(timeLeft);
Serial.print("nowTime: ");
Serial.println(nowTime);
}
void countTime()
{
if(dudon)
{
count++;
// Serial.print("countTime:");
// Serial.println(count);
}
else count = 0;
}
void BoilerOn()
{
digitalWrite(boiler,LOW);
digitalWrite(OnLed,LOW);
digitalWrite(systemLED,HIGH);
dudon = true;
count = 0;
Serial.println("dudon");
Blynk.notify("Boiler ON");
if(work == 130)Blynk.virtualWrite(V1, "pick", 0);
state = LOW;
}
void BoilerOff()
{
digitalWrite(boiler,HIGH);
digitalWrite(OnLed,HIGH);
digitalWrite(systemLED,LOW);
Serial.println("dudoff");
dudon = false;
Blynk.virtualWrite(V1, "pick", 0);
Blynk.notify("Boiler OFF");
state = HIGH;
work = 0;
work2 = 0;
minTime = 0;
}
void Blynk_Delay(int milli)
{
int end_time = millis() + milli;
while (millis() < end_time){ }
}
//void CheckConnection()
//{
// Connected2Blynk = Blynk.connected();
// if(!Connected2Blynk)
// {
// Serial.println("Not connected to Blynk server");
// MyWiFi();
//
// }
// else{
// Serial.println("Still connected to Blynk server");
// }
//}
//
//void MyWiFi()
//{
// int mytimeout = millis() / 1000;
// WiFi.begin(ssid, pass);
// while (WiFi.status() != WL_CONNECTED) {
// delay(500);
// Serial.print(".");
// if((millis() / 1000) > mytimeout + 20){ // try for less than 4 seconds to connect to WiFi router
// break;
// }
// }
//
// if(WiFi.status() == WL_CONNECTED){
// Serial.print("\nIP address: ");
// Serial.println(WiFi.localIP());
// }
// else{
// Serial.println("\nCheck Router ");
// }
// Blynk.config(auth);
// Connected2Blynk = Blynk.connect(2000); // 1000 is a timeout of 3333 milliseconds
// mytimeout = millis() / 1000;
// while (Blynk.connect() == false) {
// if((millis() / 1000) > (mytimeout + 12)){ // try for less than 4 seconds
// break;
// }
// }
//}
void CheckConnection() {
unsigned long startConnecting = millis();
while(!Blynk.connected()){
Blynk.connect();
if(millis() > startConnecting + myConnectionTimeout){
Serial.println("\tUnable to connect to server. ");
break;
}
}
Serial.print("\tChecking again in ");
Serial.print(blynkcheckInterval / 1000.0);
Serial.println("s.");
}
void checkBlynk()
{
Serial.println("checkBlynk");
if (WiFi.status() == WL_CONNECTED)
{
unsigned long startConnecting = millis();
while(!Blynk.connected()){
Blynk.connect(); //
if(millis() > startConnecting + mytimeout){
Serial.print("Unable to connect to server. ");
break;
}
}
}
if (WiFi.status() == 1) {
Serial.print("No WiFi. ");
}
Serial.println("Checking again in 5s.");
}
this is thee log:
Üø[294]Connecting to Nir&Rotem //stuck in here and not execute the sketch