Hello All
I found this sketch in the sketch builder i am trying to configure it to work with relay output but no luck.
I know how to get a virtual pin to activate a digital output but in this example i failed.
can anyone tell me how to do it here on V1 ?
thanks.
/ *************************************************************
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Blynk community: http://community.blynk.cc
Social networks: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
App project setup:
Time Input widget on V1.
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
#define W5100_CS 10
#define SDCARD_CS 4
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();
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
Blynk.begin(auth);
// You can also specify server:
//Blynk.begin(auth, "blynk-cloud.com", 8442);
//Blynk.begin(auth, IPAddress(192,168,1,100), 8442);
}
void loop()
{
Blynk.run();
}
BLYNK_WRITE(Vx) // Runs every-time switch widget is toggled.
{
switchState = param.asInt(); // Get switch value.
if (switchState == HIGH) {
digitalWrite(digitalPin, HIGH); // set digital pin HIGH
} else {
digitalWrite(digitalPin, LOW); // set digital pin LOW
}
}
@Ze_Pico you will need to locate an Arduino sunrise / sunset library or API for Blynk Webhook to actually control anything at sunset / sunrise. TimeInput widget simply checks if you have selected the option in the app, no more, no less.
So the process is:
Was sunrise / sunset selected in the app?
If yes, is it sunrise / sunset time now (from library / API) then take some action.
@Costas here is the serial print for V1 from the sketch
[5001] Connecting to 192.168.0.139
[5282] Ready (ping: 12ms).
Start at sunset
Stop at sunrise
Time zone: Europe/Paris
Time zone offset: 3600
Day 1 is selected
Day 2 is selected
Day 3 is selected
Day 4 is selected
Day 5 is selected
Day 6 is selected
Day 7 is selected
@Ze_Pico look through this thread for sketches that actually control hardware with Time Input.
Watch for Blynk days being different to regular time library days and look up the library hack to set TimeInput as “off” when no days are selected.
The links are still not hightlighted in Chrome or on Smartphones but at least when Blynkers see the http://… it gives a strong indication that there is something to click on.
Nice to see the SKETCH BUILDER link at the top of each forum page.