Hello all,
New to Arduino and electronics in general. Looking for some help figuring out how to get my shiny new RTC to work with my arduino (have a mega 2560).
I have already made a simple project which uses the Time library to display a coloured LED depending on the time of day and the season. But since I have to hardcode the starting date it is not ideal.
So I bought this RTC without knowing much about them. I’ve tried to follow the sample code but I cannot even figure out how to attach it to my Arduino! (I know Im a big noob). Could someone give me a hand in figuring out how to do this?
It has 7 connectors:
GND - ground
VCC – voltage??
SQW – square wave??
CLK – clock??
MISO – master in, slave out
MOSI – master out, slave in
SS – slave selector
Ive learned some things about SPI but still am shaky on how that even works.
Any help you could provide would be greatly appreciated!
I haven't worked with this chip yet, but can tell you something about the used pins.
VCC should be connected to the +5volt connection on your arduino to power the RTC-chip.
CLK is the same as SCK pin, on the DS-board Clock is abbreviated to CLK, my best guess is Serial ClocK is Atmels/arduinos abbreviation, SCLK is sometimes also used, but they're all the same. When talking about time, Arduino uses it to signal the chip that it's time to send/receive the next bit of info, it's not related to time in hours/minutes/seconds.
The SQW-connector probably isn't very important to get started, it doesn't need to be connected.
You can do several things with it though.The 3234 can be programmed with 2 alarms in which case the pin responds, but
It can also be used to generate 4 different frequencies. You could program alarms on the arduino or have it generate a frequency, but the pin could be useful if you wanted to perform a task at a certain time without having an clock-routine running on the arduino.
I took your advice and wired the component as suggested in the RTClib library that I am using. Using 8 on my arduino as the slave selector.
Its making more sense how the SPI actually works, using the "clock" to regulate bits.
However, the RTC does not appear to be functioning as the test function outputs 00:00:00. Not sure what I can do to debug this as the circuit is quite simple.
Then I tried a library written specifically for this and other RTCs. That is found here:
I am unsure how to create a schematic but the wiring is quite simple
Connections on the board -> Arduino
GND -> Ground on Arduino
VCC -> 5V connector on arduino
SQW -> not used
CLK -> 12 on arduino (PWM)
MISO ->11 on arduino
MOSI -> 10 on ardunio
SS -> 8 on arduino (defined in code)
Thanks all for their feedback.
Got my project up and running and it works well when plugged into the USB port.
However, when I plug the 9V connector into battery port the device just flickers and turns off after a few seconds.
These are fresh batteries.