Just the kind of thing you want to run into after a long, arduinious struggle with bugs the size of black holes. I tried the rtc1307 (https://www.amazon.com/gp/product/B07TVMVDDP/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1)
on two nano boards, but that didn't work. I verified that i2c worked with a light sensor. Then I put it on my r3 board, and all of them work perfectly. I think maybe since these boards are so cheap, they don't have some kind of pull up resistor, and thats why? IDK, but I would really love to put these boards to use in various gardening devices I'm going to be working on, if anyone has any idea whats going on.
The Nanos that you have, are they the classic Nano (with atmega328 processor) or one of the newer Nanos, like NanoBLE, Nano Every, Nano33IOT?
i'm only working with nano clones from amazon, nothing special.
-
We need to see your schematic.
-
We need to see good images of your wiring.
-
We need to see your sketch.
Maybe if you post a link, we can check what you are actually using. There are enough clone Nanos that are actually not Nanos because they use a different processor.
I'm just using the RTClib for the ds1307
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include "RTClib.h"
RTC_DS1307 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup () {
Serial.begin(57600);
#ifndef ESP8266
while (!Serial); // wait for serial port to connect. Needed for native USB
#endif
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
while (1) delay(10);
}
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running, let's set the time!");
// When time needs to be set on a new device, or after a power loss, the
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
// When time needs to be re-set on a previously configured device, the
// following line sets the RTC to the date & time this sketch was compiled
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
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.print(" since midnight 1/1/1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");
// calculate a date which is 7 days, 12 hours, 30 minutes, and 6 seconds into the future
DateTime future (now + TimeSpan(7,12,30,6));
Serial.print(" now + 7d + 12h + 30m + 6s: ");
Serial.print(future.year(), DEC);
Serial.print('/');
Serial.print(future.month(), DEC);
Serial.print('/');
Serial.print(future.day(), DEC);
Serial.print(' ');
Serial.print(future.hour(), DEC);
Serial.print(':');
Serial.print(future.minute(), DEC);
Serial.print(':');
Serial.print(future.second(), DEC);
Serial.println();
Serial.println();
delay(3000);
}
and the wiring is just scl sda and vcc and gnd. I always have to double check if A5 is scl or sda ( i still don't know) and I double check my wiring every time I plug it in.
What do you see when you run the i2c scanner program on the Nano.
// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011
#include <Wire.h>
void setup() {
Serial.begin (115200);
// Leonardo: wait for serial port to connect
while (!Serial)
{
}
Serial.println ();
Serial.println ("I2C scanner. Scanning ...");
byte count = 0;
Wire.begin();
for (byte i = 8; i < 120; i++)
{
Wire.beginTransmission (i);
if (Wire.endTransmission () == 0)
{
Serial.print ("Found address: ");
Serial.print (i, DEC);
Serial.print (" (0x");
Serial.print (i, HEX);
Serial.println (")");
count++;
delay (1); // maybe unneeded?
} // end of good response
} // end of for loop
Serial.println ("Done.");
Serial.print ("Found ");
Serial.print (count, DEC);
Serial.println (" device(s).");
} // end of setup
void loop() {}
it didn't pick it up at all
Does it report "Done Found 0 Devices" or does it hang at "I2C scanner. Scanning ..."
I don't believe it hanged when i tried it.
I've always used pull up resistors with a DS1307 (which I have used in many projects). All documentation I have seen calls for pull up resistors. You have nothing to lose to add pull up resistors.
Please read the reviews in the Amazon link posted for the 1307. There is discussion of a ground not being connected on the board.
I got tired of troubleshooting. You know the feeling, like your drowning. I just can't believe that it works on the r3 and not on the nano, since they are identical. But I'm willing to try it out before I buy the ds3231. For this project though I just substituted in a light sensor to turn on the pump when the sun comes up. should work the same.
The DS3231 is by far the better choice !
Yeah, I actually had one laying around and I'm using it right now for another project for the garden, a seedling light and mister. I couldn't believe it when I went to set the date and time, it was exactly 4:19, and I had to wait just 20 seconds till it changed to 4:20! Oh well. I think I read somewhere that the ds1307 can run on a battery for 17 years. I had a battery in the ds3231 when I used it last year and its already dead. But it is running on a nano perfectly.
The datasheet (below) shows the registers that can be manipulated.
The ds1307.cpp library file describes how it sets up the ds1307. I have not had been inside the registers, so I do not have advice.
And, of course, the internet has some nano/1307 issues... here's one example...
Thanks so much for the video. I have no idea how programming the registers would allow me to use it with the nano while it already works for the uno. Oh well, I had another problem with the RTClib from adafruit, they have no way to tell if its am or pm if the rtc is programed for 12h mode. So I've been looking into programming the rtc, and here it is!
Differences might surface, but I do not know the issue. There are small differences in Uno v Nano; analog pins, EEPROM and SRAM. Does your code use the two extra analog pins on the Nano?
I'm actually over the 1307 for the nano and used a light sensor. Everything about the RTC is just shrouded in ambiguity, but I figured out allot since yesterday and I'll just have to order some DS3231's for my nano projects.