Rtc DS3231 display in dashboard: I2C confusion

I posted this earlier in a different thread, but it was marked "solved" so I don't know if anyone saw this post:

Well, I seemed to have really messed something up. All was working well until I followed some tutorials about how to set the HWCLOCK.

Now, when I scan using 'i2cdetect -y 1' it shows ports 57 and a UU in port 68 where the DS3231 is supposed to be. The 'UU' is supposedly a conflict but the commands 'sudo hwclock -r' and sudo hwclock -w' entered into the terminal seem to work.

Yet using the i2c Scan node, a port 87 appears. I get errors when I try to use the 'i2c in' nodes to connect to 57 or 68. It will connect to the phantom port 87 but I only receive '255' in the msg.

Can someone tell me what I've messed up here?

So how are you trying to access the RTC?

I can't see/find anything telling me that in this thread.

Why do you think that the UU on port 68 is a conflict?

Port 57 may be RAM on the RTC.

I am simply trying to read the DS3231 RTC in NODE RED, do some arithmetic on it and then display the results on the Dashboard. I initially looked for a simple way of doing that. Nor finding any Node that would do this for me, I addressed the chip via I2C using the chip's '00' '01' and '02' commands and then had to decode the BCD return.

Not too bad, but then I wanted to write to the clock and messed up my RPi settings in various config files. Here are my questions:

Why can't I connect to port 68 using the I2C IN nodes? Yes, port 57 is the EEPROM on the chip but 68 supposedly has the time.

If I look for active addresses on the I2C bus using 'i2cdetect -y 1' in the terminal, it shows one open on port 57 and 'UU' on 68 sometimes but just plain '68' at other times.

If I look for active addresses on the bus using a i2c node, i get '87' as a payload. I can't connect to the 68 port at all. I can to the phantom '87' port but only get '255' as a payload.

This was working before but I can't figure out what I messed up.


How did you connect the RTC chip to Rpi ?
Is the power supply of RTC chip 5V ?
Are on SCL and SDA pin pullup resistor, if yes is this connect to 5V?

The RTC chip has only one i2c address 68h (not port).

Sorry ... using the wrong terminology ... I2C address not port.

The RTC module is wired properly and to 3.3v (which is correct). The DS3231 does indeed have two addresses 68 and 57 (56 on older versions). The 57 is the onboard RAM.

Using the 'i2cdetect' command in the Pi's terminal window it shows addresses at 57 and UU at 68. No other addresses appear in that scan. But when I read using NODE RED's i2c SCAN node in the flow, it only shows an 87 address in the payload.

None of these addresses work when I try to read them using a 'i2c in' node. I can read the RTC hardware in the terminal window using 'hwclock -r' . When I unplug the RTC module, I can no longer read it or see the i2c addresses.

Can you enter this in command line:
2cget -y 1 0x68 0
i2cget -y 1 0x68 1
i2cget -y 1 0x68 2

I get the response "Error: Could not set address to 0x68: Device or resource busy" on all 3 entries. I retried with the HW module unplugged and got the same error message

I do not have that RTC chip. Mine is a different chip.

So I can't test what I am saying.

But if you install the node that talks to that RTC chip accessing the time should be simple.

You do what you want to do and then you can even send it back to the RTC.

In the other thread @Andrei showed you the node you need.

Install it and see what it says. As I said: I can't as I don't have that RTC.

If you have bought a board, it plugs onto the GPIO pins.

If not, you need to connect it yourself to the I2C pins, GND and +3.3v
They are all at one end of the GPIO pins and all on the same side.

Oh and a general reply:

You need to edit the /boot/config.txt file and other stuff to tell the system there is a RTC and to use it.

It is not simply a case of connecting it and it will work.

There are commands to read/write to the RTC.
You don't need to mess around with the commands you are showing.

Set PI time from RTC (HW clock) enter:
sudo hwclock -s

Set RTC (HW Clock) time from PI time enter:
sudo hwclock -w

Looks like that an other program opens address 0x68.
Test it with an other fresh OS installation.
Enable i2c with raspi-config.

87 decimal = 57 hex

1 Like

Yeah, I forgot that part too! (Thumbs up)

Thanks for pointing that out dceejay. I had this all working on address 104 in the node (0x68) before and it didn't even occur to me that it might have been decimal. As a result, I had no idea where the '104' came from. In hindsight, it's pretty obvious.

I still have the conflict as 0x68 address is being used by some other program somewhere and that's preventing me from accessing it from the node. I started with a clean slate but I've obviously changed something in a config file somewhere that is causing this.

I'm trying to use some more advanced stuff in Node Red like the i2c bus communications. I realize I could probably fix this from a clean OS load, but since this is intended to be a learning experience for me, I'd like to find the cause of the conflict the hard way.

I'll continue to plod along unless someone can point me in the right direction regarding clearing the conflict. At this point it's apparently more of a RPi thing than a node red thing so I might try a different forum.

Thanks for the help.

I remember using below article when I tested a DS3231 module in the past. It explains the conflict is with Linux kernel. It is a nice walkthrough.

Thanks Andrei,

I've seen this tutorial and have been through it. To be sure, I went through it again. I can read and set the DS3231 RTC using the terminal program as shown at the end of the tutorial. Everything seems to be working. It displays the time and I can even set the time on the RTC... in the terminal. I have removed the fake HW commands.

But I still can't read the RTC using the NODE RED "i2c in" node. Using the NODE RED "i2c scan" node, it doesn't even show it as an available address (should be 0x68 == decimal 104)

I just get "Error: , Remote I/O error" when I try and connect to 0x68 (104)

Something about the "UU" shown in the terminal scan still indicating a conflict I think:

0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

If you set up the DS3231 RTC correctly, then I suspect that other I2C program including the Node RED I2C node can't access it any more. It is blocked by the system. That's why it shows up "UU" in the I2cdetect command.

If you want to get the time, then just read the system time, which is provided by the RTC.

Alternatively, do not follow the guide that installs the DS3231 as the system service. Then you can see DS3231 shows up normally in the I2cdetect command. Then you can use your own I2C program.

1 Like

U da man, davidz!

I had followed the guide so that I might be able to write the system time to the RTC easily on bootup. That was causing the conflict. But now hwclock -w no longer works.

So now I have to find another way to set the RTC and sync it to system time. My application is extremely time sensitive (and battery operated) so I need an RTC and it has to be set accurately. The system clock on its own drifts far too much.

But at least this mystery is finally solved. Thank you.