Weekly Scheduling with Arduino UNO

Weekly Scheduling with Arduino UNO © LGPL

Human habits are usually different between weekdays and weekend. Therefore, smart devices should be able to switch their task based on this.

  • 4,234 views
  • 0 comments
  • 28 respects

Components and supplies

About this project

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

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

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

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.

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

4. Run the code below

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

Note that you can do much with Arduino when combined with a PHPoC shield because this shield has many powerful features such as IPv4/IPv6, TCP/UDP, SSL, ESMTP, etc.

For more information, visit http://www.phpoc.com/phpoc_shield_for_arduino.php and http://www.phpoc.com/support/manual/phpoc_shield_for_arduino

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

Code

Source CodeArduino
#include <SPI.h>
#include <Phpoc.h>

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
}

Comments

Similar projects you might like

Gmail & Arduino UNO & IPv6

by phpoc_man

  • 2,395 views
  • 0 comments
  • 14 respects

Simple Arduino Uno - ESP 8266 Integration

Project tutorial by circuito.io team

  • 93,137 views
  • 23 comments
  • 75 respects

Arduino UNO Mini-Weather Station

Project tutorial by Igor Fonseca Albuquerque

  • 25,837 views
  • 21 comments
  • 67 respects
Add projectSign up / Login