Get Real Time Clock from computer OpenSDA USB

> Blockquote

 #include "mbed.h"
#include "TextLCD.h"
// Host PC Communication channels
Serial pc(USBTX, USBRX); // tx, rx
// I2C Communication
I2C i2c_lcd(PTE0,PTE1); // SDA, SCL

// LCD instantiation 
TextLCD_I2C lcd(&i2c_lcd, 0x4E, TextLCD::LCD16x2);
int main() {   
        Timer t;
     time_t seconds = time(NULL);
    char buffer[32];
    strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
    lcd.printf(" %s", buffer);
    //lcd.printf("Hello World!");

Show 12:00 AM actually. Is there any way to initialize time via internet?

Hi there,
I don’t understand what do you want because in the title you write about USB, and at the end of your post you write about internet.

  • Over internet, if you have a Network Interface, you can use a NTP server.
  • Over USB, you can send the time in seconds via terminal.
  • With some limitations is also possible to use “Compilation time” as a starting time
    printf("Time is: %s %s\n",__TIME__,__DATE__);
  • Probably most fun is Radio clock, but it takes some time for synchronization.

BR, Jan