Hi, again.
I still aim for a stable AC-dimmer using Blynk, but it seems a difficult way.
First I created a code as below, just for testing my hardware:
#include <ESP8266WiFi.h>
#include <Ticker.h>
// Interupt PIN = 12
// Dim PIN = 13
Ticker blinker;
volatile int dimTime;
int LED = 2;
volatile int dimVal = 20;
void ICACHE_RAM_ATTR onTimerISR()
{
digitalWrite(LED,!(digitalRead(LED))); //Toggle LED Pin
timer1_write(12800000);
dimVal = dimVal + 10;
if(dimVal > 130)
{
dimVal = 20;
}
}
// *******************************************************************************************
void setup()
{
Serial.begin(115200);
delay(10);
pinMode(13, OUTPUT); // Set AC Load pin as output
pinMode(2,OUTPUT);
timer1_attachInterrupt(onTimerISR);
timer1_enable(TIM_DIV16, TIM_EDGE, TIM_SINGLE);
timer1_write(12800000); //60000 = 120000 us
attachInterrupt(12, zero_crosss_int, RISING); // Choose the zero cross interrupt # from the table above
ESP.wdtDisable();
ESP.wdtEnable(WDTO_8S);
}
// *******************************************************************************************
void zero_crosss_int() //function to be fired at the zero crossing to dim the light
{
dimTime = (75*dimVal); // Value set for 50Hz
delayMicroseconds(dimTime); // Wait till firing the TRIAC
digitalWrite(13, HIGH); // Fire the TRIAC
delayMicroseconds(10); // triac On propogation delay
digitalWrite(13, LOW); // No longer trigger the TRIAC (the next zero crossing will swith it off) TRIAC
}
// *******************************************************************************************
void loop()
{
ESP.wdtFeed();
}
This code works stable for over two days.
Then I add BLYNK to control dimming in a new code as below:
#include <BlynkSimpleEsp8266.h>
char auth[] = " "; //
char ssid[] = " "; //
char pass[] = " "; //
int dimS;
volatile int dimVal = 20;
volatile int dimTime;
// *******************************************************************************************
void setup()
{
Serial.begin(115200);
delay(10);
pinMode(13, OUTPUT); // Set AC Load pin as output
Blynk.begin(auth, ssid, pass);
attachInterrupt(12, zero_crosss_int, RISING); // Choose the zero cross interrupt # from the table above
ESP.wdtDisable();
ESP.wdtEnable(WDTO_8S);
}
// *******************************************************************************************
void zero_crosss_int() //function to be fired at the zero crossing to dim the light
{
dimTime = (75*dimVal); // Value set for 50Hz
delayMicroseconds(dimTime); // Wait till firing the TRIAC
digitalWrite(13, HIGH); // Fire the TRIAC
delayMicroseconds(10); // triac On propogation delay
digitalWrite(13, LOW); // No longer trigger the TRIAC (the next zero crossing will swith it off) TRIAC
}
// *******************************************************************************************
void loop()
{
Blynk.run();
ESP.wdtFeed();
}
// *******************************************************************************************
BLYNK_WRITE(V1) // Slider
{
dimS = param.asInt();
dimVal = dimS;
}
Then troubles starts. ESP crash after 10-30 min. with error message as below:
// --------------------------------------------------------- ESP ERROR -------------------------------------------------------------
14:33:54.877 -> Exception (0):
14:33:54.877 -> epc1=0x4020210c epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
14:33:54.877 ->
14:33:54.877 -> ctx: sys
14:33:54.877 -> sp: 3ffffc30 end: 3fffffb0 offset: 01a0
14:33:54.877 ->
14:33:54.877 -> >>>stack>>>
14:33:54.877 -> 3ffffdd0: 40106b58 00000000 3ffeb986 000000f7
14:33:54.877 -> 3ffffde0: ffffffff 00000020 00000001 00000000
14:33:54.877 -> 3ffffdf0: 00000000 40100fab 00000000 00000022
14:33:54.877 -> 3ffffe00: 3fffc200 40106b20 3fffc258 4000050c
14:33:54.877 -> 3ffffe10: 4000437d 00000030 00000019 ffffffff
14:33:54.924 -> 3ffffe20: 60000200 00000008 ffffffff 80000000
14:33:54.924 -> 3ffffe30: 20000000 3fff1630 80000000 2007c100
14:33:54.924 -> 3ffffe40: 80000000 3fffc6fc 3ffee308 3fff1634
14:33:54.924 -> 3ffffe50: 000001f4 0007c100 60000600 00000030
14:33:54.924 -> 3ffffe60: 00000128 40103891 00040000 40202148
14:33:54.924 -> 3ffffe70: 40106bbc 00080000 00000000 40106ba6
14:33:54.924 -> 3ffffe80: ffffffff 00000020 00000000 4000050c
14:33:54.971 -> 3ffffe90: 00000000 00000000 0000001f 40105139
14:33:54.971 -> 3ffffea0: 4000050c 40106b20 3fffc258 4000050c
14:33:54.971 -> 3ffffeb0: 40000f68 00000030 0000001a ffffffff
14:33:54.971 -> 3ffffec0: 40000f58 00000000 00000020 00000000
14:33:54.971 -> 3ffffed0: 3fff04dc 40208f24 00000000 00000000
14:33:54.971 -> 3ffffee0: ffffffff 3ffe8f64 3ffee308 3fffdab0
14:33:54.971 -> 3ffffef0: 00000000 3fffdcb0 3ffee348 00000030
14:33:55.018 -> 3fffff00: 00000000 400042db 00000064 60000600
14:33:55.018 -> 3fffff10: 40004b31 3fff1534 000002f4 0007c000
14:33:55.018 -> 3fffff20: 4010569e 3ffee330 3ffed3d0 40107118
14:33:55.018 -> 3fffff30: 402089f5 3ffed3d0 3ffee330 1dfbe4e0
14:33:55.018 -> 3fffff40: 3fff1534 00001000 40208e8a 00000008
14:33:55.018 -> 3fffff50: 40105e5c 00000000 40208f37 3ffed484
14:33:55.018 -> 3fffff60: 3ffee330 08ea9ad5 3ffee330 60000600
14:33:55.065 -> 3fffff70: 4021a619 3ffed484 3ffee330 1dfbe24e
14:33:55.065 -> 3fffff80: 4021a65e 3fffdab0 00000000 3fffdcb0
14:33:55.065 -> 3fffff90: 3ffee350 00000000 40000f65 3fffdab0
14:33:55.065 -> 3fffffa0: 40000f49 0002f684 3fffdab0 40000f49
14:33:55.065 -> <<<stack<<<
14:33:55.111 -> ets Jan 8 2013,rst cause:2, boot mode:(1,7)
14:33:55.111 ->
14:34:02.939 -> ets Jan 8 2013,rst cause:4, boot mode:(1,7)
14:34:02.939 ->
14:34:02.939 -> wdt reset
I’m using an ESP-07 module.
Newest Arduino version.
Latest Blynk lib.
Hardware works 100%
Can anyone tell me what’s wrong when adding Blynk?