element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Home Automation
  • Challenges & Projects
  • Project14
  • Home Automation
  • More
  • Cancel
Home Automation
Blog Smart Clock over Cloud
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Home Automation to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fyaocn
  • Date Created: 13 Mar 2019 4:19 AM Date Created
  • Views 2048 views
  • Likes 12 likes
  • Comments 5 comments
  • homeautomationch
  • arduino_iot_cloud
  • mkr_1000
  • p14 mkr 1000
  • iotcloudch
Related
Recommended

Smart Clock over Cloud

fyaocn
fyaocn
13 Mar 2019

1、 Introduction

Normal clock runs with internal oscillation and the alarm shall be manually set. While the basic function of smart home shall be connected with the internet and reveal more information.

This smart clock has no push buttons, all the information is got from internet. The SNTP for time synchronization,  Sensor data from thingspeak channels can all be show in LCD panel of the smart clock.

This smart clock is information hub, it fetches information and send command to home automation.

 

2. Hardware

2.1 MKR1000

2.2 LCD1602 panel

2.3 LED lights

2.4 Arduino Creator Cloud

2.5 thingspeak API for publishing data and SNTP time service

3. Program Flow Chart

Here is flow chart shows how the MKR1000 can get access to cloud services.

image

 

4. Codes

4.1 There have been many types of arduino IDEs, the arduino create Cloud is by far the best one, log into https://create.arduino.cc/editor/ , you can get your IDE panel and standard library without downloading from web anymore.

image

4.2 The debuge console and Serial Monitor shows the running mode of the program.

In this screenshot, it can be seen that the thingspeak channel is connected, but later the link is lost with http error code -301.

image

4.3 Here is the code.

#include <LiquidCrystal.h>
#include "ThingSpeak.h"


#include <NTPClient.h>
#include <WiFi101.h> // for WiFi 101 shield or MKR1000
#include <WiFiUdp.h>


//#include "secrets.h"
#define CH_ID_WEATHER_STATION 12397           //MathWorks weather station
#define CH_ID_COUNTER 298725 //Test channel for counting
#define READ_APIKEY_COUNTER "SODG0O2UZVGKWAWG" //API Key for Test channel


#define LEDLIGHT 1 // LED light output for D1


const char *ssid     = SECRET_SSID;
const char *password = SECRET_PASS;


WiFiUDP ntpUDP;
//NTPClient timeClient(ntpUDP);
// You can specify the time server pool and the offset (in seconds, can be
// changed later with setTimeOffset() ). Additionaly you can specify the
// update interval (in milliseconds, can be changed using setUpdateInterval() ).
NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000);


WiFiClient  client;
int keyIndex = 0;            // your network key Index number (needed only for WEP)
unsigned int temperatureFieldNumber = 4;
unsigned int counterFieldNumber = 1; 
const char * myCounterReadAPIKey = READ_APIKEY_COUNTER;
unsigned long counterChannelNumber = CH_ID_COUNTER;
unsigned long weatherStationChannelNumber = CH_ID_WEATHER_STATION;


const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int gt_day,gt_hour,gt_minute;
String gt_time;


void setup(){
  lcd.begin(16, 2);
  lcd.print("Smart Clock.");
      pinMode(LEDLIGHT, OUTPUT);
  digitalWrite(LEDLIGHT, LOW);   // turn the LED on (HIGH is the voltage level)
         
  Serial.begin(115200);


  WiFi.begin(ssid, password);


  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );
  }


  timeClient.begin();
   ThingSpeak.begin(client);  // Initialize ThingSpeak
   delay(1000);
}


void loop() {
  int statusCode = 0;
  timeClient.update();


  gt_time=timeClient.getFormattedTime();
   lcd.setCursor(0, 1);
    lcd.print("Ticks:");
  lcd.setCursor(6, 1);
  lcd.print(gt_time);
  Serial.println(gt_time);
  //lcd.print(millis() / 1000);


  float temperatureInF = ThingSpeak.readFloatField(weatherStationChannelNumber, temperatureFieldNumber);  
  // Check the status of the read operation to see if it was successful
  statusCode = ThingSpeak.getLastReadStatus();
  if(statusCode == 200){
    Serial.println("Temperature at MathWorks HQ: " + String(temperatureInF) + " deg F");
    lcd.setCursor(0, 0);
    lcd.print("Temp:");
    lcd.setCursor(6, 0);
    lcd.print( String(temperatureInF) + " F");
  }
  else{
    
    Serial.println("Problem reading channel. HTTP error code " + String(statusCode)); 
  }
  if (millis() >15000){
    onAlarm();
    }
  delay(500);  
}




void onAlarm() {


   digitalWrite(LEDLIGHT, HIGH);  
}

 

5. Final build

5.1 Here is how the smart clock wiring

image

Then, Put it into one case and tag Smart Clock. The leds hide in one mini desklamp, left red/black wires out.

image

5.2 The video.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

6. Conclusion

This is prototype Smart Clock of Home Automation . More function can be added to this smart clock for rich features.

  • Sign in to reply
Parents
  • aspork42
    aspork42 over 6 years ago

    Nice job! I love it!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • aspork42
    aspork42 over 6 years ago

    Nice job! I love it!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube