Search:

PmWiki

pmwiki.org

edit SideBar

Main / ArduinoRealTimeClock

Overview


The aim of this project is to complete an initial, simple, Arduino-based project to learn about the technology. The goal of this project is to use an Arduino Uno, a Real Time Clock chip, crystal oscillator, an LCD screen, and a custom laser-cut acrylic case to create a working clock with digital display. This project is being completed with the support of incredible and patient friends from the Hacklab Toronto.

Progress


  • learned how to make an LED blink using the Arduino, "Hello, world!" style
  • connected the LCD screen and learned to display simple text
  • disconnected LCD screen, and created circuit (on a breadboard) including the Arduino and RTC chip (NJU6355)
  • used Instructables' RTC tutorial to create Arduino sketch using a DS1307RTC Library
  • hit a road bump when I realized that the NJU6355ED RTC chip that I'm using has pins assigned differently from the default DS1307 used in the tutorial, and spent a lot of time poring over both data sheets
  • consulted with someone who knows a lot more than I do, learned that I would either have to write my own library for the NJU6355ED chip, or order a DS1307. Chose to order a DS1307.
  • in the meantime, consulted with someone else who knows a lot more than I do about building a custom case for the finished clock. My plan had been to laser cut an acrylic case at the Hacklab, so he pointed me in the direction of a Thingiverse download that can be customized to easily laser cut a custom case.
  • December 27
    • now have an Arduino Tiny RTC module, rather than my dysfunctional chip from before. Feel like I've learned my lesson in ordering electronics components - it's worth it to pay a little more for parts that definitely work than pay less and have less reliable parts
    • found this additional Instructables tutorial to help with this project
    • thanks to generous souls at the Hacklab, got quick crash courses in I2C protocols, communication busses, object-oriented coding, and modulus functions
    • was gifted an I2C LCD screen that allows me to use fewer wires to connect my screen and RTC module to the Arduino
    • tested the screen, and it worked no problem
    • added RTC chip, screen test failed. Hacklab friends built a bridge using 10kohm resistors and a small breadboard (learn about this later), and screen test successful
    • learned that I should probably learn C basics, and was directed to a database for downloading free IT ebooks, and found an ebook about beginner C for Arduino to breeze through
  • December 28 - came for a late night work session at the lab
    • started by asking for some advice on steps to follow tonight. Ended up with the following list:
      • Step 1 – test the RTC on its own without the screen
      • Step 2 - write the code for the RTC and LCD to communicate w one another:
        • Import the libraries
        • Configure – assign pins for all the things
        • Create a variable that gives information to the chip (set time, date, etc)
        • Use the RTC library to translate/send that information to the chip
        • Create a second variable that specifies what information I want the chip to send (actual time, date, etc – maybe also temperature eventually, but maybe that’s a third variable)
        • Use RTC library to query the chip
        • Use LCD library to write the information to the LCD
    • disconnected the LCD screen to test the RTC module
    • tested the module using this test code
      • copied and pasted the test code into the Arduino app, verified and uploaded it, and then verified the test using the Serial Monitor (found in the Tools section)
    • test successful! whee! (told everyone, resisted Tweeting about it)
      • using the "?" command in the Serial Monitor, found some of the other useful commands, and used the Serial Monitor to set the date and time for the RTC chip
    • reconnected the LCD screen
    • combined the test code for both the RTC and the LCD, being sure to include all the relevant libraries at the start, then putting both setup codes at the top, followed by the RTC main code, and then the LCD main code (minus the lcd.print("hello world") line)
    • changed "setup.print" to "lcd.print" through the entire code, and added "lcd.println" under the necessary/relevant "setup.println"
    • when I verified the code, the only error was that "lcd" was not defined within the scope, so I went back and double checked the LCD test code. I had not defined LCD at the beginning of the combined code, so I added "LiquidCrystal lcd(8);" underneath the libraries
    • verified the code without errors
    • connected all components via the Arduino serial port, and the LCD began to display the time as hoped!
    • summarily celebrated my small victories!
  • January 1 (working on temporary MacBook Air)
    • Had a problem uploading program to Uno, checked the troubleshooting guide and was reminded to be sure to select the board and port before working on a new computer, problem solved
    • Trying to adjust the format in which time is displayed:
      • commented out lcd.print(count) and ( :)
      • after asking for help, realized that the main code for the LCD screen being after the main code for the RTC in the loop meant that the cursor wasn't resetting to its original position when the clock was refreshing to display the time
      • Note: Next steps, power supply and design a case (dimensions of the entire screen piece for the case: 48.5 mm x 87 mm)
  • January 10
    • learned my lesson a second time about selecting the board and port before working on a project
    • completed a button tutorial to add buttons to the clock for setting the time
    • next steps will be to add the buttons to the clock code, buy the parts for the power cord, and then design and cut a case (since the laser cutter is currently out of commission, this may take a little while longer than originally anticipated)
  • March 4
    • I opened this project up after a few months of not looking at it. Am now on a different laptop than before because of the accident that happened with mine over the holidays, and also had to update my Arduino software
    • all libraries were missing, so I re-downloaded and installed all of them
    • now, many errors being thrown - for almost every item in each library. Consulted with Hacklab colleagues and still not sure what's going on.
    • leaving this alone for tonight, and trying to decide whether to call this project done for now because learning has been had and I should move on to something else, or whether it's still worth the time investment to go back and finish this project.



Blog Post


I published a blog post about this project for the SCDS. Go read about my relative failure!


Page last modified on March 23, 2016, at 06:25 PM