As far as I can tell, and as I've been told by others, the R4 won't work with UNO R3 data logging shields. If true, this is disappointing. The R4 looks like a duck, but it doesn't quack like a duck, and it's certainly not a duck. For my projects, I almost always need to log data, including the date/time. Of course, the R3 data logging shields have an RTC that saves the date/time because that shield has a coin cell backup battery.
I assume separate RTC and SD card modules will work, but that's certainly not as convenient as having a data logging shield. Any reason why you can't develop an R4-compatible data logging shield? Or is there code that will make R3 data logging shields work on the R4? Any thoughts will be greatly appreciated.
Please post a link to the data logging shield that you are referring to
You can get UNO R3 data logging shields from adafruit.com or from many online sources. The online sources use DS1307 RTCs instead of PCF8523 RTCs. These are just "standard" data logging shields, all basically the same, that have been used for years with R3, and there's certainly nothing special about the ones I use. If you want to find out more about them, just search for UNO R3 data logging shield on Amazon.
I have had a brief look at the Adafruit Data Logging Shield specification and at first sight cannot see why it would not be compatible with the Uno R4
Where did you see the advice that the shield was not compatible with the R4 ?
Was the problem perhaps that some of the libraries that are used in example code for the shield are not compatible with the R4 ? If so, then that is a different problem
I was told by someone at Adafruit.com that their data logging shields (which are no different from "off shore" shields except that Adafruit shields now uses PCF8523 clocks rather than DS1307 clocks.) These clocks are completely interchangeable on UNOs. Off-shore Nano data logging shields also always us DS1307 clocks, as far as I know. If it's a library problem, then I hope someone can solve it -- that's way beyond my abilities. If you think it should work, perhaps you could try it yourself. Write code that logs a date and time, perhaps displaying the data/time on a small OLED at the same time. That would be a major contribution! As far as I know, everybody uses the RTClib library that's available through the library manager in the Arduino IDE.
Here's some code with an Adafruit data logging shield on an R4 MINIMA. As you can see, the DATE and TIME print correct values (are these macros, or what??), but then calls to now.year(), etc., give junk values. Perhaps this really is some kind of software library problem that can be fixed. Short of that, how could I write code to get year, month, etc. values from DATE and TIME without the now.year(), etc. ??
// RTC_pcf8523.ino
// Date and time functions using a PCF8523 RTC.
#include <Wire.h>
#include "RTClib.h"
RTC_PCF8523 rtc;
void setup () {
Serial.begin(9600);
if (rtc.begin()) {
Serial.println("clock running...");
rtc.adjust(DateTime(DATE, TIME));
}
else Serial.println("clock not running...");
}
void loop () {
DateTime now = rtc.now();
Serial.print(F(DATE));Serial.print(' ');
Serial.println(F(TIME));
Serial.print(now.year());
Serial.print('/');
Serial.print(now.month());
Serial.print('/');
Serial.print(now.day());
Serial.print(' ');
Serial.print(now.hour());
Serial.print(':');
Serial.print(now.minute());
Serial.print(':');
Serial.println(now.second());
Serial.println();
delay(3000);
}
Jun 17 2024 19:20:15
2165/165/165 165:165:85
Jun 17 2024 19:20:15
2165/165/165 165:165:85
Please use code tags when posting code.
I notice that this is not in the output:
implying that there was some issue initializing the RTC.
How do you have it connected?
Here's some output from the code below. The code works the same on an R4 MINIMA if I'm using an UNO data logging shield or a separate RTC module. The same code works perfectly well on an UNO or Nano, for example. That is, updating the date/time as the loop() function runs.
What's going on here?? Without the ability to log data with a date/time stamp, the R4 is of absolutely no use to me and probably a lot of other potential users, too! Surely there must be some way to use the R4 to record data from sensors and log their data with a date/time stamp, remotely, without a USB cable connected to a computer.
Jun 18 2024 13:22:21
2165/165/165 165:165:85
Jun 18 2024 13:22:21
2165/165/165 165:165:85
Jun 18 2024 13:22:21
2165/165/165 165:165:85
#include <Wire.h>
#include "RTClib.h"
RTC_PCF8523 rtc;
void setup () {
Serial.begin(9600);
if (rtc.begin()) {
Serial.println("clock running...");
rtc.adjust(DateTime(DATE, TIME));
}
else Serial.println("clock not running...");
}
void loop () {
DateTime now = rtc.now();
Serial.print(DATE);Serial.print(' ');
Serial.println(TIME);
Serial.print(now.year());Serial.print('/');
Serial.print(now.month());Serial.print('/');
Serial.print(now.day());Serial.print(' ');
Serial.print(now.hour());Serial.print(':');
Serial.print(now.minute());Serial.print(':');
Serial.println(now.second());
Serial.println();
//Serial.println(now.year()); // G12arbage data for all now... calls.
//date=String(DATE);
//timex=String(TIME);
//Serial.print(date);Serial.print(' ');Serial.println(timex);
delay(3000);
}
Yes, the clock is running. I didn't copy that part of the output.
How are the connections? Does the shield have the right pull-ups for I2C lines?
The problem isn't the R4. It can read an RTC. It has one built in but no crystal for it
You're talking about an Adafruit product. I don't think the R4 can be judged as useless because something someone else made doesn't work with it. You'll probably get better help from more folks if you cut that part out and focus on fixing the problem.
The numbers you get back, those 165's, are usually what you see when the I2C bus isn't working right for some reason. So focus on figuring out if there are differences between the R3 and R4 in respect to the I2C bus. I know the R4 has a lot less drive current so you may need stronger pull-ups. I don't know.
Either way, you can't complain here that something made by Adafruit isn't working right. If you want to complain about that shield being incompatible then complain to them. If you want to find a fix then stop complaining and let's look for a fix.
OK. Let's look for a fix. I mentioned the Adafruit data logging shield because it's been around a long time and works well. "Off shore" data logging shields are basically the same and they work with UNOs, and similar off-shore shields work for Nanos. Those off-shore versions always have DS1307 clocks, which Adafruit data logging shields don't use anymore, but RTClib works with PCF8523 clocks, too. As you may know, DS1307 clocks work only on 5V boards, while PCF8523 clocks work with either 3.3 or 5 V boards.
Figuring out differences between the R3 and R4 I2C bus is a hardware issue beyond my skill level. I have no idea whether the shield has "the right pull-ups for I2C lines." All I know is that these shields and separate RTC modules from a variety of sources ALWAYS work with UNOs and separate RTC modules, with a variety of Arduino boards, using RTClib, but not the R4.
I know that the R4 has a built in clock, but it doesn't have battery backup, that stores date/time settings. As I'm sure you know, the UNO data logging shields have a coin cell battery and will store date/time settings essentially forever so you can use it for data logging offline.
It's nice that R4s have the same pin layout as UNOs, so it's not unreasonable to think that one should be able to plug in a data logging shield and have it work. It doesn't.
You say that this should be an Adafruit problem, which it's not really, because it's not just their particular data logging shields. Adafruit says it's an Arduino problem. It can't solve the problem, so who's going to do it?? If I sound like I'm just complaining, it's only because the folks that SHOULD be equipped to solve the problem haven't done it -- just pass the blame. Maybe that person who can solve the problem will be you I said the R4 is useless for me, which it is, because it doesn't allow me to record and log data offline with a date/time stamp. Others may have different uses for which the R4 is perfectly suitable.
Well, my apologies are in order. The R4 MINIMA WILL provide date/time values with a separate RTC module -- I'm using an RTC PCF8523 module from Adafruit. Not ideal because I'll need a separate SD card module to log data, so it's less convenient than a data logging shield but certainly workable. Here's code that displays date/time on a small IZOKEE OLED:
// RTC_pcf8523_OLED.ino
// Date and time functions using a PCF8523 RTC.
#include <Wire.h>
// RTC setup
#include "RTClib.h"
RTC_PCF8523 rtc;
int YR,MON,DAY,HR,MIN,SEC;
// OLED setup
#include "U8x8lib.h"
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);
void setup () {
Serial.begin(9600);
if (rtc.begin()) {
Serial.println("clock running...");
rtc.adjust(DateTime(DATE, TIME));
}
else Serial.println("clock not running...");
u8x8.begin();
u8x8.setFlipMode(0); // landscape
u8x8.setFont(u8x8_font_7x14_1x2_f);
//u8x8.setFlipMode(1); // reversed landscape
}
void loop () {
DateTime now = rtc.now();
Serial.print(DATE);Serial.print(' ');
Serial.println(TIME);
YR=now.year(); MON=now.month(); DAY=now.day();
HR=now.hour(); MIN=now.minute(); SEC=now.second();
Serial.print(YR);Serial.print('/');
Serial.print(MON);Serial.print('/');
Serial.print(DAY);Serial.print(' ');
Serial.print(HR);Serial.print(':');
Serial.print(MIN);Serial.print(':');
Serial.println(SEC);
Serial.println();
u8x8.clearDisplay();
u8x8.setCursor(0,0);
u8x8.print(YR);u8x8.print('/');
u8x8.print(MON);u8x8.print('/');
u8x8.println(DAY);//u8x8.print(' ');
u8x8.print(HR);u8x8.print(':');
u8x8.print(MIN);u8x8.print(':');
u8x8.println(SEC);
delay(3000);
}