IoT Guide

Raspberry Pi Time Sync

Raspberry Pis do not have a Real Time Clock (RTC) battery. If they lose internet connectivity, time drifts. Use this script to verify time against our API upon boot or for magic mirror projects.

PYTHON
import requests
import time

# Loop to fetch time every minute
while True:
    try:
        r = requests.get('https://time.now/developer/api/timezone/America/New_York')
        data = r.json()
        print(f"Display Time: {data['datetime']}")
        # Logic to update LED Matrix or LCD goes here
    except:
        print("Network error")
        
    time.sleep(60)

Why use Time.Now for IoT?

  • Ideal for MagicMirrors
  • Verifies network connection
  • Provides raw offsets
API Reference View All Guides

Free widgets for webmasters:

Free Analog Clock Widget | Free Digital Clock Widget | Free Text Clock Widget | Free Word Clock Widget | Free Countdown Widget