clock with RTC and setting via wifi/buttons

Hi everyone,
I am trying to make a clock with RTC(DS1302) and setting via Wi-Fi / buttons(if wifi is not available). I would like to use arduino as main chip and esp8266 to set rtc over ntp server. (esp8266 would only turn on when setting the clock); I don't know how to send the time from esp8266 to arduino so that it is stored in three variables [hours, minutes, seconds]. I thought to use Serial or I2C. by the way, the code for operating the RTC and setting it using buttons is complete.

Take a look at Serial input basics - updated for ideas on how to deal with serial data and parse once it has been received

Thank you very much, it helped me.
I solved it lt like this (probably not the most elegantly :wink: ):

#include <SoftwareSerial.h>
SoftwareSerial serial(12, 13);

const byte numChars = 32;
char receivedChars[numChars];   // an array to store the received data
boolean newData = false;
int h;
int m;
int s;
int x;

void setup() {
  serial.begin(9600);
  Serial.begin(9600);
  Serial.println("Receiver is ready");
}

void loop() {
  recvWithEndMarker();
  showNewData();
}

void recvWithEndMarker() {
  static byte ndx = 0;
  char rc;

  while (serial.available() > 0 && newData == false) {
    rc = serial.read();

    if (rc != '\r' && rc != '\n') {
      receivedChars[ndx] = rc;
      ndx++;
      /*if (ndx >= numChars) {
        ndx = numChars - 1;
        }*/
    }
    else if (rc == '\r') {
      x++;
      if (x == 1) {
        h = atoi(receivedChars);
      }
      else {
        m = atoi(receivedChars);
      }
      receivedChars[ndx] = '\0';
      ndx = 0;
    }
    else if (rc == '\n') {
      s = atoi(receivedChars);
      receivedChars[ndx] = '\0';
      ndx = 0;
      newData = true;
      x = 0;
    }
  }
}

void showNewData() {
  if (newData == true) {
    Serial.print("This just in ... ");
    //Serial.println(receivedChars);
    Serial.print(h);
    Serial.print(':');
    Serial.print(m);
    Serial.print(':');
    Serial.println(s);
    newData = false;
  }
}