AC Dimmer control using google assistance and alexa to with the help of IFTTT

Dear, Sir that time I didn’t know how to put symbols and % sing in what’ do you want say blocks , but for now I know how to put symbols in blocks

If We use defferent value we need more applet but according to this process we can mange all in one in one applet

So my hearty request to you sir,

Could you help me to complete this way,

As I said earlier…

Either way, your Blynk code is expecting values between 0 and 1023, so unless you say “1023 percent” then you either have to change the data in IFTTT before it’s sent, or adjust your Blynk code and remove the re-mapping of the incoming values.

Pete.

1 Like

Thankyou so much #Peteknigh sir, Project successfully completed , working perfectly, as my needs

Lots of love from India

Hello Sir,

In the below esp32 light dimmer code how can i save the slider Value of blynk virtual pin V0 even after esp32 reboot. Because after reboot my ac light start flickering until i change the slider position in blynk app.
i want to save the dimmer state using eeprom plz guide me in this regards.

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <RBDdimmer.h>           // header file for robodyn dimmer

char auth[] = "xxxxxxxxx";   

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

#define outputPin  D26  // PWM pin for dimmer
#define zerocross  D25 // for boards with CHANGEBLE input pins

dimmerLamp dimmer(outputPin, zerocross); //initialase port for dimmer for ESP8266, ESP32, Arduino due boards

int outVal = 0; // Intialisation value for dimmer
int dim_val; // dimmer value to dim the appliance

void setup()
{
  Serial.begin(9600); // begin serial communication
  dimmer.begin(NORMAL_MODE, ON); //dimmer initialisation: name.begin(MODE, STATE)

  Blynk.begin(auth, ssid, pass); // begin blynk server
}

void loop()
{
  Blynk.run(); // Run blynk server
}

BLYNK_WRITE(V0)  {  // Set to your virtual pin  
  outVal = param.asInt(); // Get State of Virtual Button
  dim_val = map(outVal, 0, 100, 0, 100); // mapped the value for dimmer
  dimmer.setPower(dim_val);               // Set dimmer power
  Blynk.virtualWrite(V1, dim_val); //sending to Blynk
} ```

Read the “ Synchronising the output state with the app at startup” section of this post…

Pete.

Sir The code above works perfectly.
But problem is that when esp32 restart due to power issue. The dimmer light should be on with same condition.

i.e

if outval is 50 using blynk app V0 ping
then after reboot must be 50

i want to store the outval using eeprom

You do t need to save to EEPROM (which is outdated anyway, you should be UI sh SPIFFS or LittleFS anyway), you simply need to get Blynk to send you the latest value from the slider on startup.

Pete.

Sir,
How to use SPIFFS to store the state of blynk outval.

Google is your friend!

Pete.

Just put this line in void loop and enjoy

dimmer.setPower(50)

When you restart or power will on your dimmr will start at 50% :wink:

Thanks me later :slightly_smiling_face:

Well, putting that in the void loop would mean that the brightness would be reset to 50% every time the void loop was processed (which is hundreds of time per second) so you’d lose all control of the dimmer from the app.

Putting it into void setup would be a more sensible approach, but again somewhat flawed. You may not want a light to turn on at 50% brightness whenever the MCU chooses to reboot, and this could be annoying in some situations, such as a light in a bedroom which would suddenly go to 50% brightness in the middle of the night. It could also result in considerable unwanted energy usage if the ESP32 starts while you’re away and goes undetected for some time. As there is no synchronisation to reflect the 50% setting back to the app, checking the app would not alert the user to the issue.

As the sketch uses the blocking Blynk.begin command, the light would turn on to 50% brightness and remain there until a WiFi connection is established and then a connection to the Blynk server is established. If this is impossible then the light would be on at 50% brightness permanently, until this issue is resolved. Given that the Blynk cloud servers used for Blynk 0.1 (which this sketch uses) will be decommissioned fairly soon (maybe as early as 5-6 months time), it will soon be impossible to contact the Blynk server and the light will be stuck at 50% brightness permanently.

I suspect that @Rizwan_Saeed’s desire to store the last brightness setting in NVR is because he thinks that this will give some additional usability in offline mode, but the use of the blocking Blynk.begin function makes it unlikely that this will work as anticipated, although it depends on how its implemented.

The symptom of

would be solved by my BLYNK_CONNECTED / Blynk.syncVirtual solution.

If he’s trying to solve a different or additional issue then explaining that in detail would be a good starting point.

Pete.

Thanks Pete and Yogendraj for suggestion,

The first issue is that my dimmer light bulb start flickering when the MCU is reboot unless i change the value from blynk, If i use this line
dimmer.setPower(50)
then as Pete Sir said this could be annoying in some situations, such as a light in a bedroom which would suddenly go to 50% brightness in the middle of the night
First i want to stop dimmer light flickering when MCU reboot before BLYNK_CONNECTED / Blynk.syncVirtual.

Can we store its state using writing EEPROM/SPIFFS memory and after reboot restore state using reading EEPROM/SPIFFS memory.

TBH, the period between boot-up and BLYNK_CONNECTED executing isn’t that long.

I think you should be more concerned about converting the project to Blynk 2.0 than anything else.

Pete.

Sir Blynk older version will also keep working or will it stop after sometime.

Pete.

Thanks Pete for the info.

Hi Rizwan_Saeed, so have you tried this project on new blynk version ?

Today I am trying this project on new blynk app 2.0 /esp32/

And I am facing same issue dimming value doesn’t work or we can say our map doesn’t work right now

Hi Yogendraj,

I haven’t started working on blynk new version yet. If i do i will update.

1 Like

Ok see you soon buddy

Finally I completed this project with new blynk app 2.0

4 channel relaye ON/OFF
1 Fan Speed using Rbdimeer

We can control this project using mobile app, web desk and manual control with live feedback

Yes you are thinking right we can control Rbdimeer using manual push button, up and down in 5 steps completely off and completely 100%

And best part of this synchronise with slider.

Ahhh, waiting for alexa and Google without having third party