Serial Commands with data after it

Hi there!

I am making a small sketch that will adjust a RTC using the serial port and Visual Studio.
Now i need the arduino to wait for serial data, then put the intire line into a string to then check if it is a valid command.
Now that isn’t that hard, but i need to add data after it that will actually contain the time.

My command will be like this: “H:[here we write what hour it is now]”

Now i want the arduino to detect that is means hours and then write the data that was added (the time) to get written into an integer.

How can i do this?
Any help would be welcome!

#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

int RTC_Configured;
String serialData;

void setup() {
  // put your setup code here, to run once:
    Serial.begin(9600);
    display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
    Wire.begin();
    RTC.begin();

  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC_Configured = 1;
  }
}

void loop() {
  // put your main code here, to run repeatedly:

  //Here i want the code to check if any serial data has arrived, check if it is a command and write the data into an integer
  
  if (RTC_Configured != 1) 
  {
    DateTime now = RTC.now(); 
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println(); 

    display.clearDisplay();
    display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("Tiny RTC Demo");

  display.setCursor(0,8);
  display.print("Date: ");
  display.print(now.year(), DEC);
  display.print("-");
  display.print(now.month(), DEC);
  display.print("-");
  display.println(now.day(), DEC);

  display.print("Time: ");
  display.print(now.hour(), DEC);
  display.print(":");
  display.print(now.minute(), DEC);
  display.print(":");
  display.print(now.second(), DEC);

  display.setCursor(0,56);
  display.print("Gemaakt door: Sander");
  
  display.display(); //Je MOET display.display doen of anders zal hij niks laten zien
    delay(100); //Vaker dan 1 keer bijwerken om er zeker van te zijn dat de tijd op het beeldscherm klopt
  }
  else
  {
    display.clearDisplay();
    display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("Use the Tiny RTC Demo");
  display.println("Configurator to set");
  display.println("the clock!");
  display.display();
  }
}

After your Arduino receives the serial bytes, parse them.

I am still not able to do it even after reading the post and trying for a few hours :frowning:
All i need to do is get the line from the serial monitor, get the first 5 characters (since these are known to not contain any numbers, just what it is) and the rest should be put in a integer.

Im slowly wanting to pull my hair out of my head >.<

I have solved the issue by no longer sending data with a command and then data.
What i have done is it waits for data and when it receives it it puts it in a integer.
After that it does a delay of 10 miliseconds and then it will receive the next command from the program until it has all the data it needs and then it writes it to the RTC.

Just wrote this in case somebody else is stuck on this then this might be an idea!