Posts

Showing posts from March, 2026

RTC and LCD - how the code works

Image
  What's Happening in the Code Initialization: Sets up I2C communication on GPIO21 (SDA) and GPIO22 (SCL) Scans for connected devices to verify connections Initializes the LCD and turns on backlight Checks if RTC is working and sets time if it lost power Main Loop: Every 500 milliseconds, reads current time from RTC Converts UTC time to UK time (automatically handles GMT/BST switching) Updates LCD only when values change to reduce flicker Prints to serial monitor for debugging UK Time Zone Logic The code automatically figures out if Britain is in GMT or BST: BST starts on the last Sunday of March at 1:00 AM UTC BST ends on the last Sunday of October at 1:00 AM UTC Outside these dates, it displays GMT Display Format Line 1: Shows time in HH:MM:SS format (centered) Line 2: Shows BST/GMT indicator with date (e.g., "BST Mar 15 2024") Key Features Real-time accuracy using DS3231's temperature-compensated crystal Automatic  timezone  adjustment for UK Effici...