Communication between arduino uno and atmega32 is not working

So I have a complex system set up. There are two arduino unos and two atmega32. Now the two arduino are communicating through nRF24L01. The two atmega are communicating with the arduinos via UART. Now my communication starts from one atmega32. It sends some data to the arduino it's connected. This data is then send to another arduino and then to the second atmega. Now I'm sending a data like this : (1!123.456$) 1 is an ID, 123.456 is a float and it is between two delimiters ! and &. Now I can transmit this data from the first atmega to arduino and then second arduino. But when I try to transmit this data from the second arduino to second atmega and then try to read it back it doesn't work. I don't know what I'm doing wrong.

This is code for arduino:

/*
* Arduino Wireless Communication Tutorial
*     Example 1 - Transmitter Code
*                
* by Dejan Nedelkovski, www.HowToMechatronics.com
* 
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/


#include <SPI.h>
#include <stdlib.h>
#include <string.h>

#include "nRF24L01.h"
#include "RF24.h"

char text[30];
uint8_t indx = 0;
RF24 radio(7, 8); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};
char data;
char bdata;

void setup() {
  Serial.begin(9600);
  pinMode(0,INPUT);//RXD pin is set for INPUT
  pinMode(1,OUTPUT);
  radio.begin();
  //radio.openWritingPipe(address);
  radio.openWritingPipe(addresses[1]); // 00001
  radio.openReadingPipe(1, addresses[0]); // 00002
  radio.setPALevel(RF24_PA_MIN);
}
void loop() {
    if(Serial.available() > 0)
    {
      data = Serial.read();
    }

      if(data == 's')
      {
        Serial.println("here2");
        radio.stopListening();
        strcpy(text,"send");
        radio.write(&text, sizeof(text));
        while(1)
        {

          radio.startListening();
          uint8_t av;
          if (radio.available(&av)) {
            char tex[32];
            radio.read(&tex, sizeof(tex));
            for(int i = 0 ; tex[i] != '\0' ; i++){
              Serial.write(tex[i]);
            }
            tex[0]='\0';
          }


          if(Serial.available() > 0)
          {
              bdata = Serial.read();

              Serial.print(bdata);

              if(bdata == 'b')
              {
                data = 'z';
                break;
              }
          }
        }
          Serial.println("Came out");
      }
}

Inside radio.available() I'm transmitting the data received by the second arduino (1!123.456$) to the second atmega. Then when it is finished, I'm trying to read it back in Serial.available().

This is the code for atmega32:

#define F_CPU 1000000UL

#include<avr/io.h>
#include<avr/interrupt.h>
#include <stdlib.h>
#include <string.h>
#include <util/delay.h>

volatile int breakloop=0;

char text[30];
uint8_t strIndex = 0;

void sendChar(char c){
    while ( (UCSRA & (1 << UDRE)) == 0);

    UDR = c;//once transmitter is ready sent eight bit data
}

char receiveChar(){
    while ( (UCSRA & (1 << RXC)) == 0 );

    return UDR ;
}

ISR(INT1_vect)
{
    PORTA = 7;
    _delay_ms(100);
    PORTA = 0;
    _delay_ms(100);
    sendChar('b');
    breakloop = 1;
    GIFR = 0xFF;
}

int main(void)

{
    //DDRB = 0xFF;
    DDRA &= ~(1 << PINA0);//pin0 of portD as INPUT
    DDRA |= (1 << PINA1) | (1 << PINA2) | (1 << PINA3) | (1 << PINA7);
    int UBBRValue = 12;//AS described before setting baud rate 9600BPS, double transmission
    UBRRH = (unsigned char) (UBBRValue >> 8);
    UBRRL = (unsigned char) UBBRValue;
    UCSRA = 0x02;
    UCSRB = (1 << RXEN) | (1 << TXEN);    //Enable the receiver and transmitter
    UCSRC = 0b10000110;
    char k;
    int buttonPressed = 0;

    MCUCR = MCUCR & 0b11110011;
    MCUCR = MCUCR | 0b00001000;
    GICR = (1<<INT1);
    sei();

    while (1)

    {
        //sendChar('s');
        k='0';
        if(PINA & (1 << DDA0))
        {
            buttonPressed = 1;

        }

        if(buttonPressed == 1)
        {
            PORTA=2;
            _delay_ms(200);
            PORTA=0;
            sendChar('s');

            _delay_ms(10);

            while(1)
            {
                k = receiveChar();

                if(text[strIndex] == '

I hope my code is clear. If not, please let me know in the comments and I'll try to add further clarification. Can you please hint at any problems you see in my approach?

How can I make the atmega32's receive char wait until the data arrives from the arduino? It does not seem to wait.){

text[strIndex + 1] = '\0';

for(int q = 0 ; text[q] != '\0' ; q++){
                        sendChar(text[q]);
                    }

strIndex = 0;
                    text[0] = '\0';

} else strIndex++;

if(breakloop == 1)
                {
                    breakloop = 0;
                    break;
                }

}
            buttonPressed = 0;
        }

PORTA = 0b10000000;
        _delay_ms(100);
        PORTA = 0;

}

}


I hope my code is clear. If not, please let me know in the comments and I'll try to add further clarification. Can you please hint at any problems you see in my approach?

How can I make the atmega32's receive char wait until the data arrives from the arduino? It does not seem to wait.

You have said that the data (123.456) goes upto Arduino-2. How have you monitored the data? You have used hardware UART Port for communicating with the m32s; but traditionally, the UART port is engaged with IDE/Serial Monitor. I have seen people to using software UART Ports to communicate with exteranl UART-based devices.

You have an interesting project; but, it is a complex process if the m32s are considered. If you really want to make the whole system working, I would suggest you to repeat the project using 4 Arduinos (UNO). Every Arduino will have its own Serial Monitor which will help to debug the program.

I am surprised to see that you have configured the directions of the TX/RX lines -- why? They are automatically configured when the instruction Serial.begin(9600) is executed. Moreover, you have said that 1 is the ID; if so, your receiving program must be looking for this character first and then for the ! character. Why are you looking for s character? There are many inconsistencies in your program, and you need to begin the whole thing using SSS (Small Start Strategy) methodology.

Also posted at:
https://arduino.stackexchange.com/q/54971
If you're going to do that then please be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information. When you post links please always use the chain links icon on the toolbar to make them clickable.