Soutenez Time.now : Rejoignez notre Plan Premium pour une expérience sans publicité ! Soutenez-nous : Passez Premium sans pub !
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)

Pourquoi utiliser Time.Now pour IoT ?

  • Ideal for MagicMirrors
  • Verifies network connection
  • Provides raw offsets
Référence API Guide d'installation