兰博

[Training Camp] Mini network clock based on ESP32-C3 +1136228A

 
Overview

Usage

If you do not use the provided PCB, refer to the following hardware connection and software configuration solutions:
  • 1. Install and configure the ESP_IDF development kit.
  • 2. Connect the OLED module based on SSD1306 or SSD1315 to the IIC pin of the ESP32/ESP32-C3 development board (the program defaults to SDA 32 and SCL 33; the circuit board is SDA 4 and SCL 5; you need to modify it yourself when using the circuit board).
  • 3. Use USB to serial port tool to connect ESP32/ESP32C3
  • 4. Download the project file to the specified path. Make sure the file path is in English.
  • 5. Use the cd command to enter the project folder and enter idf.py set-target <chip model> to select the chip model for target compilation.
  • 6. Enter idf.py menuconfig to enter the project configuration menu, and configure the connected AP name and password under the example configure option.
  • 7. Enter idf.py build to compile
  • 8. Use the idf.py flash command for burning. The usage of this command is different on different platforms or hardware. For details, see the burning section of the esp_idf development document.

Operating mechanism

  • 1. This clock obtains time based on the SNTP protocol and uses the internal RTC to keep time. The time correction server comes from Alibaba Cloud. Since this clock relies on the RTC inside the chip, it does not have the characteristics of power failure. The time information will be reset after each power failure.
  • 2. The clock program contains three events and one task. The three events are WiFi connection event, WiFi disconnection event and SNTP synchronization event. Each of them is responsible for updating the system time and system status. The task is responsible for refreshing the OLED screen display content, running at a frequency of 1hz, and its task priority in freertos is 1.
  • 3. The SSD1315 driver is a simplified adaptation version created by me, which is adapted based on the IIC bus API of ESP32. All are thread-safe.
  • 4. When the clock is powered on, it will try to connect to the AP. After connecting to the AP, it will immediately send a request to the set SNTP server and try to correct the time. Subsequently, the time will be corrected regularly according to the set cycle. If the AP is disconnected when powering on or running, the program will try to reconnect to the AP every 5 seconds.

File structure

-esp32clock

            -build<output directory>

            -components<component directory> 

                               - SSD1315 <SSD1315 driver>

                               - SNTP_APP <SNTP service program>

                               - image <display data>

            -main<main function directory> 

UA6DYKnBNHHqn3c9VgqygdDGZFv29mnN1zpWP58z.png

Personalized configuration

  • Configure WiFi access point, see above.
  • Modify the SNTP clock cycle and modify the SNTPSYNCCYCLE macro definition value in {PROJECT_DIR}/main/main.c. The default is 10 minutes.
  • Modify the OLED display and modify the value of .display_mode in line 24 of {PROJECT_DIR}/components/SSD1306/SSD1315.c (INVERSE_DISPLAY: inverted display, NORMAL_DISPLAY: normal display).

gSfWZUMJi9rQgTRtQlU1kDP7qsb4mqmLmbUQbnwx.jpegkPLzrWJh0e3nzIkPkpfAgk6xk3LP5W9Zp341A2wu.jpeg

  • Modify the SNTP server and modify the macro definition of NTP_URL in {PROJECT_DIR}/components/SNTP_APP/include/SNTP_APP.h.

Known issues

  1. The soldering positions for the PCF8563 RTC chip and its components were reserved, but due to subsequent changes in the design plan, the chip was not used.
  2. Since the SNTP notification callback function does not return the status of time adjustment failure, the SNTP status flag can only reflect that the time has been corrected by SNTP. For specific judgments, refer to the most recently updated hours at the top.

Version Information

2021/10/23 First version released

2021/10/28 Hardware bug fixes

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-24 20:59:47

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号