author
6Instructables97,643Views50CommentsJoined February 24th, 2009

Tell us about yourself!

Complete Your Profile

Achievements

10K+ Views Earned a bronze medal
  • DS3231 OLED Alarm Clock With 2-button Menu Setting and Temperature Display

    The clock has an inner loop that runs every 500ms based upon the millis counter the code outside this loop rubs at full speed. The normal alarm beeper uses the alarm flag to toggle the alarm output on/off every time the inner loop executes, resulting in a 1/2 second on, 1/2 second off activation of the alarm.I think your issue is that you are checking the alarm flag and calling the playback function every time the 500ms inner loop executes, retriggering it every half-second! You need some kind of flag that allows it to be called once when the alarm trigger occurs, and never again until the alarm is silenced manually or times out. Also, the playback function and library may be incompatible with the Adafruit graphics library.

    View Instructable »
  • DS3231 OLED Alarm Clock With 2-button Menu Setting and Temperature Display

    I seem to recall that it outputs to a .data text file. You need to incorporate the data into the proper structure at the beginning of the sketch. The output looks like this when saved correctly.const unsigned char pusheen_teacup [] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00,0x00, 0x38, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x07, 0xE0, 0x00, 0x00, 0x00, 0x00,0x00, 0xE6, 0x0C, 0x61, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xC7, 0xFC, 0x3F, 0xFF, 0xC0, 0x00, 0x00,0x00, 0x83, 0xF8, 0x3E, 0x3D, 0xF0, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x38, 0xF8, 0x00, 0x00,0x0F, 0x80, 0x00, 0x3C, 0x00, 0xFC, 0x00, 0x00, 0x3F, 0x9C, 0xC7, 0x3F, 0x00, 0x6E, 0x00, 0x00,0x0F, 0x1C, 0xE7, 0x3D, 0x00, 0x03, 0x00, 0x00, 0x1F, 0x1D, 0xF3, 0x1E, 0x00, 0x03, 0x8...

    see more »

    I seem to recall that it outputs to a .data text file. You need to incorporate the data into the proper structure at the beginning of the sketch. The output looks like this when saved correctly.const unsigned char pusheen_teacup [] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00,0x00, 0x38, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x07, 0xE0, 0x00, 0x00, 0x00, 0x00,0x00, 0xE6, 0x0C, 0x61, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xC7, 0xFC, 0x3F, 0xFF, 0xC0, 0x00, 0x00,0x00, 0x83, 0xF8, 0x3E, 0x3D, 0xF0, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x38, 0xF8, 0x00, 0x00,0x0F, 0x80, 0x00, 0x3C, 0x00, 0xFC, 0x00, 0x00, 0x3F, 0x9C, 0xC7, 0x3F, 0x00, 0x6E, 0x00, 0x00,0x0F, 0x1C, 0xE7, 0x3D, 0x00, 0x03, 0x00, 0x00, 0x1F, 0x1D, 0xF3, 0x1E, 0x00, 0x03, 0x80, 0x00,0x13, 0x01, 0x80, 0x02, 0x00, 0x01, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00,0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00,0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xC0,0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0xE0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38,0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x08,0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x8C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xC4,0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xC4, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xC6,0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xC6, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xC4,0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x8C, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x88,0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCE, 0x18, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x38,0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0xE0, 0x70, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0xC0,0x00, 0xC0, 0x00, 0x00, 0x00, 0x03, 0x07, 0x80, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x06, 0x3E, 0x00,0x00, 0x60, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00,0x00, 0x18, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00,0x00, 0x07, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x03, 0x80, 0x00, 0x00,0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFE, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

    Thanks! It was a fun project to make.Rescaling the code for a bigger display is a bit tricky since I hard-coded the screen coordinates of many of the elements. Bad coding practice, but I never intended to port to another display.For LCD Assistant, the final image you import must be a monochrome bitmap and must be a multiple of 8 bits in both the x and y axis. You must check the "horizontal" box before exporting to make the data structure compatible with the Adafruit library. Of course the image size must not be larger than the OLED display pixel dimensions.

    The DS3231 supports a 1 pulse-per-second square wave signal that is brought out to one of the pins on the module. It must be enabled in software. I turn the feature on during initialization, but no connection is needed to that pin for normal clock operation. If you put a voltmeter on that pin, you will see it go high once per second. Some devices need a 1 PPS signal to sync to an accurate time source. Many GPS receivers have such a signal. This is nowhere near as accurate as a GPS unit, but it is a temperature-compensated time source and good enough to serve as a reference for other devices.

    View Instructable »
  • df99 commented on df99's instructable Arduino 12-mode Blue Box - Introduction9 months ago
    Arduino 12-mode Blue Box - Introduction

    What would the wifi connectivity be used for???

    View Instructable »
  • df99 commented on arduinomaster's instructable EMF detector 0- 999 Hz for ATtiny 8511 months ago
    EMF detector 0- 999 Hz for ATtiny 85

    Nice! I was wondering why the averaging routine uses an array? It seems needlessly complex since you are just averaging the readings and do nothing with the individual values. Just keep a running total and a sample counter and divide when number of samples == NUMREADINGS. No need to store each value in an array and much faster.

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

    There is an application floating around on the web and Adafruit called LCD Assistant that allows you to import a monochrome bitmap image and generate an Arduino/Adafruit-compatible data structure. The imported bitmap must be a multiple of 8 bits in both the x and y axis. You must check the "horizontal" box before exporting to make the data structure compatible with the Adafruit library.

    I have my Arduino and RTC in a box or I would have removed those SMD LEDs. They are way too bright. On my other "Four Letter Word Clock" Instructable I had to do that as the light leaking from the enclosure was annoying.

    Try adding counters that are triggered by the existing alarm that count the number of inner 100ms timed loops through the code. That would allow additional alarms at intervals after the initial alarm

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

    Hi, Alan. Your build looks very nice! The 2N2222 trick is a great way to boost the drive to a more power-hungry speaker. Permanent magnet (non-piezo) speakers can eventually demagnetize if a DC current is fed to them too long, so a series capacitor of a microfarad or two is recommended.As you found, the DS3231 temperature sensor returns its value natively in Celsius. I have to convert it for Farenheit, but just eliminating the conversion in the code works fine for a Celsius display.I never used I2C pullups, I believe the DS3231 module does have them installed, however. I believe I checked this once.After I made a few minor software updates, I built and gave a clock to each of my daughters for Christmas a few days ago. I put them in a box covered with Pusheen stickers (see new pics at th...

    see more »

    Hi, Alan. Your build looks very nice! The 2N2222 trick is a great way to boost the drive to a more power-hungry speaker. Permanent magnet (non-piezo) speakers can eventually demagnetize if a DC current is fed to them too long, so a series capacitor of a microfarad or two is recommended.As you found, the DS3231 temperature sensor returns its value natively in Celsius. I have to convert it for Farenheit, but just eliminating the conversion in the code works fine for a Celsius display.I never used I2C pullups, I believe the DS3231 module does have them installed, however. I believe I checked this once.After I made a few minor software updates, I built and gave a clock to each of my daughters for Christmas a few days ago. I put them in a box covered with Pusheen stickers (see new pics at the beginning of this Instructable). I powered it from a dual-USB port cell phone charger so they can charge their Iphones with it as well. I can easily change the code if needed by unplugging the charger and plugging into the USB port on my computer.

    I recall I needed a very specific DS3231 library for some reason, settling on the one in the distribution. I think it had to do with a function to force more frequent temperature readings, which some libraries lack, Not 100% certain though.

    The alarm duration cannot current be set in a menu item. If you would like to change it in the latest non-Pusheen version of the code, look at line 133:if(beepcount <= 600){ //Sound alarm for 60 secondsThe alarm duration is set by counting the number of 100ms iterations through the main "inner loop" of the code. Just set the comparison number (currently 600 for 60 seconds) for the number of 100ms intervals you'd like and recompile.

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

    Note that if you use the copy of the Adafruit library I included in the distribution, this error will not occur. It is happening because you are using an Adafruit graphics library obtained elsewhere, with the default display type set to 128x32.

    Note that if you use the copy of the Adafruit library I included in the distribution, this error will not occur. It is happening because you are using an Adafruit graphics library obtained elsewhere, with the default display type set to 128x32.

    Note that if you use the copy of the Adafruit library I included in the distribution, this error will not occur. It is happening because you are using the an Adafruit graphics library obtained elsewhere, with the default display type set to 128x32.

    Note that if you use the copy of the Adafruit library I included in the distribution, this error will not occur. It is happening because you are using the an Adafruit graphics library obtained elsewhere, with the default display type set to 128x32.

    View Instructable »
  • 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 df991 year 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 »