1

There are a lot of AC Fan dimmer codes are available in internet with zero cross detection and runs by Blynk app as well.

Problem is All those are only controllable by wifi (with internet) , rather have no manual control (without internet) at all.

I share a code below for AC fan dimmer which is runs by blynk app (Board NodeMCU) . It is only runs when wifi is available, i.e it has no manual contro. I am trying to improve/modify the same code by adding two physical push buttons to control Fan speed manually when internet is not available. In this case I am unable to modify the codes for these two push buttons which also capable to increase and decrease the fan speed along with the Blynk app slider button. Can anyone help/Guide me to develop this.

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

#define triacPulse 4 //D2
#define ZVC 12 //D6

int Slider_Value;
int dimming;
int x = 0;

char auth[] = "AUTH TOKEN";        // You should get Auth Token in the Blynk App.


char ssid[] = "SSID";         // Your WiFi credentials.
char pass[] = "PASS";    // Set password to "" for open networks.


BLYNK_WRITE(V1)   // function to assign value to variable Slider_Value whenever slider changes position
{
  Slider_Value = param.asInt(); // assigning incoming value from pin V1 to a variable
}


void setup()
{

  pinMode(ZVC, INPUT_PULLUP);
  //digitalWrite(2, INPUT_PULLUP); // pull up
  pinMode(triacPulse, OUTPUT);
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  attachInterrupt(digitalPinToInterrupt(ZVC), acon, FALLING); // attach Interrupt at PIN2
}



void loop()
{
  Blynk.run();
  // When the switch is closed
  dimming = map(Slider_Value, 0, 100, 7200, 200); 

}

void acon()
{
  // Serial.println("REad");

  delayMicroseconds(dimming); // read AD0
  digitalWrite(triacPulse, HIGH);

  delayMicroseconds(50);  //delay 50 uSec on output pulse to turn on triac
  digitalWrite(triacPulse, LOW);

  // Serial.println(digitalRead(triacPulse));
}
  • this is a Q&A site so you will not get guidance here – Juraj Dec 26 '20 at 06:41
  • you can set the state of a Blynk widget with Blynk.virtualWrite http://docs.blynk.cc/#blynk-main-operations-virtual-pins you have to do it in a blynk handler. – Juraj Dec 26 '20 at 06:43

0 Answers0