Things used in this project

Hardware components:
Watch%20single
O Watch Sensor Kit
×1
Software apps and online services:
Ide web
Arduino IDE
TinyCircuits-TinyScreen_Lib-master Library
Time-master Library
Adafruit_Sensor-master Library
Adafruit_BMP280 Library
Adafruit_HMC5883 Library
SI7021-master Library

Code

D Watch v0.1Arduino
Extended sample code from O Watch to include time, temp, and humidity readouts.
/*
 * My Watch 1 ( D Watch, v0.1)
 *
 * Extending O Watch smaple code to include temp and humidity
 *
 * This example is created by dwardio on 9 March 2016
 * 
*/

#include <TinyScreen.h> //include TinyScreen library
#include <TimeLib.h> //include the Arduino Time library
#include <SPI.h> //include this library for communication with OLED screen
#include <SI7021.h> //include the sensor library
SI7021 sensor; //declare the sensor

TinyScreen display = TinyScreen(TinyScreenPlus); //Create the TinyScreen object

void setup()
{
  
  Wire.begin();
  sensor.begin();
  display.begin();                            //Initializes TinyScreen board
  display.setFlip(1);                         //Flips the TinyScreen rightside up for O Watch
  display.on();                               //Turns TinyScreen display on
  display.fontColor(TS_8b_White,TS_8b_Black); //Set the font color, font background
  display.setBrightness(10);                  //Set display brightness 0 - 15
  
  // Set the time and date. Change this to your current date and time.
  setTime(07,42,00,9,3,2016);    //values in the order hr,min,sec,day,month,year

  //Show info at start to say what each button does
  display.setFont(liberationSansNarrow_12ptFontInfo);
  display.setCursor(8,25);
  display.print("D Watch v0.1");
  display.setFont(liberationSansNarrow_10ptFontInfo);
  display.setCursor(60,7);
  display.print("Time>");
  display.setCursor(64,45);
  display.print("Wx>");  
  display.setCursor(5,45);
  display.print("<Set");
  delay(2000);
  display.clearScreen();
}

void loop()
{

  //Switch statement to select part of code to run based on button selection
  switch (display.getButtons()) 
  {

    //Run updateTime function 
    case TSButtonLowerLeft:
      display.on();
      updateTime();
      delay(200);
      display.off();
      break;

    //Run showWx function
    case TSButtonLowerRight:
      delay(200);
      display.on();
      showWx();
      delay(200);
      display.off();
      break;

    //Show time for 4 seconds 
    case TSButtonUpperRight:
      display.on();
      for(int i=0; i<5; i++)
      {
        display.setFont(liberationSansNarrow_12ptFontInfo);   //Set the font type
        // Print date in US format MM:DD:YY (Switch the order in which day, month, year that you like to use)
        display.setCursor(15,8); //Set the cursor where you want to start printing the date
        display.print(monthShortStr(month()));
        display.print(" ");
        display.print(day()); 
        display.print(", ");
        display.print(year());
      
        display.setCursor(30,25); //Set the cursor where you want to start printing the date  
        display.print(dayStr(weekday()));
      
        display.setFont(liberationSansNarrow_16ptFontInfo);   //Set the font type
      
        // display time in HH:MM:SS 24 hour format
        display.setCursor(20,45); //Set the cursor where you want to start printing the time
        if(hour()<10) display.print(0); //print a leading 0 if hour value is less than 0
        display.print(hour());
        display.print(":");
        if(minute()<10) display.print(0); //print a leading 0 if minute value is less than 0
        display.print(minute());
        display.print(":");
        if(second()<10) display.print(0); //print a leading 0 if seconds value is less than 0
        display.print(second());
        display.print(" "); //just a empty space after the seconds
        delay(1000); //delay 1 second           
      }
      delay(200);
      display.clearScreen();
      display.off();
      break;
    
  }
  delay(200);
}


