I2C address conficts with HD44780 (LCD) and DS1307 (RTC)? -- Solved

I have quite a stash of HD44780 (16 x 2 line LCD modules), and I've come to find out they all have a fixed I2C address of 0x37. This was all new to me, because I had thought on the hardware level I2C addresses were always in to 0-7 range. But anyway, I've discovered these VERY cheap clock I2C modules based on the DS1307 chip...

http://www.oddwires.com/ds1307-real-time-clock-module-for-arduino-with-i2c-interface/

So knowing I2C modules often have fixed I2C addresses, does anyone know if these RTCs have a different address to avoid a conflict? I wrote the website's contact form, and all they could tell me was that there is a discovery sketch I could use to find out their I2C address. Obviously I'd rather know in advance if it can't be changed. Anyone know?

0x68 is the I2C address for DS1307. The address cannot be changed.

1 Like

The address of any I2C device will be found in the data sheet for that device.

PeterPan321:
I have quite a stash of HD44780 (16 x 2 line LCD modules), and I've come to find out they all have a fixed I2C address of 0x37.

I've not seen one yet that uses 0x37.
What device would that be? Got a link to it?

The PCF8574 based backpacks use 0x20 to 0x27 or 0x38 to 0x3f
The MCP23008 based backpacks use 0x20 to 0x27
The LCDs that use PCF2116/PCF2119x chips use 0x3a or 0x3b
A few others LCD devices I've seen use 0x3a to 0x3f

This was all new to me, because I had thought on the hardware level I2C addresses were always in to 0-7 range.

i2c slave addresses will be anything but 0-7 as 0-7 is reserved for special functions.

--- bill

bperrybap:
I've not seen one yet that uses 0x37.
What device would that be? Got a link to it?

The PCF8574 based backpacks use 0x20 to 0x27 or 0x38 to 0x3f
The MCP23008 based backpacks use 0x20 to 0x27
The LCDs that use PCF2116/PCF2119x chips use 0x3a or 0x3b
A few others LCD devices I've seen use 0x3a to 0x3f
i2c slave addresses will be anything but 0-7 as 0-7 is reserved for special functions.

--- bill

These are the LCDs I've been buying on Ali-Express. Not sure how long the link will be good for, but its been up a good while. The I2C modules they come with require 0x37 or they won't respond.

https://www.aliexpress.com/item/1602-16x2-HD44780-Character-LCD-w-IIC-I2C-Serial-Interface-Adapter-Module/32546958584.html

About the addressing, I guess I never really paid attention to this as I should have. Up until recently my experience with I2C devices was controlling audio potentiometer chips like the Dallas DS1882. The chips had three address pins you could choose to tie high or low, to make the chip respond to three bits of address. Granted it was shifted by one, and the upper nibble was (now that I look) fixed at 0101, and the LS bit was the read/write bit. So now that I think of it, even though I was thinking of it as addresses from 0-7, the truth is, the possible addresses for that chip were 0x50 through 0x5E. But I never paid attention to why the upper nibble was chosen. I guess there is some standard understanding among manufacturers as to what chip functions will have certain I2C addresses?

The photo on the aliexpress site shows a PCF8574 chip on the backpack and the backpack supports a configurable address.
I've never seen a PCF8574 that used address 0x37.
Perhaps you meant decimal 37 which is 0x25 ?
0x25 is in the address range for the PCF8474s I've seen.

The i2c spec is controlled by NXP: https://www.i2c-bus.org/specification/
There is a set of allocated addresses for specific devices.

For an i2c based clock/RTC module would use a DS3231 instead of a DS1307. The price is about the same and it is much more accurate. DS3231 modules on ebay (starting at just under $1.50 USD shipped) are cheaper than the price shown on that link you provided to the DS1307.

You do need to be careful with most of these low cost RTC modules in the they have a little charging circuit on them for using with a LIR2032. If you use a 2032 instead, you should cut a trace on the module to disable the charging circuit.
"charging circuit" is generous as it is only a resistor and a diode but a single trace cut disables it.

Although these days for not much more than the cost of an RTC module, you can get a esp8266 module with a powerful processor lots of flash and ram and built in wifi, and then use wifi to sync time using NTP and not even need an RTC at all.

--- bill

So, is there a problem? The thread indicates there probably isn't, so have you actually used the LCD successfully?

If not, use the I2C_Scanner program to discover the actual address.

bperrybap:
The photo on the aliexpress site shows a PCF8574 chip on the backpack and the backpack supports a configurable address.
I've never seen a PCF8574 that used address 0x37.
Perhaps you meant decimal 37 which is 0x25 ?
0x25 is in the address range for the PCF8474s I've seen.

