#!/usr/bin/env python3 # # Vendor:Product ID for Raspberry Pi Pico is 2E8A:0005 # # #Program syncRTC_pi.py #By D@CC #On 2021 E May 19 #Article: 164.html selectCode 08 #uSD: none # #Functions Used: # serial.Serial() # s.write() # serial.Serial() # #Source: https://forums.raspberrypi.com/viewtopic.php?f=146&t=300275#p1810708 from serial.tools import list_ports import serial, time picoPorts = list(list_ports.grep("2E8A:0005")) if not picoPorts: print("No Raspberry Pi Pico found") else: picoSerialPort = picoPorts[0].device with serial.Serial(picoSerialPort) as s: syncMSG = 'T'+str( int(time.time()) ) s.write(bytes(syncMSG, "ascii")) with serial.Serial(picoSerialPort) as s: syncMSG = 'T'+str( int(time.time()) ) s.write(bytes(syncMSG, "ascii")) print( "Raspberry Pi Pico found at "+str(picoSerialPort) ) print( "Time sync epoch USB MSG: "+syncMSG ) # source: https://www.raspberrypi.org/forums/viewtopic.php?t=301502 # Note: needs >>> python -m pip install pyserial on the Pi #/syncRTC_pi.py