Will the timers work with the hazzah 8266 and the blynk example stand alone sketch.
It should work. What is your problem?
I set the timer and it times out but I never get an output from the hazzah, I can use the buttons and they work perfect on any output but the timers never do.
@ghack68695 what Smartphone do you have and is the time accurate on the phone?
How are you testing the Timer?
Thank you for the quick response :
Im am using a samsung note 4 on sprint, and I have the automatic date and time checked in the time setting and I have checked the internet time vs my phone and it is correct, as for testing I select digital pin # 2 which is the blue led on the hazzah, set the timer and when it times out the led never comes on.
Please add a button to control the blue on board LED and see if that works. Then paste your sketch here.
or maybe first paste your sketch:P
Okay tried with button on blue led and it worked fine.here is the code I have.
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "690043f52a7f4dd7bb828d6191acd9f6";
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, "2WIRE1", "81351321");
}
void loop()
{
Blynk.run();
}
@ghack68695 your sketch is fine. Tested it on a WeMos D1 Mini with is effectively a Huzzah clone at half the price.
Both devices have 10K pullup resistors on GPIO 2 so the builtin LED will be on until the Timer sends a HIGH (ON) signal and then back on when the Timer sends a LOW (OFF) signal.
Okay I guess the problem is on my end, I will try a different 8266 and see if that helps , any other ideas I could try ??
Thank you
If you have other ESP8266’s you can try them but it is very rare for there to be a problem with an ESP even when you feed it the wrong voltage. Very occasionally widgets fail to register with the Blynk server so you could try removing the Timer and add it a second time.
Shouldn’t you set appropriate Pins as output?
@conkerkh it is good practise to set the pinMode but I believe they default to output and it certainly works on the WeMos (Huzzah clone) without.
Well in normal world you have to do this. Considering it’s just one line of code in Arduino IDE I wouldn’t bother to much and just add it for sake of clearness of the code and being sure that everything works as it should. In uC world you don’t take something for granted you just make sure sth works as you expect. Btw Here is sample code that configures GPIOs on normal uC:
__GPIOA_CLK_ENABLE();
/*Configure GPIO pins : PAPin PAPin */
GPIO_InitStruct.Pin = USART_TX_Pin|USART_RX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
And this is easy way…
BTW, Pins default to input not output in the esp8266 Arduino source.
@conkerkh I think you will find ESP’s are used in the ‘normal world’.
Actually the pins initialise as INPUT and don’t specifically require pinMode but it does make the sketch clearer if you use it.
pinMode is required when using the pins as OUTPUT but Blynk also appears to take care of it if you assign the pin to a Widget.
@ghack68695 just to clarify with the sketch as you have it (for pins with PULLUP resistors) the LED should be ON when you restart the Huzzah, OFF from the start to the end of the Timer period and then ON when the Timer period ends. If you tie the timer to a virtual pin you can reverse the HIGH / LOW on a PULLUP pin to make it more logical (LED is ON when Timer is ON).
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "xxxxxxxxxxxxx";
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, "xxxxxxxxxx", "xxxxxxxxxxx");
pinMode(2, OUTPUT);
digitalWrite(2, HIGH); // BUILTIN LED is active LOW, so will be off when you restart the Huzzah
}
BLYNK_WRITE(V1) {
if (param.asInt()==0)
digitalWrite(2, HIGH);
else
digitalWrite(2, LOW); // when Timer sends HIGH signal (1) BUILTIN LED will be ON
}
void loop()
{
Blynk.run();
}
Man first of all I pointed out that pins are initialised as INPUT, second I know that ESP8266 is used in normal world I use it and I love it one of the best SOCs in my opinion.
But what I mean and what I pointed precisely is that: in order to use any Pin you should set pinMode to something. GPIO configuration on every uC is necessary prior using the GPIO in desired way period. Just because some function abstracts something from you doesn’t mean it’s not set.
Please teach people good coding practice when you help them because it later helps a lot.
Strangest thing after a week of trying to get my timers to work I set one today and it is working, actually all the GPIO pins work, not sure what happened but I’m glad its fixed.
Okay guess I spoke to soon , I set up everything the way I wanted for my home automation and now none or timers will work again, I really like the blynk app and the concept and the timers should be simple to setup and use but to many issues for me, guess I’ll go back to using my PLC for my project.