├── README.md ├── Licence.txt └── ESP32_Using_Serial2.ino /README.md: -------------------------------------------------------------------------------- 1 | # ESP32-Using-Hardware-Serial-Ports 2 | How to use ESP32 hardware serial ports 3 | 4 | There are three serial ports on the ESP32 known as U0UXD, U1UXD and U2UXD. 5 | 6 | U0UXD is generally used to communicate with the ESP32 for programming and during reset/boot. 7 | 8 | U1UXD is unused and can be used for your projects. Some boards use this port for SPI Flash access though! 9 | 10 | U2UXD is unused and can be used for your projects. 11 | 12 | Port usage is defined like this Serial2.begin(baud-rate, protocol, RX pin, TX pin); 13 | 14 | -------------------------------------------------------------------------------- /Licence.txt: -------------------------------------------------------------------------------- 1 | This software, the ideas and concepts is Copyright (c) David Bird 2014 and beyond. 2 | 3 | All rights to this software are reserved. 4 | 5 | It is prohibited to redistribute or reproduce of any part or all of the software contents in any form other than the following: 6 | 7 | 1. You may print or download to a local hard disk extracts for your personal and non-commercial use only. 8 | 9 | 2. You may copy the content to individual third parties for their personal use, but only if you acknowledge the author David Bird as the source of the material. 10 | 11 | 3. You may not, except with my express written permission, distribute or commercially exploit the content. 12 | 13 | 4. You may not transmit it or store it in any other website or other form of electronic retrieval system for commercial purposes. 14 | 15 | 5. You MUST include all of this copyright and permission notice ('as annotated') and this shall be included in all copies or substantial portions of the software and where the software use is visible to an end-user. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS" FOR PRIVATE USE ONLY, IT IS NOT FOR COMMERCIAL USE IN WHOLE OR PART OR CONCEPT. 18 | 19 | FOR PERSONAL USE IT IS SUPPLIED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | 21 | IN NO EVENT SHALL THE AUTHOR OR COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /ESP32_Using_Serial2.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * There are three serial ports on the ESP known as U0UXD, U1UXD and U2UXD. 3 | * 4 | * U0UXD is used to communicate with the ESP32 for programming and during reset/boot. 5 | * U1UXD is unused and can be used for your projects. Some boards use this port for SPI Flash access though 6 | * U2UXD is unused and can be used for your projects. 7 | * 8 | */ 9 | 10 | #define RXD2 16 11 | #define TXD2 17 12 | 13 | void setup() { 14 | // Note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin); 15 | Serial.begin(115200); 16 | //Serial1.begin(9600, SERIAL_8N1, RXD2, TXD2); 17 | Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2); 18 | Serial.println("Serial Txd is on pin: "+String(TX)); 19 | Serial.println("Serial Rxd is on pin: "+String(RX)); 20 | } 21 | 22 | void loop() { //Choose Serial1 or Serial2 as required 23 | while (Serial2.available()) { 24 | Serial.print(char(Serial2.read())); 25 | } 26 | } 27 | 28 | 29 | /* Baud-rates available: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200, 256000, 512000, 962100 30 | * 31 | * Protocols available: 32 | * SERIAL_5N1 5-bit No parity 1 stop bit 33 | * SERIAL_6N1 6-bit No parity 1 stop bit 34 | * SERIAL_7N1 7-bit No parity 1 stop bit 35 | * SERIAL_8N1 (the default) 8-bit No parity 1 stop bit 36 | * SERIAL_5N2 5-bit No parity 2 stop bits 37 | * SERIAL_6N2 6-bit No parity 2 stop bits 38 | * SERIAL_7N2 7-bit No parity 2 stop bits 39 | * SERIAL_8N2 8-bit No parity 2 stop bits 40 | * SERIAL_5E1 5-bit Even parity 1 stop bit 41 | * SERIAL_6E1 6-bit Even parity 1 stop bit 42 | * SERIAL_7E1 7-bit Even parity 1 stop bit 43 | * SERIAL_8E1 8-bit Even parity 1 stop bit 44 | * SERIAL_5E2 5-bit Even parity 2 stop bit 45 | * SERIAL_6E2 6-bit Even parity 2 stop bit 46 | * SERIAL_7E2 7-bit Even parity 2 stop bit 47 | * SERIAL_8E2 8-bit Even parity 2 stop bit 48 | * SERIAL_5O1 5-bit Odd parity 1 stop bit 49 | * SERIAL_6O1 6-bit Odd parity 1 stop bit 50 | * SERIAL_7O1 7-bit Odd parity 1 stop bit 51 | * SERIAL_8O1 8-bit Odd parity 1 stop bit 52 | * SERIAL_5O2 5-bit Odd parity 2 stop bit 53 | * SERIAL_6O2 6-bit Odd parity 2 stop bit 54 | * SERIAL_7O2 7-bit Odd parity 2 stop bit 55 | * SERIAL_8O2 8-bit Odd parity 2 stop bit 56 | */ 57 | 58 | --------------------------------------------------------------------------------