loading
6Instructables78,607Views41Comments

Tell us about yourself!

Complete Your Profile

Achievements

10K+ Views Earned a bronze medal
Show 0 More »
  • DS3231 OLED alarm clock with 2-button menu setting and temperature display

    Check the updated code with bug fixes and selectable output modes. Also selectable night dimming.

    Oops, sorry. My bad. Try v1.3, which I just uploaded and all should compile fine.I fixed a problem with the v1.2 code that would cause compilation errors for any non-ATmega32U4 Arduino. I added a compact "note" function to generate a frequency on Pin 10 if the "speaker" alarm output option was selected. The function I included used the timer structures for ATmega32U4. In v1.3, I added a non-ATmega32U4 version of the "note" function and added conditional compilation directives to automatically compile the correct version. I also compile the "note" function only if the "speaker" output is selected, saving memory if any other output option is selected. I tested the code with all board types in the IDE and received no compilation errors.

    View Instructable »
  • df99 followed df995 days ago
      • Four Letter Word Clock with Akafugu Word Generator and Inspirational Phrases
      • Arduino Coffee Brewer Water Fill System
      • DS3231 OLED alarm clock with 2-button menu setting and temperature display
  • DS3231 OLED alarm clock with 2-button menu setting and temperature display

    I just discovered a bug that may affect your project. There is an alarm timeout function which shuts off the alarm after 600 100ms loops through the timed loop, or 1 minute. If the user resets the alarm with the "set" button, the counter does not get reset. The effect is that the NEXT time the alarm sounds, it will time out before 60 seconds (60 second less the time elapsed before the set button was pressed from the previous alarm cycle). The fix is to change this code block:if(!digitalRead(9)){DS3231_clear_a1f();}toif(!digitalRead(9)){DS3231_clear_a1f(); beepcount = 0;}I have updated code that allows alarm operation with a normal speaker rather than a buzzer. It dims the display from 10 PM to 5 AM. It also returns the display to normal after being left in setting mode after ...see more »I just discovered a bug that may affect your project. There is an alarm timeout function which shuts off the alarm after 600 100ms loops through the timed loop, or 1 minute. If the user resets the alarm with the "set" button, the counter does not get reset. The effect is that the NEXT time the alarm sounds, it will time out before 60 seconds (60 second less the time elapsed before the set button was pressed from the previous alarm cycle). The fix is to change this code block:if(!digitalRead(9)){DS3231_clear_a1f();}toif(!digitalRead(9)){DS3231_clear_a1f(); beepcount = 0;}I have updated code that allows alarm operation with a normal speaker rather than a buzzer. It dims the display from 10 PM to 5 AM. It also returns the display to normal after being left in setting mode after no button activity. I changed the alarm "on" indicator to be between the time and temperature display. I also flash the entire display into inverse mode at 5 Hz when the alarm sounds, rather than flashing the asterisk in the analog clock. I fixed the bug mentioned here as well. I may post the changes here, but will definitely fix the bug in the posted code soon.

    There is an "inner" main loop that runs every 100ms and an "outer" loop that runs full speed. The temperature polling code is in the inner loop. For the temp sensor within the DS3231, I attempt to initiate a temperature read every 100ms, but I check the busy flag first to see if the previous read has finished. I'm not sure if the DS18B20 library waits for a response before allowing the inner loop to continue processing, but if it does and the response is slow, that could cause an erratic display and other operation. Perhaps try adding a counter to only read the sensor every n of the 100ms loops and see if the performance improves.

    View Instructable »
  • DS3231 OLED alarm clock with 2-button menu setting and temperature display

    Great! Of course, with the change, the code is still trying to set the alarm output every other loop cycle. Since it only turns off the output when the alarm flag is cleared (with the change) it doesn't matter. Not worth the effort to clean up, in case you ever want to change it back to an interrupted output.Best,Don

    Oops. That change required the RTC alarm flag to be reset (happens after 600 seconds) AND the manual alarm enable to be off, which is wrong. The solution is to turn off the alarm only when the alarm flag is cleared (after 600 seconds, if the alarm silence button is pressed, or if the alarm has not yet set).Try using this line for line 72:if(!DS3231_triggered_a1()){digitalWrite(10, LOW);} //Turn off external alarm for flashing if RTC alarm flag clearThat only shuts off the alarm every loop if the RTC alarm flag is cleared. That will prevent the intermittent output on pin 10 and allow proper operation of the 600 second alarm timeout and silencing the alarm with the button.Don

    Looks great!

    In the generic clock main code, change line 72 to:if(!wake_SET && !DS3231_triggered_a1()){digitalWrite(10, LOW);} //Turn off external alarm for flashingThe published clock code turns off the alarm at 5Hz, if the alarm is on or not. If the alarm is "on", the code turns it on at 5Hz every other cycle. The main loop turns it off every cycle, resulting in pulsed 5 Hz on pin 10.The code change only turns off the alarm pin in the main loop if the alarm is NOT on. This allows pin 10 to remain high continuously when the alarm is set until the alarm is "off", when the main loop will force pin 10 low.Best,Don

    View Instructable »