//Function to update time
void updateTime()
{

  //Set hour
  display.clearScreen();
  display.setFont(liberationSansNarrow_8ptFontInfo);   //Set the font type
  display.setCursor(2,15);
  display.print("<Save | Change>");
  display.setCursor(15,40);
  display.setFont(liberationSansNarrow_12ptFontInfo);   //Set the font type
  display.print("Set Hour:");
  int myhour=hour();
  while(!display.getButtons(TSButtonUpperLeft))
  {
    display.setCursor(75,40);
    if(myhour<10) display.print("0");
    display.print(myhour);
    if(display.getButtons(TSButtonUpperRight))
      myhour++;
    if(display.getButtons(TSButtonLowerRight))
      myhour--;
    if(myhour<0) myhour=24;
    if(myhour>24) myhour=0;
    delay(200);
  }
  setTime(myhour, minute(), second(), day(), month(), year());
  delay(500);
  display.clearScreen();
  display.setCursor(10,25);
  display.print("Hour Saved");
  delay(1000);

  
  //Set minute
  display.clearScreen();
  display.setFont(liberationSansNarrow_8ptFontInfo);   //Set the font type
  display.setCursor(2,15);
  display.print("<Save | Change>");
  display.setCursor(15,40);
  display.setFont(liberationSansNarrow_12ptFontInfo);   //Set the font type
  display.print("Set Mins:");
  int myminute=minute();
  while(!display.getButtons(TSButtonUpperLeft))
  {
    display.setCursor(75,40);
    if(myminute<10) display.print("0");
    display.print(myminute);
    if(display.getButtons(TSButtonUpperRight))
      myminute++;
    if(display.getButtons(TSButtonLowerRight))
      myminute--;
    if(myminute<0) myminute=60;
    if(myminute>60) myminute=0;
    delay(200);
  }
  setTime(hour(), myminute, second(), day(), month(), year());
  delay(500);
  display.clearScreen();
  display.setCursor(10,25);
  display.print("Minute Saved");
  delay(1000);

  //Set second
  display.clearScreen();
  display.setFont(liberationSansNarrow_8ptFontInfo);   //Set the font type
  display.setCursor(2,15);
  display.print("<Save | Change>");
  display.setCursor(15,40);
  display.setFont(liberationSansNarrow_12ptFontInfo);   //Set the font type
  display.print("Set Secs:");
  int mysecond=second();
  while(!display.getButtons(TSButtonUpperLeft))
  {
    display.setCursor(75,40);
    if(mysecond<10) display.print("0");
    display.print(mysecond);
    if(display.getButtons(TSButtonUpperRight))
      mysecond++;
    if(display.getButtons(TSButtonLowerRight))
      mysecond--;
    if(mysecond<0) mysecond=60;
    if(mysecond>60) mysecond=0;
    delay(200);
  }
  setTime(hour(), minute(), mysecond, day(), month(), year());
  delay(500);
  display.clearScreen();
  display.setCursor(10,25);
  display.print("Second Saved");
  delay(1000);
  display.clearScreen();
  
}

//Function to show Wx (Temp & Humidity) for 4 seconds
void showWx()
{
  //get the temperature using the library function 
  //temperature is an integer in hundredths
  int tempHundredths = sensor.getCelsiusHundredths();
  float temperature = tempHundredths / 100.0;

  //get humidity from the libdary function
  // humidity is an integer representing percent
  int humidityvalue = sensor.getHumidityPercent();
  
  
  display.setFont(liberationSansNarrow_12ptFontInfo);   //Set the font type
    
  //print humidity value
  display.setCursor(20,10);
  display.print("RH: ");
  display.print(humidityvalue);
  display.print("%  ");
  
  //print temperature value F
  display.setCursor(5,30);
  display.print("Temp: ");
  display.print((temperature*9/5+32-13)); //printing value converted to Fahrenheit
  display.print("º F  ");

  //print temperature value C
  display.setCursor(5,50);
  display.print("Temp: ");
  display.print(temperature); //printing value in C
  display.print("º C  ");

  //clear display after delay
  delay(4000);  
  display.clearScreen();

}

Credits

12313715 10153780129703454 5569632005137107900 n
Dennis Ward

Educational Technologist, Maker, e-NABLE volunteer, & RC Pilot

Thanks to O Watch.

Replications

Did you replicate this project? Share it!

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

PiMiniMint
Intermediate
  • 173
  • 4

Full instructions

Build your very own Linux terminal inside a mint tin!

SORT4U
Intermediate
  • 69
  • 2

Full instructions

It's the sorting machine that you've been waiting for. Just throw all your junk in it and let it sort for you.

SORT4U

Team The Avengers

Solar Smart Greenhouse Using Vertical Aquaponic Towers
Intermediate
  • 3,154
  • 43

Work in progress

Feed your family with 22 sqm greenhousing by combining permaculture, aquaponic vertical towers and IoT.

Drop of Life
Intermediate
  • 676
  • 17

Full instructions

A display to remind me when I can donate blood and save lives, powered by the Red Cross API and Particle.

FM radio
Intermediate
  • 8,640
  • 38

Full instructions

Build a great sounding FM radio with a cool display using an Arduino Nano and the Sparkfun Si4703 FM tuner breakout

PiGlass
Intermediate
  • 2,875
  • 21

Full instructions

A device that can measure environmental conditions and relay to the user; in glasses form.

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback