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

Thread Starter

seanspotatobusiness

Joined Sep 17, 2016
210
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.
 

cognas

Joined Feb 24, 2017
58
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.
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.
 

Thread Starter

seanspotatobusiness

Joined Sep 17, 2016
210
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.
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.

Why the need for all of the complexity?

There are tons of products on the market to remind you to take your medication.

http://www.ebay.com/itm/Electronic-...423432?hash=item2813a74e08:g:PpoAAOSwoudW4Qnw
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.
 

LesJones

Joined Jan 8, 2017
4,174
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.
 

Phillip Lucas

Joined Mar 13, 2017
28
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
 

ErnieM

Joined Apr 24, 2011
8,377
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.
 

Thread Starter

seanspotatobusiness

Joined Sep 17, 2016
210
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.
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.
 

ErnieM

Joined Apr 24, 2011
8,377
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.
 

LesJones

Joined Jan 8, 2017
4,174
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.
 

Thread Starter

seanspotatobusiness

Joined Sep 17, 2016
210
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.
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.
 

ErnieM

Joined Apr 24, 2011
8,377
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?
 

LesJones

Joined Jan 8, 2017
4,174
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:

Thread Starter

seanspotatobusiness

Joined Sep 17, 2016
210
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.


View attachment 122527

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.
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 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?
I loaded someone else's sketch onto an Arduino but not much more than that.
 

LesJones

Joined Jan 8, 2017
4,174
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.
 
Top