Which micro controller (with RTC) to use for something really basic?

Discussion in 'Embedded Systems and Microcontrollers' started by seanspotatobusiness, Mar 13, 2017.

  1. seanspotatobusiness

    Thread Starter Member

    Sep 17, 2016
    130
    2
    I need to take medication before I go to sleep but sometimes forget. My solution is to have an LED start to flash in my bedroom at 2100 hrs and a button to press to stop it until the next day. When I switch off my light to go to sleep I'll notice the flashing LED, take my happy pill and hit the button to reset the controller until 2100 the following night. What would be a suitable microcontroller to do this? I figure it needs an RTC to know when 2100 hrs is but if it's simpler maybe it could also be set by just plugging it in at 2100 hrs and it could then count 24 hour periods from there.
     
  2. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    6,644
    2,928
  3. cognas

    Member

    Feb 24, 2017
    48
    6
    Couldn't you use a low-cost battery-powered alarm clock for that? It would ring each night at 21:00 until you stop it.
    I'm currently trying to figure out how to program an ATtiny85 (8-pin microcontroller) for a project I'm working on, and I can tell you that...
    a) this processor, with an LED or a buzzer and a button would certainly do what you want.
    b) unless you are familiar with microprocessors, you can expect to spend a long time (maybe a month or more) figuring out how to do it.

    If you really want to play with uControllers, then the month getting into it may be well spent. If you just want a solution, I'd go for the alarm clock.
     
  4. seanspotatobusiness

    Thread Starter Member

    Sep 17, 2016
    130
    2
    If I don't want to go to bed until 2300 then I just put up with the alarm for the intervening two hours? I'm pretty sure it would silence itself before then anyway. Thanks but that's not a good solution for my needs and I don't want to learn how to program microcontrollers from scratch; I was expecting to use something with an IDE.

    There's nothing in the product information that indicates that it does what I want. They're all trying to fit other people's needs and I want to fit my needs which are quite different. Thanks anyway.
     
  5. LesJones

    Well-Known Member

    Jan 8, 2017
    1,404
    334
    You could use a plug in timer that powered a small DC power supply (Wall wart.). The power supply would feed a small circuit that powered up in a state that switched the flashing LED on. It would have a button to switch off the flashing LED. It could be a simple as a small SCR (Such as a 2N5060) that was triggered on via a capacitor to the positive rail when power was applied. This could switch on the power to a NE555 (Or the cmos version) to flash the LED. The button could be a push to break that was in series with the SCR anode to unlatch the SCR. The timer would be set to switch on at 21:00 and off at 08:00. By the way an IDE (Integrated development environment.) does not write the code for you. It consists of a text editor to type in your source code, a compiler or assembler (Depending if you are writing in assembly language or a high level language such as "C") and an interface to a programmer to put the code into the microcontroller. It may also have a simulator to test the code before writing it to the micro.

    Les.
     
  6. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    6,644
    2,928
  7. tracecom

    AAC Fanatic!

    Apr 16, 2010
    3,934
    1,430
    Most RTC chips have alarm functions built in. DS1307 is cheap and easy. See this for a start.
     
  8. Phillip Lucas

    New Member

    Mar 13, 2017
    28
    0
    ok how about we do something different... have a "dark detector"
    when you turn the lights off to meet the sandman it will light the room with a flash to remind you. set a timer on it for about 5 minutes so that it only goes for 5 minutes after lights are out so no need to reset the device every day. No need to set a schedule as it relies on darkness of the room....
    hope this helps
     
  9. radiohead

    Senior Member

    May 28, 2009
    495
    39
  10. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,943
    1,816
    I use the PCF2129 for a real time clock. It has several advantages over types such as the DS1307 (which costs the same or more) in that the crystal is built in so you don't have to connect one, and since it is built in it is extremely accurate. You probably don't care about accuracy but did I mention the crystal is built in???

    These external RTCs are much easier to add a simple coin cell battery backup so you don't need to reset them all the time.

    You still need a micro in your system to program these, but you probably want one anyway since you need to set the current time and the alarm anyway. Yeah, if you catch this at the time you want the alarm to sound you can just press a SET button to do that, as the current time isn't an issue, just matching the last time is.
     
  11. seanspotatobusiness

    Thread Starter Member

    Sep 17, 2016
    130
    2
    On eBay and AliExpress, at least, the DS1307 appears to be quite a bit cheaper than PCF2129 (10xDS1307 for £0.65 vs 1xPCF2129 for £3.50).

    Would it be possible to use one of these thing that already has bits and pieces in it? I don't know whether it depends on the Arduino for anything other than programming it.
     
  12. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,943
    1,816
    Sure those would work just fine. It does need something else to program it. It works over something called the I2C (eye two see) interface that is very common in small micro computers.

    Just about any size micro can do this trick, but you may want to use something with some heft to it just to make it easier for you to use. Something like an Arduino or similar would be good.
     
  13. TQFP44

    Member

    Sep 3, 2016
    53
    13
  14. seanspotatobusiness

    Thread Starter Member

    Sep 17, 2016
    130
    2
    Would this be a suitable microcontroller? It's a cheap and dirty looking ESP8266 but it has a couple of GPIO pins. I think it can be programmed with the Arduinio IDE as a "generic ESP8266".
     
  15. LesJones

    Well-Known Member

    Jan 8, 2017
    1,404
    334
    Do you plan on having a display and buttons for setting the time ? If so I don't think the ESP8266 will have enough I/O pins. There are several different versions of the ESP8266 modules with different numbers of I/O pins brought out to connections so you need to check that you have enough I/O pins for your purpose. I have only used them to read data from DHT-22 modules (Temperature and humidity sensor.) It only requires one I/O pin for this purpose.

    Les.
     
  16. seanspotatobusiness

    Thread Starter Member

    Sep 17, 2016
    130
    2
    I don't intend to have a display. I expect to set the time either when I load the program or afterwards via Wi-Fi (probably too complicated and not worth it) or don't program the time at all and have it consider the time it first receives power/turns on to be 2100 hrs.

    Alternatively there are also these DS3231 modules which have built-in alarm functions and maybe the alarm function can turn on a thyristor via the square wave output. The thyristor can then be reset with a switch.
     
  17. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,943
    1,816
    I can't check your controller as I don't speak that language. It may be a Bluetooth module and not a micro.

    Whatever micro you choose will need a program you will need to write, and you need some way to get that program into the micro, and test it. Have you done any work like that?
     
  18. LesJones

    Well-Known Member

    Jan 8, 2017
    1,404
    334
    I have come up with a possible solution just using Cd4000 series cmos chips. This is the basic part to generate a signal every 24 hours. It would be used to set a flipflop (CD4013) which would enable the flashing LED A push button would reset this flipflop.


    24HR.PNG

    Above is a picture of the plan. If I was doing it I would do it in software using a PIC12F1840 or ATtiny13a (Or similar microcontroller)

    Les.
     
    Last edited: Mar 15, 2017
    seanspotatobusiness likes this.
  19. seanspotatobusiness

    Thread Starter Member

    Sep 17, 2016
    130
    2
    Thanks! Have you any idea how close the CD4000 method would keep to a 24 hr cycle? Like how many seconds it would gain or lose each day?

    Can you program an ATtiny13a with the Arduino IDE using one of these adapters: https://www.aliexpress.com/item/Plu...or-Micro-Usb-Power-Connector/32666942466.html ? Would you program it in a different language?

    I loaded someone else's sketch onto an Arduino but not much more than that.
     
  20. LesJones

    Well-Known Member

    Jan 8, 2017
    1,404
    334
    These 32.768 Khz crystals are pretty accurate. They are used in digital watches, clocks and with RTC ICs as the frequency standard. You can add a small trimmer capacitor for fine adjustment if you have a frequency standard to calibrate them to. I would think for your application they be accurate enough without any adjustment. You may need to reset the time every few years. You cannot program directly with an Arduino IDE but you can find code on the web that can program an Arduino to behave like a programmer. I use one of the USBASP programmers. And use the assembler in Atmel AVR studio. I use Avrdude programming software to program them. You could use an Arduino but it would take more power than an ATtiny13a running at 32.768 Khz.

    Les.
     
Loading...