How much expander to wire with I2C-Bus and Ardiono mega2560 ?

hi all,

Arduino mega 2560 has lot a lot of pins , but Not ENOUGH FOR ME :grin:

Its used here with model railway.

Just now its connected with

  • 1 x 20x4 LCD-Display
  • 1 x mcp23017
  • 1 x Servo-/LED-Expander PCB9648 that works sufficently

5V-Technology is used here uniquely for wiring

for an automated running of trains some more inputs and outputs would be needed,

i.e. 8 inputs and 8 outputs in summary 16 pins what could be done with an additional mc23017.

I guess, an addiontional I2C-Address would not be a problem,

but can that all be handled by Arduino ?

What is that? Link please.

Not sure what you're asking. The Mega has around 70 IO pins. And plenty of memory if you use it wisely.

Ok, sorry, PCA 9685 was meant..:wink:

with the PCF8574P you can have 64x8 pins GPIO both diraction with all interapt on one pin
so you can chck ISR what happend
THIs is most used in Scale railway systems
there is also a expander where you can expand to 32x64x8 pins

how ?

on datasheet there are shown 8 pins, then to manage maximal 64

Pin adresses by A0 To A2 and only 1 I2C-Adress ?

Guess, there is a way to switch for input or output every single Pin ?

meanwhile i found an article where is written at PCF8574 GPIO Extender - With Arduino and NodeMCU : 15 Steps - Instructables

“These modules run on the I2C bus, and if daisy-chained you can connect upto 8 of these devices in a project. Each device will give us an additional 8-bits of GPIO enabling 64 GPIOs in total.”

So, that board will not be better than mcp23017 except mcp23017 is only for 5V-issues

against PCF8574 with a wide range of voltages…

There is 3 Address pins so you can have 8 combinations ; this equates to 8 of the PCF8574P expanders on a single I2C bus, so 8 * 8 = 64 total IO's

Address bits are set by pulling the address pins HIGH or LOW as seen in table 7.1.1 of the datasheet.

ok, for the mc23017 is written

“The MCP23017 has a base I2C address of 0x20 to 0x27

, which can be changed to one of seven other addresses” by soldering bridges..

that the same thing or not ?

Bild

Yes, The MC23017 Works in the same way ; Three address pins to allow 8 devices on a single I2C bus, In the MC23017 case address 0x20 to 0x27

As PCF8574P works over a wide range of supply voltages,

what about the I2C-LEvel ?

Would there a level-shifter be needed (as is with SX1509 in 5V-Peripherie) ?

The I2C voltage compliance range would be the same as the supply range for the PCF8574P. Since you are running a 2560 at 5V it will run with the 5V I2C bus fine.

No need for level shifting on the PCF8574P or others within that same family range that run over the 2.5V to 5.5V range for your 5V rated stuff.

ok, thank your very much for infos..have good time !

@lupus51

Only if you remove the pull-up resistors.

Just now its connected with
1 x 20x4 LCD-Display

How much GPIO is taken up by that?

How much more do you need?

LCD-Display only needs I2C and 5V-Power-Supply, no other Pins

of Ardi used

Additionally i need maximal 8 PIN’s for Input and 8 PIN’s for OUTPUT..

think 1 additional MC23017 will do the job.

How many pins does a Mega have? Why don't you use some of the free ones?

Seventeen posts in and no schematic or, even a block diagram?

2 Likes

@lupus51 Since there's a lack of connection details, we're free to assume stuff. My assumptions:

  • you're going to wire leds, buttons, etc. to all the other 2560 I/O, hence you think you need an expander
  • you're not even really aware of how to use an MCP23017, nor that you can wire 8 together, but you've 'heard stuff, like it can be done'.

So yeah, lots to unpack there. Here's some random commentary on my random assumptions.

  • You can wire 8 23017 together, if you a) set all the addresses uniquely, b) don't have that LCD on the I2C bus at a conflicting address, c) can wire your power appropriately for the 8 devices, and d) remove the pullups on most of your MCP23017 expanders(assuming you're using them, not bare-designing a board).
  • You haven't indicated that you're aware that the Mega2560 has power limitations, or what they are, or that they're not overwhelmed already with your planned LED attachments, etc.

Now, all of the above may be irrelevant, but that's why we press for more details. So we can either assess that you're capable of 'things', or that we need to help you deal with more fundamental issues on your project.

One MR to another, I'd suggest you give us a much more detailed indication of what it is you're planning to do. There's plenty of help available here, MR specific and otherwise, but to gain full advantage, you have to engage us. The value of the answers is proportional to the quantity and quality of the input info. Ball's in your court.

hi, if i would have free pins left, i would Not think of expanders..why should ?

its Not all in planing

but items like my post #1 ARE RUNNING SUCCESSFULLY,

an additional expander should enable me to add and control 2 railway-blocks

after modifying the tracks plan in front of nearly unreachable switch inclusive

adding smd-led-signals !

:roll_eyes:

  • Why don't tell us how many GPIO pins you need ?

  • A schematic would explain to us what you are doing and would be an invaluable documentation tool for you in the future.