From ebb3c90ac6a092163e0ed519d7a69aa4b9a9913d Mon Sep 17 00:00:00 2001 From: jsfraz Date: Mon, 12 Aug 2024 18:03:54 +0200 Subject: [PATCH] Aded Internal Serial Port. --- examples/Hello World/README.md | 2 +- examples/Internal Serial Console/README.md | 16 ++++++++++++++++ .../Internal Serial Console/sketch/sketch.ino | 9 --------- .../sketch_pc_to_esp32/sketch_pc_to_esp32.ino | 12 ++++++++++++ 4 files changed, 29 insertions(+), 10 deletions(-) delete mode 100644 examples/Internal Serial Console/sketch/sketch.ino create mode 100644 examples/Internal Serial Console/sketch_pc_to_esp32/sketch_pc_to_esp32.ino diff --git a/examples/Hello World/README.md b/examples/Hello World/README.md index ec9fe6c..d43b6e3 100644 --- a/examples/Hello World/README.md +++ b/examples/Hello World/README.md @@ -4,7 +4,7 @@ 1) Open Arduino IDE, create project and pste the following code: -https://github.com/jsfraz/esp32-examples/blob/babe66bb216f46ae25eea57311abe4f44c718429/examples/Hello%20World/sketch/sketch.ino#L1-L8 +https://github.com/jsfraz/esp32-examples/blob/19d93d1fda92e05c4c6ff4420fcf878207474cf1/examples/Hello%20World/sketch/sketch.ino#L1-L8 2) **Press and hold ESP32 Boot button** and click **Upload** in Arduino IDE. You can release the button when `Connecting...` text shows up in **Output**. diff --git a/examples/Internal Serial Console/README.md b/examples/Internal Serial Console/README.md index ade9233..e6b8c1d 100644 --- a/examples/Internal Serial Console/README.md +++ b/examples/Internal Serial Console/README.md @@ -1,5 +1,21 @@ # Internal Serial Console +You can communicate with ESP32 serial interface USB cable. + +## From ESP32 to PC + +You can use the same code as in Hello World example: + +https://github.com/jsfraz/esp32-examples/blob/19d93d1fda92e05c4c6ff4420fcf878207474cf1/examples/Hello%20World/sketch/sketch.ino#L1-L8 + +You can use **Tools > Serial Monitor** or any other serial client like [Putty](https://www.putty.org/) to read data from the serial port. + +## From PC TO ESP32 + +TODO codeblock + +You can use **Arduino IDE Serial Monitor** using **Tools > Serial Monitor** or any other serial client like [Putty](https://www.putty.org/) to send data to the serial port. + ## Sources - [ESP32 - Serial Monitor](https://esp32io.com/tutorials/esp32-serial-monitor) diff --git a/examples/Internal Serial Console/sketch/sketch.ino b/examples/Internal Serial Console/sketch/sketch.ino deleted file mode 100644 index 95c2b6e..0000000 --- a/examples/Internal Serial Console/sketch/sketch.ino +++ /dev/null @@ -1,9 +0,0 @@ -void setup() { - // put your setup code here, to run once: - -} - -void loop() { - // put your main code here, to run repeatedly: - -} diff --git a/examples/Internal Serial Console/sketch_pc_to_esp32/sketch_pc_to_esp32.ino b/examples/Internal Serial Console/sketch_pc_to_esp32/sketch_pc_to_esp32.ino new file mode 100644 index 0000000..683fc64 --- /dev/null +++ b/examples/Internal Serial Console/sketch_pc_to_esp32/sketch_pc_to_esp32.ino @@ -0,0 +1,12 @@ +void setup() { + Serial.begin(9600); +} + +void loop() { + // Check if there is data comming + if (Serial.available()) { + // Read string until newline character + String str = Serial.readStringUntil('\n'); + Serial.println("String: " + str); + } +} \ No newline at end of file