loading

Human usually go to work on weekday, and stay at home or go to other places on weekend. Therefore, smart devices should be able to switch their task basing on this human behavior. For examples, traffic light system should act differently between weekday and weekend. RFID-based door in workplace may need to be activated only on weekday.

In this article, I am going to show you how to switch Arduino Uno-based IoT device’s tasks basing on day of week.

Step 1: Components

- Arduino Uno

- PHPoC Shield for Arduino

PHPoC Shield not only provide the internet connection for IoT devices but also provide the real-time clock (RTC) which is useful for scheduling.

Step 2: All Steps

1. Stack PHPoC Shield on Arduino

2. Install Arduino library and examples for PHPoC Shield:

On Arduino IDE, Goto Sketch -> Include Library -> Manage Libraries. Type “PHPoC” on search box. Click on PHPoC row and click “Install” button.

Or you can get .zip file here: https://github.com/phpoc/arduino

3. Run the following code

#include
#include

enum day { FAILURE, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY }; enum day today;

void weekdayTask() { Serial.println("This is weekday task"); //TODO }

void weekendTask() { Serial.println("This is weekend task"); //TODO: }

PhpocDateTime datetime;

void setup() { Serial.begin(9600); while (!Serial) ;

Phpoc.begin();

Serial.println("Weekly Scheduling");

datetime.date("Y-m-d D H:i:s"); Serial.println(datetime.date()); }

void loop() { today = datetime.dayofWeek();

if (today == FAILURE) Serial.println("System Error!"); else if ( today >= MONDAY && today <= FRIDAY) weekdayTask(); //Program for weekday else weekendTask(); //Program for weekkend }

4. Modify two functions: weekdayTask() and weekendTask() according to your need.

Note that you can do much with Arduino when combining with PHPoC shield because this shield has many powerful features such as IPv4/IPv6, TCP/UDP, SSL, ESMTP… For more information, visit http://www.phpoc.com/phpoc_shield_for_arduino.php... and http://www.phpoc.com/phpoc_shield_for_arduino.php...

If you have any questions or something to discuss, don’t hesitate to leave a comment. I am glad to discuss with you.

About This Instructable

255views

13favorites

More by phpoc_man:Arduino uno, Weekly Scheduling Arduino Uno, Gmail Arduino, Monitoring Door-Opening Via Gmail 
Add instructable to: