ATtiny85 using external reference and I2C communication

Hello,

A little background before I proceed with my question.

I am designing a universal charger for NiMh battery type, my design incorporates an ATtiny85 as a dedicated controller for the constant current source and it will communicate with an ATmega328P(which in the main controller for the user interface and runs a -dV termination algorithm for charge termination) over an I2C bus.

My application requires to have a precision external reference on the ATtiny85 since the internal reference isn't good enough and I am only getting good results when using the external reference, the Aref and SDA pin on the ATtiny85 is same, when the charger circuit is turned ON the Atmega328P needs to pass on a current setpoint to the ATtiny85, once the setpoint is passed on to the ATtiny85 then there is no further communication between the microcontrollers and both work independently, is it possible that I use a relay on the ATtiny side in order to disconnect the SDA pin from the I2C bus once the communication has ended and attach a precision reference to it after calling

analogReference(EXTERNAL) command?

has anyone ever tried something of this nature? is it ok to first use the SDA pin for communication on the I2C bus and then change it functionality over to the analog external reference?

I haven't put together a code for it yet, I have separate code running on the ATmega328p and ATtiny85 which I will extend by adding the I2C function, just though it'd be better to take some advice before I implement it.

Thanks!

I think that should work. There are IC's you can use (I2C or analog multiplexers) that are designed for this sort of thing and won't have all the problems that relays have.

Any particular reason you are avoiding the ATtiny84(A)?

Thanks for being as helpful as ever DrAzzy, I will look up for these analog multiplexer IC and find a suitable fit.

Cheers!

Thanks for the response Coding Badly, no there isn't any reason to be honest, it's just that I have spent a lot of time trying to implement the PID current controlling on the ATtiny85, I initially tested it on an Arduino but never knew it could be so much trouble just trying to get it to work on the ATtiny85, it took some effort, since I am still in testing phase for this charger I really don't want to go through the process of building another board with the attiny84 since I have to put the circuit on perf board as the design doesnt work well with loose connectionson the bread board. Maybe at a later stage I can move over to the ATtiny84, I am just not getting enough time to work on this project so just trying short cuts at the moment, like DrAzzy said hope I can get away with this and use my existing ATtiny85 board to do the testing.

Just set up a small experiment and tried this out with a relay and it seems to work just fine, thanks again DrAzzy.