beginner question about ds3231 rinkydink code

I hooked up my uno to the ds3231 module. I downloaded the ds3231.zip and added it to my sketch. I also copied and pasted the sketch to my arduino. I hooked up sda and scl to A4 and A5 as instructed. The sketch compiles, but the output is attached as a .jpg The output is a bunch of backwards ? and other gibberish continuously in a line. I am sure this is probably something I overlooked, so maybe someone can tell what is missing from my code? thanks

In the setup() function of the sketch, there will be a line that looks something like this:

Serial.begin(115200);

That initializes serial communication and, in this example, sets it to 115200 baud. You need to make sure the Serial Monitor is set to the same baudrate as the sketch. The baudrate menu is at the bottom right corner of the Serial Monitor window.

pert:
The baudrate menu is at the bottom right corner of the Serial Monitor window.

SerialMonitor.png

SerialMonitor.png

Thank you. That works. I feel so baudly about that. Do you think I will have a conflict when blend this sketch with my working mpu6050 sketch and chain the two modules together? I keep seeing stuff posted that the mpu6050 and the ds3231 are using the same register?

4x1ks:
Thank you. That works. I feel so baudly about that. Do you think I will have a conflict when blend this sketch with my working mpu6050 sketch and chain the two modules together? I keep seeing stuff posted that the mpu6050 and the ds3231 are using the same register?

Yes! You will face problem as to having the same I2C Bus address (0x68 = ob1101000) for both DS3231 and MPU6050 (not the same registers). The solution is:

Assign address 0x69 to MPU6050. the procedures are:
1. Look for the path/folder in your PC where the MPU6050.h file is located. For my PC it is here:
mpu6050h.png

2. Open the file. Change this line: #define MPU6050_ADDRESS (0x68) into this line:
#define MPU6050_ADDRESS (0x69)

3. Save the file and exit.

4. Connect AD0-pin of your MPU6050 sensor at 5V.
mpu6050-2.png

mpu6050h.png

mpu6050-2.png

thanks…I am not using the mpu6050.h library. My definitions are directly in the sketch. I change the mpu6050 register to 0b1101001 in all the register addresses in my sketch. So now the mpu6050 is running on 0x69 and not 0x68. IT WORKS. I have the ds3231 and mpu6050 working simultaneously. And without using the mpu6050.h library. thanks!

I attached a pic of the working output. The rtc on the left and the x and y axes in degrees also. The mpu6050 is sitting flat approx.

working ds3231 and mpu6050 output.JPG

Good news that your MPU6050 and DS3231 are working together as good neighbors.

By the way: I see that there are repeated prints of the same time (11.39:57 twice) in your Serial Monitor and at the same time there are two different values for Xdeg and Ydeg which look odd. I think you are using delay(1000) function in your program to drive the Serial Monitor.
rtcx.png

The DS3231 RTC maintains time at 1-sec interval which can be used to drive the Serial Monitor and then we will not see the repeated prints of the same time; there will also be only one value for Xdeg and Ydeg at the printed time point.

rtcx.png

Thanks. I changed it to 1000ms. I have another problem in that I put in the battery 2032...when I restart the uno, the time is not keeping up with realtime. For example, if it is 12:01 when I disconnect the power from the uno, then I wait 5 minutes, when I reconnect the power to the uno, the time starts at 12:01 on the serial monitor. It should be 12:06. Any ideas?

4x1ks:
Thanks. I changed it to 1000ms.

After changing to 1000ms, what is the show on the Serial Monitor? Can you post a screenshot please?

4x1ks:
I have another problem in that I put in the battery 2032...when I restart the uno, the time is not keeping up with realtime. For example, if it is 12:01 when I disconnect the power from the uno, then I wait 5 minutes, when I reconnect the power to the uno, the time starts at 12:01 on the serial monitor. It should be 12:06. Any ideas?

Yes! There is a cure for it. Please, post your RTC codes with code tags; I will try to locate your problems and will provide hints so that you can correct it yourself.

problem solved...all is well.

4x1ks:
problem solved...all is well.

Good news.

But, what is about the following request? Should it go unheard?

GolamMostafa:
After changing to 1000ms, what is the show on the Serial Monitor? Can you post a screenshot please?