Electronic – arduino – How to connect ATTiny45 to Arduino via serial/spi/i2c and send data

arduinoattinyi2c

I am trying to create a smart alarm system for my house. I want to have one arduino as the master and several other AtTiny's as slaves to collect data as temperature, moisture, gas concentration, opened doors etc.

How do I connect multiple wired AtTiny's to a master Arduino? Which is the most clever way to communicate between them ? I have read that AtTiny's do not support spi or i2c but you can "hack" it somehow.

EDIT: the distance between the master and the slave can be 1 to 10 meters.

Best Answer

If you happen to use those ATtiny that do not have hardware support of SPI or I2C, you can likely implement that in software, assuming you wont have any CPU-heavy processing running on the ATtiny (which is typically the case for mere sensor reading). That said, except for the 6-pins ones, most ATtiny's do have hardware support for both I2C and SPI (see product selector).

Choosing between I2C and SPI, I would go for the former given the multiple slave setup and the limited number of pins of the ATtiny (2 pins needed for I2C and 4 for SPI).