Advertisement
MrLunk

Raspberry Pi Pico W (wifi) Clock with NTP time synchonisation at Midnight.

Feb 12th, 2023 (edited)
955
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | Source Code | 0 0
  1. # Script by: Peter Lunk
  2.  
  3. """
  4. This MicroPython script is for Raspberry Pi Pico W (Wifi) device
  5. that connects to a Wi-Fi network and synchronizes its time with
  6. a NTP (Network Time Protocol) server.
  7. The script first sets up a connection to the Wi-Fi network using
  8. the specified ssid (network name) and password, and then sets
  9. the device's time using the ntptime.settime() function.
  10. The device continuously retrieves the current time from internal
  11. clock and displays it along with the current date and day of the
  12. year on the serial monitor every second.
  13. The script synchronizes the time with NTP every day at midnight.
  14. """
  15.  
  16. import network
  17. import socket
  18. import time
  19. import struct
  20. import ntptime
  21. from machine import Pin
  22.  
  23. led = Pin("LED", Pin.OUT)
  24.  
  25. x = 1
  26. Hour = ""
  27. Minute = ""
  28. Seconds = ""
  29. Maanden = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Okt","Nov","Dec"]
  30. WeekDagen = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]
  31.  
  32. ____________________________________________________
  33. Looking for the final full script ?
  34. Link:
  35. https://github.com/mrlunk/Raspberry-Pi-Pico
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement