can any 1 tell me what i did wrong for this advanced timer input for nodemcu module
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
BLYNK_WRITE(V1) {
TimeInputParam t(param);
// Process start time
if (t.hasStartTime())
{
Serial.println(String("Start: ") +
t.getStartHour() + ":" +
t.getStartMinute() + ":" +
t.getStartSecond());
}
else if (t.isStartSunrise())
{
Serial.println("Start at sunrise");
}
else if (t.isStartSunset())
{
Serial.println("Start at sunset");
}
else
{
// Do nothing
}
// Process stop time
if (t.hasStopTime())
{
Serial.println(String("Stop: ") +
t.getStopHour() + ":" +
t.getStopMinute() + ":" +
t.getStopSecond());
}
else if (t.isStopSunrise())
{
Serial.println("Stop at sunrise");
}
else if (t.isStopSunset())
{
Serial.println("Stop at sunset");
}
else
{
// Do nothing: no stop time was set
}
// Process timezone
// Timezone is already added to start/stop time
Serial.println(String("Time zone: ") + t.getTZ());
// Get timezone offset (in seconds)
Serial.println(String("Time zone offset: ") + t.getTZ_Offset());
// Process weekdays (1. Mon, 2. Tue, 3. Wed, ...)
for (int i = 1; i <= 7; i++) {
if (t.isWeekdaySelected(i)) {
Serial.println(String("Day ") + i + " is selected");
}
}
Serial.println();
if (param.asInt() == 1) {
digitalWrite(2, HIGH);
}
else {
digitalWrite(2, LOW);
}
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(2, OUTPUT);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
}
void loop()
{
Blynk.run();
}
It shows error compiling for board nodemcu 1.0(esp-12e module).I think I would have missed some header file…I don’t know where the error is but it shows error compiling for board nodemcu 1.0(esp-12e module).
now,after combining both BLYNK_WRITE(V1) ,there is no error …see,i have edited my code in the first post.
i was not able to control my desired pin in the nodemcu using blynk timer,there no output at the pin even after the start time,but when to tried to switch on the pin by button it is working,can any 1 help me??
Whatever it is you are trying to do… you appear to be misunderstanding how Blynk works. You seem have everything crammed into a single Blynk function that runs whenever you press a button.
I suggest you start with some of that basic Examples Sketches and first learn the basics.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
BLYNK_WRITE(V1) {
TimeInputParam t(param);
// Process start time
if (t.hasStartTime())
{
Serial.println(String("Start: ") +
t.getStartHour() + ":" +
t.getStartMinute() + ":" +
t.getStartSecond());
}
else if (t.isStartSunrise())
{
Serial.println("Start at sunrise");
}
else if (t.isStartSunset())
{
Serial.println("Start at sunset");
}
else
{
// Do nothing
}
// Process stop time
if (t.hasStopTime())
{
Serial.println(String("Stop: ") +
t.getStopHour() + ":" +
t.getStopMinute() + ":" +
t.getStopSecond());
}
else if (t.isStopSunrise())
{
Serial.println("Stop at sunrise");
}
else if (t.isStopSunset())
{
Serial.println("Stop at sunset");
}
else
{
// Do nothing: no stop time was set
}
// Process timezone
// Timezone is already added to start/stop time
Serial.println(String("Time zone: ") + t.getTZ());
// Get timezone offset (in seconds)
Serial.println(String("Time zone offset: ") + t.getTZ_Offset());
// Process weekdays (1. Mon, 2. Tue, 3. Wed, ...)
for (int i = 1; i <= 7; i++) {
if (t.isWeekdaySelected(i)) {
Serial.println(String("Day ") + i + " is selected");
}
}
Serial.println();
}
BLYNK_WRITE(V1)
{
if (param.asInt() == 1) {
digitalWrite(2, HIGH);
}
else {
digitalWrite(2, LOW);
}
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(2, OUTPUT);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
}
void loop()
{
Blynk.run();
}
Arduino: 1.8.5 (Windows 8.1), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"
In file included from C:\Users\bpkma_000\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkApi.h:18:0,
from C:\Users\bpkma_000\Documents\Arduino\libraries\Blynk\src/BlynkApiArduino.h:14,
from C:\Users\bpkma_000\Documents\Arduino\libraries\Blynk\src/BlynkSimpleEsp8266.h:18,
from C:\Users\bpkma_000\Documents\Arduino\timer6\timer6.ino:30:
C:\Users\bpkma_000\Documents\Arduino\timer6\timer6.ino: In function 'void BlynkWidgetWrite1(BlynkReq&, const BlynkParam&)':
C:\Users\bpkma_000\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkHandlers.h:152:10: error: redefinition of 'void BlynkWidgetWrite1(BlynkReq&, const BlynkParam&)'
void BlynkWidgetWrite ## pin (BlynkReq BLYNK_UNUSED &request, const BlynkParam BLYNK_UNUSED ¶m)
^
C:\Users\bpkma_000\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkHandlers.h:160:31: note: in expansion of macro 'BLYNK_WRITE_2'
#define BLYNK_WRITE(pin) BLYNK_WRITE_2(pin)
^
C:\Users\bpkma_000\Documents\Arduino\timer6\timer6.ino:119:1: note: in expansion of macro 'BLYNK_WRITE'
BLYNK_WRITE(V1)
^
C:\Users\bpkma_000\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkHandlers.h:152:10: error: 'void BlynkWidgetWrite1(BlynkReq&, const BlynkParam&)' previously defined here
void BlynkWidgetWrite ## pin (BlynkReq BLYNK_UNUSED &request, const BlynkParam BLYNK_UNUSED ¶m)
^
C:\Users\bpkma_000\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkHandlers.h:160:31: note: in expansion of macro 'BLYNK_WRITE_2'
#define BLYNK_WRITE(pin) BLYNK_WRITE_2(pin)
^
C:\Users\bpkma_000\Documents\Arduino\timer6\timer6.ino:41:1: note: in expansion of macro 'BLYNK_WRITE'
BLYNK_WRITE(V1) {
^
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.