From 12d9729838dc5a25db090474836afc4ed76ec13e Mon Sep 17 00:00:00 2001 From: Zhentao-Lin <173039613@qq.com> Date: Mon, 1 Jul 2024 14:50:50 +0800 Subject: [PATCH] Update Sketches. --- C/Sketches/Sketch_01.1_Blink/Sketch_01.1_Blink.ino | 6 +++--- .../Sketch_02.1_SerialToSerialBT.ino | 3 ++- .../Sketch_02.2_BLE_USART/Sketch_02.2_BLE_USART.ino | 7 +++---- .../Sketch_03.1_SDMMC_Test.ino | 2 +- .../Sketch_04.1_WiFi_Station.ino | 2 +- .../Sketch_04.2_WiFi_AP/Sketch_04.2_WiFi_AP.ino | 2 +- .../Sketch_04.3_AP_Station.ino | 2 +- .../Sketch_05.1_WiFiClient.ino | 2 +- .../Sketch_05.2_WiFiServer.ino | 5 ++--- .../Sketch_06.1_CameraWebServer.ino | 13 +++++++------ .../Sketch_06.2_As_VideoWebServer.ino | 4 ++-- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/C/Sketches/Sketch_01.1_Blink/Sketch_01.1_Blink.ino b/C/Sketches/Sketch_01.1_Blink/Sketch_01.1_Blink.ino index 8904766..df3c1b7 100644 --- a/C/Sketches/Sketch_01.1_Blink/Sketch_01.1_Blink.ino +++ b/C/Sketches/Sketch_01.1_Blink/Sketch_01.1_Blink.ino @@ -2,7 +2,7 @@ * Filename : Blink * Description : Make an led blinking. * Auther : www.freenove.com -* Modification: 2020/07/11 +* Modification: 2024/06/18 **********************************************************************/ #define LED_BUILTIN 2 // the setup function runs once when you press reset or power the board @@ -13,8 +13,8 @@ void setup() { // the loop function runs over and over again forever void loop() { - digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) + digitalWrite(LED_BUILTIN, HIGH); // turn the LED off (HIGH is the voltage level) delay(1000); // wait for a second - digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW + digitalWrite(LED_BUILTIN, LOW); // turn the LED on by making the voltage LOW delay(1000); // wait for a second } diff --git a/C/Sketches/Sketch_02.1_SerialToSerialBT/Sketch_02.1_SerialToSerialBT.ino b/C/Sketches/Sketch_02.1_SerialToSerialBT/Sketch_02.1_SerialToSerialBT.ino index 1732ad5..9d48066 100644 --- a/C/Sketches/Sketch_02.1_SerialToSerialBT/Sketch_02.1_SerialToSerialBT.ino +++ b/C/Sketches/Sketch_02.1_SerialToSerialBT/Sketch_02.1_SerialToSerialBT.ino @@ -2,7 +2,7 @@ Filename : SerialToSerialBT Description : ESP32 communicates with the phone by bluetooth and print phone's data via a serial port Auther : www.freenove.com - Modification: 2020/07/11 + Modification: 2024/06/19 **********************************************************************/ #include "BluetoothSerial.h" @@ -12,6 +12,7 @@ void setup() { Serial.begin(115200); SerialBT.begin("ESP32test"); //Bluetooth device name Serial.println("\nThe device started, now you can pair it with bluetooth!"); + Serial.println("Hello!"); } void loop() { diff --git a/C/Sketches/Sketch_02.2_BLE_USART/Sketch_02.2_BLE_USART.ino b/C/Sketches/Sketch_02.2_BLE_USART/Sketch_02.2_BLE_USART.ino index 348d2ca..c7bc6c5 100644 --- a/C/Sketches/Sketch_02.2_BLE_USART/Sketch_02.2_BLE_USART.ino +++ b/C/Sketches/Sketch_02.2_BLE_USART/Sketch_02.2_BLE_USART.ino @@ -2,13 +2,12 @@ Filename : BLE_USART Description : Esp32 communicates with the phone by BLE and sends incoming data via a serial port Auther : www.freenove.com - Modification: 2020/07/11 + Modification: 2024/06/19 **********************************************************************/ #include "BLEDevice.h" #include "BLEServer.h" #include "BLEUtils.h" #include "BLE2902.h" -#include "String.h" BLECharacteristic *pCharacteristic; bool deviceConnected = false; @@ -31,7 +30,7 @@ class MyServerCallbacks: public BLEServerCallbacks { class MyCallbacks: public BLECharacteristicCallbacks { void onWrite(BLECharacteristic *pCharacteristic) { - std::string rxValue = pCharacteristic->getValue(); + String rxValue = pCharacteristic->getValue(); if (rxValue.length() > 0) { rxload=""; for (int i = 0; i < rxValue.length(); i++){ @@ -57,7 +56,7 @@ void setupBLE(String BLEName){ } void setup() { - Serial.begin(9600); + Serial.begin(115200); setupBLE("ESP32_Bluetooth"); } diff --git a/C/Sketches/Sketch_03.1_SDMMC_Test/Sketch_03.1_SDMMC_Test.ino b/C/Sketches/Sketch_03.1_SDMMC_Test/Sketch_03.1_SDMMC_Test.ino index 2d77993..bef19a7 100644 --- a/C/Sketches/Sketch_03.1_SDMMC_Test/Sketch_03.1_SDMMC_Test.ino +++ b/C/Sketches/Sketch_03.1_SDMMC_Test/Sketch_03.1_SDMMC_Test.ino @@ -2,7 +2,7 @@ Filename : SDMMC Test Description : The SD card is accessed using the SDMMC one-bit bus Auther : www.freenove.com - Modification: 2023/08/21 + Modification: 2024/06/20 **********************************************************************/ #include "sd_read_write.h" #include "SD_MMC.h" diff --git a/C/Sketches/Sketch_04.1_WiFi_Station/Sketch_04.1_WiFi_Station.ino b/C/Sketches/Sketch_04.1_WiFi_Station/Sketch_04.1_WiFi_Station.ino index be9c5cc..c0142ba 100644 --- a/C/Sketches/Sketch_04.1_WiFi_Station/Sketch_04.1_WiFi_Station.ino +++ b/C/Sketches/Sketch_04.1_WiFi_Station/Sketch_04.1_WiFi_Station.ino @@ -2,7 +2,7 @@ Filename : WiFi Station Description : Connect to your router using ESP32 Auther : www.freenove.com - Modification: 2020/07/11 + Modification: 2024/06/20 **********************************************************************/ #include diff --git a/C/Sketches/Sketch_04.2_WiFi_AP/Sketch_04.2_WiFi_AP.ino b/C/Sketches/Sketch_04.2_WiFi_AP/Sketch_04.2_WiFi_AP.ino index 91a1b1b..5d58bbf 100644 --- a/C/Sketches/Sketch_04.2_WiFi_AP/Sketch_04.2_WiFi_AP.ino +++ b/C/Sketches/Sketch_04.2_WiFi_AP/Sketch_04.2_WiFi_AP.ino @@ -2,7 +2,7 @@ Filename : WiFi AP Description : Set ESP32 to open an access point Auther : www.freenove.com - Modification: 2020/07/11 + Modification: 2024/06/20 **********************************************************************/ #include diff --git a/C/Sketches/Sketch_04.3_AP_Station/Sketch_04.3_AP_Station.ino b/C/Sketches/Sketch_04.3_AP_Station/Sketch_04.3_AP_Station.ino index 4c12a44..968da2c 100644 --- a/C/Sketches/Sketch_04.3_AP_Station/Sketch_04.3_AP_Station.ino +++ b/C/Sketches/Sketch_04.3_AP_Station/Sketch_04.3_AP_Station.ino @@ -2,7 +2,7 @@ Filename : WiFi AP+Station Description : ESP32 connects to the user's router, turning on an access point Auther : www.freenove.com - Modification: 2020/07/11 + Modification: 2024/06/20 **********************************************************************/ #include diff --git a/C/Sketches/Sketch_05.1_WiFiClient/Sketch_05.1_WiFiClient.ino b/C/Sketches/Sketch_05.1_WiFiClient/Sketch_05.1_WiFiClient.ino index c668a5b..fea06b0 100644 --- a/C/Sketches/Sketch_05.1_WiFiClient/Sketch_05.1_WiFiClient.ino +++ b/C/Sketches/Sketch_05.1_WiFiClient/Sketch_05.1_WiFiClient.ino @@ -2,7 +2,7 @@ Filename : WiFi Client Description : Use ESP32's WiFi client feature to connect and communicate with a remote IP. Auther : www.freenove.com - Modification: 2020/07/11 + Modification: 2024/06/20 **********************************************************************/ #include diff --git a/C/Sketches/Sketch_05.2_WiFiServer/Sketch_05.2_WiFiServer.ino b/C/Sketches/Sketch_05.2_WiFiServer/Sketch_05.2_WiFiServer.ino index cadc84d..6a6ffed 100644 --- a/C/Sketches/Sketch_05.2_WiFiServer/Sketch_05.2_WiFiServer.ino +++ b/C/Sketches/Sketch_05.2_WiFiServer/Sketch_05.2_WiFiServer.ino @@ -3,7 +3,7 @@ Description : Use ESP32's WiFi server feature to wait for other WiFi devices to connect. And communicate with them once a connection has been established. Auther : www.freenove.com - Modification: 2020/07/11 + Modification: 2024/06/20 **********************************************************************/ #include @@ -30,12 +30,11 @@ void setup() Serial.println(WiFi.localIP()); Serial.printf("IP port: %d\n",port); server.begin(port); - WiFi.setAutoConnect(true); WiFi.setAutoReconnect(true); } void loop(){ - WiFiClient client = server.available(); // listen for incoming clients + WiFiClient client = server.accept(); // listen for incoming clients if (client) { // if you get a client, Serial.println("Client connected."); while (client.connected()) { // loop while the client's connected diff --git a/C/Sketches/Sketch_06.1_CameraWebServer/Sketch_06.1_CameraWebServer.ino b/C/Sketches/Sketch_06.1_CameraWebServer/Sketch_06.1_CameraWebServer.ino index 6ea3678..3c0c3c0 100644 --- a/C/Sketches/Sketch_06.1_CameraWebServer/Sketch_06.1_CameraWebServer.ino +++ b/C/Sketches/Sketch_06.1_CameraWebServer/Sketch_06.1_CameraWebServer.ino @@ -3,7 +3,7 @@ Description : ESP32 connects to WiFi and prints a url through a serial port. Users visit the site to view the image data ESP32 camera. Auther : www.freenove.com - Modification: 2021/12/01 + Modification: 2024/06/20 **********************************************************************/ #include "esp_camera.h" #include @@ -57,7 +57,8 @@ void setup() { s->set_saturation(s, -1); //lower the saturation WiFi.begin(ssid_Router, password_Router); - while (WiFi.isConnected() != true) { + WiFi.setSleep(false); + while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } @@ -90,8 +91,8 @@ void config_init() { config.pin_pclk = PCLK_GPIO_NUM; config.pin_vsync = VSYNC_GPIO_NUM; config.pin_href = HREF_GPIO_NUM; - config.pin_sscb_sda = SIOD_GPIO_NUM; - config.pin_sscb_scl = SIOC_GPIO_NUM; + config.pin_sccb_sda = SIOD_GPIO_NUM; + config.pin_sccb_scl = SIOC_GPIO_NUM; config.pin_pwdn = PWDN_GPIO_NUM; config.pin_reset = RESET_GPIO_NUM; config.xclk_freq_hz = 20000000; @@ -100,6 +101,6 @@ void config_init() { //config.pixel_format = PIXFORMAT_RGB565; // for face detection/recognition config.grab_mode = CAMERA_GRAB_WHEN_EMPTY; config.fb_location = CAMERA_FB_IN_PSRAM; - config.jpeg_quality = 12; - config.fb_count = 1; + config.jpeg_quality = 10; + config.fb_count = 2; } diff --git a/C/Sketches/Sketch_06.2_As_VideoWebServer/Sketch_06.2_As_VideoWebServer.ino b/C/Sketches/Sketch_06.2_As_VideoWebServer/Sketch_06.2_As_VideoWebServer.ino index 8e60293..239ea72 100644 --- a/C/Sketches/Sketch_06.2_As_VideoWebServer/Sketch_06.2_As_VideoWebServer.ino +++ b/C/Sketches/Sketch_06.2_As_VideoWebServer/Sketch_06.2_As_VideoWebServer.ino @@ -36,8 +36,8 @@ void setup() { config.pin_pclk = PCLK_GPIO_NUM; config.pin_vsync = VSYNC_GPIO_NUM; config.pin_href = HREF_GPIO_NUM; - config.pin_sscb_sda = SIOD_GPIO_NUM; - config.pin_sscb_scl = SIOC_GPIO_NUM; + config.pin_sccb_sda = SIOD_GPIO_NUM; + config.pin_sccb_scl = SIOC_GPIO_NUM; config.pin_pwdn = PWDN_GPIO_NUM; config.pin_reset = RESET_GPIO_NUM; config.xclk_freq_hz = 20000000;