Nano Every SDA SCL Pins

Newbie here ... do not assume that I know what I am doing ...

Any guidance is appreciated.

I am trying to communicate with a Real Time Clock Module, and I do not understand what is wrong

Hardware:
RTC: DS3231
Board: Nano Every (authentic Arduino not a knock off)

For troubleshooting I am running the following sketch

#include <RTClib.h>
RTC_DS3231 rtc; // setup the Real Time Clock

// Define Variables
char DaysOfTheWeek[7][12] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

void setup() {
// Start the Serial Port
Serial.begin(9600);
}

void loop() {
DateTime now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(DaysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.println();
delay(3000);
}

My RTC is running and has the current time and date. I just loaded this sketch onto an UNO and it works fine, I get the current time and date. When I download the sketch to the Nano Every, I get the following;

2165/165/165 (Saturday) 165:165:85

So, I think there must me something that I do not understand about the Nano Every SDA SCL pins, I am using A4-SDA, A5-SCL I've check these a couple of times.

For troubleshooting I have both a Nano Every and Uno here, and again this runs fine on the Uno so I'm confident that the RTC is running and has the current time. Also, this is my first experience with the Every board, so I think it highly likely that I just confused on how it handles the TWI.

Any suggestions or feedback is appreciated.

Thanks

A4 and A5 are the I2C pins, if you have pins marked SDA and SCL they are connected to A4 and A5 so you cannot use those pins for anything else. Download the scanner for I2C and see if it shows up. If not try switching them. When that works do the scan again with all the hardware hooked up. Also note the I2C is a bit fussy on Pull Up resistors, check them. I think when you get the scanner to work your problem will be solved. If your wires are over a few inches in length that can cause problems as well. Be sure all the grounds are connected.

I don't see any pullup resistors on SDA/SCL in the Nano Every schematic

I appreciate both suggestions.

I ran a I2C scanner as suggested. Again, I'm newbie so I found a I2C scanner on another forum page. I'll paste the sketch I used below. Scanner results;

Scanning ...
I2C device found at address 0x57
I2C device found at address 0x68
done

So ... I'm not sure why it found two devices ... I have a single RTC DS3231 and nothing else. If I disconnect the DS3231 the scanner correctly return no devices found, so I think that's working??

Crossroads also suggested checking out the pull up resisters. I played around with this ... added 4.7K pull up resistors to 3.3V. also tried 1.5K pull up resisters, also tried pull up resisters to 5V, all the same result. The original sketch, the one that just reads the time/date from the RTC returns "2165/165/165 (Saturday) 165:165:85"

Retested this with the UNO , no problems getting good results with the UNO ... so RTC is working. For troubleshooting I have an Uno and a Nano Every, and the RTC. Only 4 wires here, GND, 3.3V, SDA, SCL ... that's it, no other devices of any kind. Hook up to Uno, no issues, hook up to Nano Every I get garbage.

I have two Nano Every's here, so just to be complete I swapped out Nanos and got the same result between the two. So I am still thinking that this is something more fundamental that I do not understand with the Nano Every I2C? I'm confused.
I'll keep playing around, but any thoughts as to why the scanner is returning two addresses, or thoughts as to what else to try on the pull up resisters?
I appreciate your input, I just do not have experience with the Nano Every to understand what the issue is.

Thanks

Just for reference, here is the I2C scanner sketch that I ran

#include <Wire.h>
void setup()
{
Wire.begin();
Serial.begin(115200);
Serial.println("\nI2C Scanner");
}
void loop()
{
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for (address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address < 16)
Serial.print("0");
Serial.print(address, HEX);
Serial.println(" !");
nDevices++;
}
else if (error == 4)
{
Serial.print("Unknown error at address 0x");
if (address < 16)
Serial.print("0");
Serial.println(address, HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // wait 5 seconds for next scan
}

Some RTC modules have an I2C EEPROM chip also. Does yours have a 2nd chip?

The 2165/165/165 (Saturday) 165:165:85 indicates to me that the time is not running.
I think you have to set a bit in one of the control registers to get it going.

CrossRoads:
Some RTC modules have an I2C EEPROM chip also. Does yours have a 2nd chip?

The 2165/165/165 (Saturday) 165:165:85 indicates to me that the time is not running.
I think you have to set a bit in one of the control registers to get it going.

Wouldn't that also show up on the uno though - which apparently works OK?

So I figured out my issue.

But first, I just want to express my appreciation and help for the newbie.

Second, I can confirm that the original sketch works fine on Uno, yes the RTC is running, correct time comes up on the Uno ... every time. I also ran the I2C scanner on the Uno and it comes up with the exact same two addresses.

My newbie error and issue was that on the Nano Every sketch I had to add

include <Wire.h> in the header

and
Wire.begin(); in the setup

so ... I guess my only last question is why did this work on the Uno? apparently Uno did not need the # include <Wire.h> and Wire.begin(); ??

Again, appreciate your patience and help.

Hello DS1307 sniffers,
On UNO the shield works fine, but not on Leonardo and MEGA2560.
Jumpers resolve the problem like on the picture.
Thanks for your job !!!

@pol64800

Modern shields should make use of the dedicated I2C pins and not A4 and A5. Your jumper wires indicate that, although the shield has the I2C pins, they are not used.

Your Nano is placed on a board that gives it the Uno form factor. So should work like Uno.