Now that I look again, you are right... BUT.. the actual address is 0x3F! I'm not sure that makes sense either but because I believe the lowest bit is considered the R/(not)W bit. Since its a write only device, I'd think it should be ox3E if anything, but that's the address needed, so I guess the LCD library I'm using overrides the low bit. And now that you mention it, I see that the board does have places for jumpers (or zero hom SMD parts) to further configure the address. It means I can now drive multiple displays (up to 8) if I even needed to.

bperrybap:
The i2c spec is controlled by NXP: Specification - I2C Bus
There is a set of allocated addresses for specific devices.

Very interesting Thanks! So the likelihood of two devices with completely different purposes using the same addess range is fairly low, and like my DS1882 audio pot chips, they will usually allow the user to configure 3 bits within the lower nibble of the address.

bperrybap:
For an i2c based clock/RTC module would use a DS3231 instead of a DS1307. The price is about the same and it is much more accurate. DS3231 modules on ebay (starting at just under $1.50 USD shipped) are cheaper than the price shown on that link you provided to the DS1307.

You do need to be careful with most of these low cost RTC modules in the they have a little charging circuit on them for using with a LIR2032. If you use a 2032 instead, you should cut a trace on the module to disable the charging circuit.
"charging circuit" is generous as it is only a resistor and a diode but a single trace cut disables it.

More good inf.... thanks Bill!

Well that one I linked seems very convenient, and I probably wouldn't need even 1/10th of it current functions. But I'll investigate the S3231 too! For my projects, I just need a way to re-set the time if power has been lost for a while. Currently I detect eminent power fail, save the current time in EEprom, and retrieve it on power up. This is just to survive very typical power losses that only last minutes, without resetting to a stupid time like 12:00AM like most household devices do. But I'll never need millisecond accuracy for any current projects.

And yes... I've been meaning to check out those nifty esp8266 modules too, for other projects. I was wondering though (even though its another subject), can they be used without coding them, just using external commands? I'm thinking of the major hassles and expense getting any kind of FCC approval, should I ever use such a module in a product. From my research, if a module has already passed FCC muster with its existing code, and you don't alter its code, you may have a slightly cheaper path to approval.

jremington:
So, is there a problem? The thread indicates there probably isn't, so have you actually used the LCD successfully?

If not, use the I2C_Scanner program to discover the actual address.

No... no problem yet thanks.... I was just trying to avoid one. I have the LCD working, and was thinking of buying some I2C RTC modules that were also I2C based, where the seller did not know the address. From the discussion here, I've learned that the DS chip used in the RTC will definitely have a different address, and that my LCD's I2C module is actually configurable anyway. So it seems I can go ahead and buy those RTC modules without concern.

PeterPan321:
the actual address is 0x3F! I'm not sure that makes sense either but because I believe the lowest bit is considered the R/(not)W bit. Since its a write only device, I'd think it should be ox3E if anything, but that's the address needed, so I guess the LCD library I'm using overrides the low bit

The i2c addresses used by the Wire library are 7 bit with the LSB being the "r/w bit" and not considered part of the address.

Well that one I linked seems very convenient, and I probably wouldn't need even 1/10th of it current functions. But I'll investigate the S3231 too! For my projects, I just need a way to re-set the time if power has been lost for a while.

Just keep in mind that the 3231 is much more accurate. In real world tests people have reported seeing minutes/month inaccuracies on the 1307 vs a few minutes per year on the 3231.
The 1307 is very susceptible to temperature changes while the 3231 automatically internally compensates for temperature changes.
At this point in time, given the similar pricing I wouldn't use a 1307.

--- bill

bperrybap:
The i2c addresses used by the Wire library are 7 bit with the LSB being the "r/w bit" and not considered part of the address.
Just keep in mind that the 3231 is much more accurate. In real world tests people have reported seeing minutes/month inaccuracies on the 1307 vs a few minutes per year on the 3231.
The 1307 is very susceptible to temperature changes while the 3231 automatically internally compensates for temperature changes.
At this point in time, given the similar pricing I wouldn't use a 1307.

--- bill

That does surprise me for a Dallas chip! Over 20 years ago I was programming industrial modules that had some kind of Dallas RTC, And you could pick one up that hadn't been used in 1/2 a year, plug it into a programmer/monitor and request its time, and it would seldom be off by more than a minute! Maybe they were among Dallas's better offerings (I think they were built right into static RAM ICs, with the battery built in). But you'd think even the cheapest offerings by the same company 20 years later would be even better.

One thing though, and again for my project it probably wouldn't matter a great deal, but I'm becoming leery of analog chips that are likely based on China made clones. I recently had some China made TMP36 ICs from ebay, which despite being marked with authentic looking Analog Devices were really phonies, and both their accuracy and stability were awful. I thought it was my implementation, but after getting some authentic ones through Digi-Key, it was a night and day difference. I've had much better luck with China made digital parts, and even analog parts where precision didn't matter.

So that said, have you worked with some of those cheap China made DS3231 modules and found them to be up to snuff? Sure when we're talking $1.50 vs 95¢, I'll opt for the better one. But I'm sure such modules made with a guaranteed authentic part would be a bit more costly,

