Arduino Uno chiming the bells help needed, pls

Parts list:

  1. Arduino uno Rev 3
  2. Ethernet Shield
  3. Chronodot RTC DS3231S
  4. i2C/SPI Character LCD Backpack Adafruit
    What I need it to do:
  5. retrieve an IP address over DHCP
  6. retrieve date and time from local NTP server
  7. set RTC clock with date and time from NTP server
  8. convert date and time to Unix
  9. adjust for day light savings time
  10. output on specific pins to control bell tones for 3 different shifts (each shift needs these bell tones)
    a. 5 min warning bell
    b. Start shift
    c. Lunch start
    d. Lunch end
    e. End shift

I am currently not worried about displaying the time on the LCD screen. My main concern here is getting the bells to chime at specific times based on the NTP time and adjusted for day light savings time. This is a project that I am taking over from somebody with much more knowledge about the subject and they are no longer with us. I have done research but am finding it difficult to get everything to mesh together. What I need is to send a signal (voltage) from 3-5V out of two pins to a relay. This signal will ring the bells. Any help that I can get would be greatly appreciated.

Code that I have so far: http://playground.arduino.cc/Main/DS1307OfTheLogshieldByMeansOfNTP (which I am not sure will even work with my specific RTC) And the attached code

Arduino Bell Code.docx (15.6 KB)

My main concern here is getting the bells to chime at specific times based on the NTP time and adjusted for day light savings time.

I take it that it's the scheduling/time management that is concerning you, not the mechanism of making the bells chime. However, you're going to need a driver circuit between the Arduino and the relay, and you haven't mentioned that so far.

There's a time library which you can use to work out the wall-clock time based on NTP or an RTC. Assuming the Arduino somehow knows what time each bell is due at, making it sound then is easy enough.

Are the bell times going to be hard-coded (fixed in the software) or configurable; if configurable, how / where will they be configured? This strikes me as one of those jobs that might be best done on a PC (using standard OS scheduling features, and NTP clock management and timezone/DST support and all that stuff, rather than in a microcontroller. If you do the schedule management on A PC then the role of the Arduino becomes just playing a specified bell chime whenever the PC commands it and you eliminate NTP, and the RTC, and all the user interface stuff. However, it does mean you'd have to have a PC available - I don't know whether that's feasible for you.

In my original post I state that I only need the arduino to output to two specific pins when the time is right. These pins will tell the relay to engage and send 60V to the bells causing them to chime. This program does not need to be configurable as this will be a set and forget type of project. I already have the hardware configuration that is doing it's job at the moment. The bells are ringing. However, the arduino was setup with a static IP address and that is a security risk that my director wants to negate. So, I have a need to learn code quickly and hopefully get a little help from the community in setting the code up. I understand what the arduino is capable of, I am just not capable of making it do it by myself.

What I need help with - knowing what libraries to include in my code to do the specific things I need the arduino to do, what commands will set the RTC from the NTP time pulled from the local NTP server (using the RTC because it is more accurate than the arduino with regards to keeping time), how to create actions based on the time. Also, I haven't been able to find any code that is specific to my particular RTC. Does anyone know if the link that I included in my original post to that code will work with my specific RTC as well?

To PeterH, I am terribly sorry. I was very rude of me not to thank you for replying to my original post. Thank you for your reply.

I'm not sure I follow the security concern. You don't have to use a static address if you don't want to - the Ethernet library supports DHCP. What threat are you trying to guard against? If you're concerned about NTP spoofing attacks then can't you get rid if the network interface completely? I mean just select an RTC that has good enough accuracy for your requirements, set the clock once and leave it running.

You seem confident that the output side has been dealt with but I want to make sure you understand that the Arduino won't drive a relay directly - it will need a driver circuit between the Arduino and the relay.

The physical setup is sufficient and operational. At this time I need assistance with the code. Thank you.

Is there anyone that can point me in the right direction? (please see original post if you have questions about what I am talking about) There is a LOT of information in these forums and even searching for things yields a mountain of information. I am going to continue to try and mesh this code together. I really need some help on the RTC circuit and how to call up actions based on the time in the RTC circuit. Thank you

Ok, after some more research, I believe I have something that may work. Please look at the attached code and let me know if there is anything that I have that will not work, or problems I may run into. Thank you for your help

Ring_The_Bells.docx (17.3 KB)

A quick Google for "Chronodot RTC DS3231S arduino" took me to Arduino Playground - HomePage which should make it easy to use the RTC as a wall clock using the DS1307RTC library. That page also suggests that it is easy to use NTP to synchronise the RTC.

If you're willing to hard-code the scheduled times then you could detect when it was time to do something based on seconds now different to previous seconds, and hours/minutes/seconds all matching your scheduled time.

If you want your schedule times to apply daylight saving then you would need to find/implement an algorithm to decide what timezone you are in (or hard-code the timezone) and then work out when DST starts and ends in the current year in that timezone and apply the appropriate offset before making the time comparison.