Clock ATtiny84

Hello at all,

I'm designing a PCB for using 5 TCS230 color sensors with an ATtiny84 as a slave via I2C. The master will be an Arduino Mega 2560.
I will have to use this PCB in a Robot, so the speed is a significant factor. I'm planning to use I2C in fast-mode, so 400kHz.

The first question is, the ATtiny has an 8MHz internal clock, should I use it (is it enough??) or it's better to implement an external 16MHz clock for my application?

The second, to put the I2C in pull-up I chose 1k8 Ohm for the 5V part, 1k2 Ohm for the 3.3V part. Are these values correct or too low / high?
(I calculated them based on the following websites:
https://www.microchip.com/forums/m1011861.aspx

http://cache.nxp.com/docs/en/user-guide/UM10204.pdf?fsrch=1&sr=3&pageNum=1 )

Thank you in advance.

I would not use tiny85 tiny84 like this. Its just one more, or in your case, 5 more things to get wrong. 5 more sketches to debug. With mega you have plenty of pins, so why this idea?

Why would a robot need 5 colour sensors?

I have to follow a complex line and now I'm using these 5 sensors. They are excellent at doing this, but the problem is that they are far from Arduino and I would like to significantly reduce the number of cables passing through the robot.
So after a lot of research, I concluded by considering ATtiny84 as the best option. There are also many different tutorials on this microcontroller, like this:

where it is shown how to use ATtiny exactly as I would like to do.

What problems are you talking about? What sketches to debug?

The problems of having multiple sketches on multiple MCU. Each tiny will have its own sketch uploaded, plus the sketch on the mega. The tiny sketches will be 99% identical but I guess you will configure each with a different i2c address, so 5 sketches to re-upload each time you fix a bug. And finding bugs will be more difficult because you have to figure out if it's in the sketch on the mega of the sketch on the tiny.

At the cost of 1 extra wire to each sensor, you could use a pcf8574 at each sensor to drive the channel select and output enable pins on the sensor. The sensor outputs can all go back to the same pin on the mega.

I know there exist I2C color sensors (in fact, I remember using one in something - don't recall the part number though) - I don't think they let you choose enough possible addresses to do it without an I2C multiplexer, but I don't think that would be that hard either.

That said, doing it with tinies as you propose also shouldn't be hard... assuming the Wire library included with my ATTinyCore (which is a special version that chooses appropriate code for the hardware in question, and so works on parts like the t84 that have a USI instead of hardware I2C) actually works in slave mode. I do not know the extent to which it has been exercised - I suspect "not very much".

As far as using DrAzzy's ATTinyCore, with the ATtiny84 as slave, it works just fine. I use an ATtiny84 as an I2C slave signal generator and control it with a 386PB as controller. Ask if you need help.

Doing a quick check on the TCS230 module pin requirements, it seems you basically need 3 pins per module (if you hard wire the frequency percentage). I assume you can parallel connect S0 and S1 which means you need 5 additional pins - one per module - a total of 7, which is exactly what is available with the ATtiny84 (while using I2C). That also assumes you are externally clocking the ATtiny84. I use a 16MHz resonator (they are tiny).

An interesting project. I also just learned something new - I did not know about the pulseIn() function for Arduino IDE.

Keep us updated.

Edit: I use the generally recommended 4K7 pull-up resistors for the I2C bus. (Why both 5V and 3.3V?).

Willem.