I've yet to get sold an I2C backpacked 1602 screen that didn't have address jumpers.

But to be fair, none of them came with any documentation whatsoever explaining them so it's easily overlooked.

INTP:
I've yet to get sold an I2C backpacked 1602 screen that didn't have address jumpers.

But to be fair, none of them came with any documentation whatsoever explaining them so it's easily overlooked.

Yep! It wasn't until Bill pointed it out to me that I pulled out my magnifier and saw the pads for address configuration. I've become so lazy! I must have searched a dozen times on Google just to find out what other's had discovered as far as their address, and once I found one that worked, it never occurred to me to look for such options. :frowning:

bperrybap:
The i2c addresses used by the Wire library are 7 bit with the LSB being the "r/w bit" and not considered part of
Just keep in mind that the 3231 is much more accurate. In real world tests people have reported seeing minutes/month inaccuracies on the 1307 vs a few minutes per year on the 3231.
The 1307 is very susceptible to temperature changes while the 3231 automatically internally compensates for temperature changes.
At this point in time, given the similar pricing I wouldn't use a 1307.

--- bill

So I found these 3231 modules dirt cheap on ali-express...

https://www.aliexpress.com/item/1pcs-DS3231-AT24C32-IIC-Module-Precision-Clock-Module-DS3231SN-for-Arduino-Memory-module/32819627537.html

If the recommended LIR2032 cell is included, even better. But if I use a standard non rechargeable cell, that's when I should cut the charging circuit parts, right?

PeterPan321:
If the recommended LIR2032 cell is included, even better. But if I use a standard non rechargeable cell, that's when I should cut the charging circuit parts, right?

Correct about the LIR vs CR batteries.
If you look closely in the photo you will see that the battery in the socket is in fact a CR2032 and not a LIR2032 so the charging circuit should be disabled.

With respect to the charging circuit,
If you look at the photo you can see a diode to the right of the 3231 chip. Then if you look really close you can see a trace from the top of side of the diode over to the positive pin on the battery, which is right by the SDA and SCL silkscreen labels. To disable the charging circuit, you simply cut that trace. You can also remove or break the diode if you don't care to ever use it.

I prefer the 3231 chip over the 1307, it can use a 400k i2c clock vs a 100k clock, and has the ability to provide temperature.
The 3231 modules also usually have an EEPROM on them for some nonvolatile storage.

--- bill

Hi,
Did you google i2c address lcd backpack

Tom.. :slight_smile:

bperrybap:
Correct about the LIR vs CR batteries.
If you look closely in the photo you will see that the battery in the socket is in fact a CR2032 and not a LIR2032 so the charging circuit should be disabled.

With respect to the charging circuit,
If you look at the photo you can see a diode to the right of the 3231 chip. Then if you look really close you can see a trace from the top of side of the diode over to the positive pin on the battery, which is right by the SDA and SCL silkscreen labels. To disable the charging circuit, you simply cut that trace. You can also remove or break the diode if you don't care to ever use it.

I prefer the 3231 chip over the 1307, it can use a 400k i2c clock vs a 100k clock, and has the ability to provide temperature.
The 3231 modules also usually have an EEPROM on them for some nonvolatile storage.

--- bill

Thanks! That will save me some "tracing" (Haw Haw! :wink: ) But then again those LIR versions of those cells are pretty cheap on ebay too. I'll have to think about it. The final project will be AC powered most of the time so maybe a rechargeable cell would be such a bad thing.

I guess my other concern these would be how to talk to this thing... always a concern when buying on ebay or ali-express. Will its I2C address be the same as the other Dallas chip? And I guess the DS1307 libraries won't work. But if all I need is the Dallas data sheet to program it, I could write my own support code, right? I really hate loading in whole libraries and bloating my projects with unneeded code. All I really need for my own project is to be able to set the time, and read the number of seconds since the current day started. I should have enough I2C helpers in the WIRE library I already pulled in for my LCD, right?

TomGeorge:
Hi,
Did you google i2c address lcd backpack

Tom.. :slight_smile:

I already had my LCD working, and knew its address. It was the RTC that I couldn't find info on, and I didn't realize I2C address ranges were both built into the Dallas chip, and were not in a conflicting range.

PeterPan321:
I guess my other concern these would be how to talk to this thing...

Just install a DS3231 library. There are few available in the IDE library manager.

bperrybap:
Just install a DS3231 library. There are few available in the IDE library manager.

Hmmm... This has happened quite a lot. I'm not sure why I often don't have libraries that I'm told are in my library manager. I don't even seem to have the "Time" library, and definitely don't have any libraries for specific RTC chips. I understand how to fish around for libraries and add them to the IDE, but I wonder if there is some feature within the IDE I've neglected to enable, that is supposed to connect with a larger cloud based library?