-->
Page 1 of 1

problema con nodemcu interrupciones y obtener datos firebase

PostPosted: Tue Jul 09, 2019 1:33 pm
by Esdras4757
I have problems with a project that detects the zero crossing of a sine wave this is done with the use of interrupts but at the same time you get firebase data, the program works indefinitely and then stops working

I hope someone can help me I have been looking for a solution for days and I can not find


code:

////////////////////////////BRIG//////////////////////////////////////////////////77
uint8_t GPIO_Pin = D1;
int AC_OUT = D5; // Output to Opto Triac
int AC_VALUE = 60; // AC OUT VALUE (0 - 100) *0 = ON BULB; 100 = OFF BULB
// * THESE VALUES ARE UNTESTED, YOU MUST PLAY AROUND WITH THEM) *

int sensorValue = 0;
int value = 0;
int delayTime;

///////////////////////////////////////////////////////////////////////////////

#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>

// Set these to run example.
#define FIREBASE_HOST "smarthome-36935.firebaseio.com"
#define FIREBASE_AUTH "mjIg4GMu4aTD7b7fWz12sEMBsIINbkJHMQitun6e"
#define WIFI_SSID "oscar"
#define WIFI_PASSWORD "LALL16281202"
#define ICACHE_RAM_ATTR

void setup() {
//Serial.begin(115200);

////////////////////////////////////////////////////////////////////////////////77

pinMode(GPIO_Pin, INPUT_PULLUP);

pinMode(AC_OUT, OUTPUT); // Set the light control pin as output


/////////////////////////////////////////////////////////////////////////////////////

// connect to wifi.
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
// Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
// Serial.print(".");
delay(500);
}
// Serial.println();
//Serial.print("connected: ");
//Serial.println(WiFi.localIP());

Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
pinMode(D5,OUTPUT);
delay(1000);

attachInterrupt(digitalPinToInterrupt(GPIO_Pin), ICACHE_RAM_ATTR setAC, RISING);
}
void loop() {
int a= map(Firebase.getFloat("washer/Brightness/brightness"),100,0,10,100);
delayTime = (81*a);
value=delayTime;
}
//////////////////////////////////////////////////////////////////////////
void ICACHE_RAM_ATTR setAC() // function to be fired at the zero crossing to dim the light
{

delayMicroseconds(value); // delay the dim time
digitalWrite(AC_OUT, HIGH); // fire the Triac
delayMicroseconds(55); // pause briefly to ensure the triac turned on
digitalWrite(AC_OUT, LOW); // turn off the Triac gate (triac will not turn off until next zero cross)
}



////////////////////////////////////////////////////////////////////////////