Hi,
Using Arduino IDE i am trying to read a UART ultrasonic sensor on UART0 using GPIO pins 20 and 21, It is failing to read.
Previously i was using ESP32 Devkitv1, in which using Serial2 and GPIO pins 16 and 17, successfully read the UART ultrasonic sensor.
Can anyone let me know how to use UART on ESP32-C3 Devkitc-02 to read the UART ultrasonic sensor using Arduino IDE.
Thank You
How to use UART on ESP32-C3 devkitc-02 to read UART ultrasonic sensor
Re: How to use UART on ESP32-C3 devkitc-02 to read UART ultrasonic sensor
Here is an example of using the second UART on ESP32 C3
Remember to connect the ultrasonic TX to pin4 (ESP32 C3 RX) and the ultrasonic RX to pin5 (ESP32 C3 TX)
Remember to connect the ultrasonic TX to pin4 (ESP32 C3 RX) and the ultrasonic RX to pin5 (ESP32 C3 TX)
Code: Select all
// ESP32 C3 SERIAL1 (second UART)
void setup() {
Serial.begin(115200);
Serial1.begin(115200,SERIAL_8N1, 4,5); //int8_t rxPin=4, int8_t txPin=5
}
void loop() {
if (Serial.available()) { // If anything comes in Serial (USB),
Serial1.write(Serial.read()); // read it and send it out Serial1 (pins 4 & 5)
}
if (Serial1.available()) { // If anything comes in Serial1 (pins 4 & 5)
Serial.write(Serial1.read()); // read it and send it out Serial (USB)
}
}
Re: How to use UART on ESP32-C3 devkitc-02 to read UART ultrasonic sensor
hi,
I am developing a software in Arduino IDE for ESP32-C3.
I want to use UART1 to communicate with another device using AT command.
I've tried using SoftwareSerial and HardwareSerial but can't get it to work.
I just need to be able to send "AT?" and get a "OK" as reply.
Any help?
Codes:
// ESP32 C3 SERIAL1 (second UART)
HardwareSerial mySerial1(1);
int rxPin=5;
int txPin=4;
void setup()
{
Serial.begin(115200);
pinMode(txPin,OUTPUT);
pinMode(rxPin,INPUT);
mySerial1.begin(115200, SERIAL_8N1, rxPin, txPin);
}
void loop()
{
mySerial1.println("AT?");
//delay(100);
if (mySerial1.available())
{ // If anything comes in Serial1
while (mySerial1.available())
Serial.write(mySerial1.read()); // read it and send it out Serial (USB)
}
}
I have swapped the TX and RX pins but no avail.
Thanks for any suggestions.
I am developing a software in Arduino IDE for ESP32-C3.
I want to use UART1 to communicate with another device using AT command.
I've tried using SoftwareSerial and HardwareSerial but can't get it to work.
I just need to be able to send "AT?" and get a "OK" as reply.
Any help?
Codes:
// ESP32 C3 SERIAL1 (second UART)
HardwareSerial mySerial1(1);
int rxPin=5;
int txPin=4;
void setup()
{
Serial.begin(115200);
pinMode(txPin,OUTPUT);
pinMode(rxPin,INPUT);
mySerial1.begin(115200, SERIAL_8N1, rxPin, txPin);
}
void loop()
{
mySerial1.println("AT?");
//delay(100);
if (mySerial1.available())
{ // If anything comes in Serial1
while (mySerial1.available())
Serial.write(mySerial1.read()); // read it and send it out Serial (USB)
}
}
I have swapped the TX and RX pins but no avail.
Thanks for any suggestions.
Re: How to use UART on ESP32-C3 devkitc-02 to read UART ultrasonic sensor
Hi,
The UART1 (hardware UART) is not exposed on the pin out, so I can't use it.
Will have to use ESPSoftwareSerial to get data thru UART with another module.
Anyone got experience with ESPSoftwareSerial on ESP32-C3? It works well?
The UART1 (hardware UART) is not exposed on the pin out, so I can't use it.
Will have to use ESPSoftwareSerial to get data thru UART with another module.
Anyone got experience with ESPSoftwareSerial on ESP32-C3? It works well?
-
- Posts: 9709
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to use UART on ESP32-C3 devkitc-02 to read UART ultrasonic sensor
As with most peripherals, UART1 is configurable to use almost any GPIO the ESP32C3 has; just initialize it with the pins you want to use it on. If a pin is said to have a function wrt a peripheral, generally you can see that as the 'default' pin, not the pin that you mandatorily need to use it on.
Re: How to use UART on ESP32-C3 devkitc-02 to read UART ultrasonic sensor
Thanks.
Have tried to use UART1 with all the GPIO pins, but nothing is coming back (tried the code on ESP32 Wroom and it was fine).
Am using ESP32-C3-WROOM-02-N4.
Have tried to use UART1 with all the GPIO pins, but nothing is coming back (tried the code on ESP32 Wroom and it was fine).
Am using ESP32-C3-WROOM-02-N4.
Re: How to use UART on ESP32-C3 devkitc-02 to read UART ultrasonic sensor
hi,
thanks for the link.
I am able to flash the esp32-c3, but not able to get data from uart1.
NO matter which free pins I used for the hardware serial, i don't get any response.
I can see the data from uart0 (which are shown on the Arduino serial output console).
thanks for the link.
I am able to flash the esp32-c3, but not able to get data from uart1.
NO matter which free pins I used for the hardware serial, i don't get any response.
I can see the data from uart0 (which are shown on the Arduino serial output console).
Who is online
Users browsing this forum: Google [Bot] and 248 guests