I2C device addressing

You can have input pins on each arduino, for 32 devices you will need five of them. You then short out a unique combination to ground on each device. Your code then reads these pins and so gives itself an address.