Skip to content

Instantly share code, notes, and snippets.

@SyNeto
Last active October 1, 2017 04:16
Show Gist options
  • Save SyNeto/e499f78036ccbe541630d8bbb4d40a2e to your computer and use it in GitHub Desktop.
Save SyNeto/e499f78036ccbe541630d8bbb4d40a2e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import serial
import atexit
from datetime import datetime
ser = serial.Serial('/dev/tty.usbmodem1411', 9600)
while True:
current_time = ser.readline().decode('utf-8')
print(datetime.utcfromtimestamp(int(current_time)))
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 rtc;
void setup () {
// for Leonardo/Micro/Zero
while (!Serial);
Serial.begin(9600);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
}
void loop () {
DateTime now = rtc.now();
Serial.println(now.unixtime());
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment