Send sensor data from atmega328 to another atmega328

Hey guys..
I am using an atmega328p with an ir sensor to measure the rpm of a gear. Since there are two gears in motion I have used 2 atmega328p to measure the rpms respectively using interrupt.
I need the ratio of the output of both the sensors on a third atmega328 but how do I transfer the sensor output to the atmega328p?

Please help

(deleted)

Yeah..I successfully tried it for a pair using SPI but I was doubtful whether it would transfer the data while simultaneously counting the rpm with missing any value.

Why were you doubtful? You don't think a 16MHz microcontroller can handle SPI comma and watching an interrupt signal at the same time? Why not? Are you having some trouble with it?

My main aim is to get the values of both the gears simultaneously.
I tried using both the interrupts together which would not give me even close values and since I'm new to this I dont have much of an idea why.

I tried using both the interrupts together which would not give me even close values and since I'm new to this I dont have much of an idea why

One Arduino can do everything. Post the code and wiring diagram for an Arduino that reads the RPM from one gear, and we can help you increase that functionality.

Please read and follow the instructions in the "How to use this forum" post.

int NbTopsFan; int Calc; 
 
//The pin location of the sensor
int opto = 2;

typedef struct{
 
//Defines the structure for multiple fans and 
//their dividers 
char fantype;
unsigned int fandiv;}
fanspec;
 
//Definitions of the fans
//This is the varible used to select the fan and it's divider,
//set 1 for unipole hall effect sensor
//and 2 for bipole hall effect sensor
fanspec fanspace[3]={{0,1},{1,2},{2,8}}; char fan = 1;

  
void rpm()
//This is the function that the interupt callsṀ
{ NbTopsFan++; }

 
//This is the setup function where the serial port is initialised,
//and the interrupt is attached
void setup()
{ 
pinMode(opto, INPUT);
Serial.begin(9600);
attachInterrupt(0, rpm, RISING);}
 
void loop ()
//Set NbTops to 0 ready for calculations
{ NbTopsFan = 0;
  
 
//Enables interrupts
sei();
 
//Wait 1 second
delay (1000);
 
//Disable interrupts
cli();
 
//Times NbTopsFan (which is apprioxiamately the fequency the fan 
//is spinning at) by 60 seconds before dividing by the fan's divider
Calc = ((NbTopsFan*60)/fanspace[fan].fandiv);

//Prints the number calculated above
Serial.print (Calc, DEC);
Serial.print (" rpm\r\n");
}

This is the code for one sensor with best accuracy that i used.
Connections:

Sensor ----- Arduino
VCC ----- VCC
GND ----- GND
OUT ----- PIN 2 (INT 0)

Why use two ATmega328? Can't just one monitor both sensors? Then you don't need any data communication between MCUs.

There are lots of problems with your RPM code:

  1. Variable shared between interrupts and main code must be declared volatile
int NbTopsFan; int Calc;
  1. You should NOT be doing this except under very special and limited circumstances, like making a copy of the variable NbTopsFan:
//Disable interrupts
cli();

Serial.print() depends on interrupts!

  1. To monitor a second fan you need to another interrupt, e.g. external interrupt 1 on pin 3.