Exercise 9: RTC and data logging

Introduction

The ESP32 has a real time clock implemented on chip. This will however only work as long as the ESP32 is powered. It may therefore be interesting to employ and external RTC like the DS1307, backed up with a battery, to keep time even when the ESP32 is powered off or in deep sleep mode.

Getting the current (GMT) time from the internet is easy when using the ntptime module. We can make use of this to setup our RTC with the correct time.

Exercise 1: Set the ESP32 RTC

Ask the user for the current date and time and set the real time clock in the ESP32 correspondingly. Read back the time a little late and print it out.

Exercise 2: Set the DS1307 RTC

Do the same thing with the DS1307 RTC

Exercise 3: Get the time from the Internet and setup the RTC

Write a function that connects your ESP32 to the Internet through WiFi. Use the station interface to do so. Find out the IP address the ESP32 can be reached at. Setup system time and print it.

-- Uli Raich - 2020-05-06

Comments

Edit | Attach | Watch | Print version | History: r10 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2020-05-06 - UliRaich
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback