Using a Feather Huzzah. Having some problems with my garage door sensor bypass.
Basically, I have a 6.5ms low, and then a .5 ms high.
It works for several seconds, and then it “flickers” on my scope. I think it is resetting every few seconds, but I’m not sure why.
Can someone point me in the right direction?
Code is as follows
/*
* Simple HTTP get webclient test
*/
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
const char* ssid = "***SSID***";
const char* pass = "***PASS***";
char auth[] = "***AUTH***";
int interval = 7;
int count;
unsigned long previousMillis;
unsigned long currentMillis;
int pin = 16;
void setup() {
Serial.begin(115200);
delay(100);
pinMode(pin, OUTPUT);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
Blynk.begin(auth, ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop()
{
Blynk.run();
// You can inject your own code or combine it with other sketches.
// Check other examples on how to communicate with Blynk. Remember
// to avoid delay() function!
//Handle the time keeping
previousMillis = currentMillis; //Set new “old time”
currentMillis = millis(); // Update current time
count += (currentMillis - previousMillis);
//Check to see if you need to run the pulse high
if(count > interval)
{
digitalWrite(pin, HIGH);
delayMicroseconds(500);
digitalWrite(pin, LOW);
delayMicroseconds(500);
count -= interval;
}
else { }
}
Not sure what you are referring to here… assuming use of an oscilloscope??
But my experience with delayMicroseconds() and Blynk, is that there is probably some shared timer conflict or something that can cause erratic behavior when using delayMicroseconds() for longer periods of time… such as in the void loop()
No solution was found, except to stop using them and switch to BlynkTimer whenever I could.
500 microseconds = 0.5ms, but as BlynkTimer has only 1ms resolution, you have a point…
Thus I would recomend useing BlynkTimer to call a function that ran the microsecond delays only as long as required, with a breakout if it looked like it was taking too long, then move on with the rest of the main loop.
I did something like that with an ultrasonic sensor that would cause issues if ran in “normal” Arduino code fashion
Yeah, I built the timer in there using the system clock, so it doesn’t have to run for the 6.5ms delay the original sketch did.
I didn’t think the 500 microseconds would cause a problem, and the blynktimer only does ms delay.
I suppose I could see if I can use 6ms and 1ms for the opener, but I doubt it will work.