Instructing ChatGPT to generate code
In this section, we will request ChatGPT to update the previous code generated in Chapter 11 to implement the Wi-Fi access logic. You can instruct ChatGPT to work on the previous code and add internet access requirements:
Hi, ChatGPT
Please refer to the following code, maintain its current structure and style, and support the following
additional requirements.
Requirements:
Wi-Fi access: Use the pre-provisioned SSID and password to access Wi-Fi. The SSID and password are stored in the
Platformio.ini file.
Normal condition: The ESP32 receives a valid IP address. It then pings a public internet destination and syncs with an NTP server to get the
current time.
Abnormal condition: If the ESP32 fails to obtain a valid IP address, the ESP32 LED D4 (IO12) will turn on as an indicator of Wi-Fi connection failure. The buzzer will beep, and the system will retry three times
before rebooting.
Platformio.ini File:
Create...