Before creating the topic
- Search forum for similar topics
- Check http://docs.blynk.cc and http://help.blynk.cc/
- Add details :
• Node MCU
• Smartphone ANDROID (6.0.1 MMB29M)
• Blynk server
• Blynk_Release_v0.4.4
• Add your sketch code. Code should be formatted as example below.
Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
This example runs directly on ESP8266 chip.
Note: This requires ESP8266 support package:
https://github.com/esp8266/Arduino
Please be sure to select the right ESP8266 module
in the Tools -> Board menu!
Change WiFi ssid, pass, and Blynk auth token to run :)
Feel free to apply it to any other example. It's simple!
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
int UP=0;
int DOWN=12;
int cutoff_temp=40;
int relay=14;
int MOD=16;
int SW=4;
int a,da,up,down,mod,sw;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "**************";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "****";
char pass[] = "********";
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(UP,INPUT);
pinMode(DOWN,INPUT);
pinMode(A0,INPUT);
pinMode(relay,OUTPUT);
pinMode(MOD,INPUT);
pinMode(SW,INPUT);
digitalWrite(UP,LOW);
digitalWrite(DOWN,LOW);
digitalWrite(MOD,LOW);
digitalWrite(SW,LOW);
digitalWrite(relay,LOW);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
mod=digitalRead(MOD);
if(mod==LOW)
{
mod=digitalRead(MOD);
a= analogRead(A0);
da= (a-574.8)/6.13;
up= digitalRead(UP);
down= digitalRead(DOWN);
Blynk.run();
auto_mode();
set_temp();
Blynk.virtualWrite(1,da);
Blynk.virtualWrite(2,cutoff_temp);
}
if(mod==LOW)
{
mod=digitalRead(MOD);
a= analogRead(A0);
da= (a-574.8)/6.13;
up= digitalRead(UP);
down= digitalRead(DOWN);
Blynk.run();
sw=digitalRead(SW);
manual_mode();
set_temp();
Blynk.virtualWrite(1,da);
Blynk.virtualWrite(2,cutoff_temp);
}
}
void auto_mode()
{
if(da>cutoff_temp)
{
digitalWrite(relay,HIGH);
WidgetLED led1(V3);
WidgetLED led2(V4);
led1.on();
led2.off();
}
else if(da<=cutoff_temp-5)
{
digitalWrite(relay,LOW);
WidgetLED led1(V3);
WidgetLED led2(V4);
led1.off();
led2.on();
}}
void manual_mode()
{
if(sw==HIGH)
{
digitalWrite(relay,HIGH);
WidgetLED led1(V3);
WidgetLED led2(V4);
led1.on();
led2.off();
}
//else if(sw==LOW)
// {
// digitalWrite(relay,LOW);
// WidgetLED led1(V3);
// WidgetLED led2(V4);
// led1.off();
// led2.on();
// }
else if(da>cutoff_temp)
{
digitalWrite(relay,LOW);
WidgetLED led1(V3);
WidgetLED led2(V4);
led1.off();
led2.on();
}
}
void set_temp()
{
up= digitalRead(UP);
down= digitalRead(DOWN);
if(up==HIGH)
{
cutoff_temp++;
}
else if(down==HIGH)
{
cutoff_temp--;
}
}