My project requires to reconnect to an I2C bus as a slave. I can't reset my ATTiny physically because I2C + my project + a pin to trigger the reset isn't possible due to the limited amount of pins available on the ATTiny85. I searched the reference and different forums. If there was an answer to my question, I couldn't find one.

Thanks in advance.

(I want to try to make a plug-and-play kind of experience with a product. I want the chip to join with a defined address (100 or so), get a new address from the master and then reconnect to the I2C bus).

  • A jump to 0 can "fake" a reset, but no guarantees that it does what you want. – Ignacio Vazquez-Abrams Nov 3 '17 at 22:04
  • I considered that before but i'm not sure if it stops the i2c connection aswell – PolygonGraphics Nov 3 '17 at 22:11
  • Or you could use the watchdog. – Ignacio Vazquez-Abrams Nov 3 '17 at 22:12
  • The Watchdog works perfectly. I had to use modified code that works with the ATTINY that I found on a Blog. bigdanzblog.wordpress.com/2015/07/20/… – PolygonGraphics Nov 4 '17 at 11:59
  • USI is used to implement I2C on an ATtinyX5. The I2C address is not a hardware register instead this is done in software. It easy both to change address but also listen for several address. Please read the library source code and USI hardware manual for further details. – Mikael Patel Dec 4 '17 at 7:02

You only need to reinit the I2C slave.

The TinyWireS lib I found lets you just call TinyWireS.begin() with the new slave address. Though it doesn't have a way to stop the I2C connection. But the lib is hackable enough that with the ATTiny's specsheet you can add an end() to it.

However I believe that it may be better if the newly connected ATTiny acts as a master first and requests a free address from a known fixed slave acting as a dhcp server.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.