Need help regarding UART1 and UART2 communication for ESP32
Need help regarding UART1 and UART2 communication for ESP32
Hi,
I have one ESP32 chip based custom board in which UART1 and UART2 are connected with other controller chip and I am working on ESP32-idf RTOS SDK.
Now, I want to enable both UART1 and UART2 and want to send and receive some data over UART interface.
Does anyone has any idea regarding code point of view to initialize UART1 and UART2 and send/receive data for ESP32?
Please let me know ASAP.
I have one ESP32 chip based custom board in which UART1 and UART2 are connected with other controller chip and I am working on ESP32-idf RTOS SDK.
Now, I want to enable both UART1 and UART2 and want to send and receive some data over UART interface.
Does anyone has any idea regarding code point of view to initialize UART1 and UART2 and send/receive data for ESP32?
Please let me know ASAP.
Regards,
Ritesh Prajapati
Ritesh Prajapati
Re: Need help regarding UART1 and UART2 communication for ESP32
I have been super impressed with the work done by mr "me-no-dev" on the Arduino libraries. He seems to have decoded much of the ESP32 hardware interfaces. Either he is extraordinarily talented in comprehending technical documents or he has spent a lot of time on it or a mixture of both ... but either way his contributions are huge.
Within the Arduino code there are "hardware abstraction libraries" which provide C consumable interfaces to the underlying hardware. For example, this source file seems to wrap the UART functions in what appears to be all three of the hardware UARTs:
https://github.com/espressif/arduino-es ... hal-uart.c
You might be able to study this for your answers or maybe even lift it as-is.
Within the Arduino code there are "hardware abstraction libraries" which provide C consumable interfaces to the underlying hardware. For example, this source file seems to wrap the UART functions in what appears to be all three of the hardware UARTs:
https://github.com/espressif/arduino-es ... hal-uart.c
You might be able to study this for your answers or maybe even lift it as-is.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: Need help regarding UART1 and UART2 communication for ESP32
Hi,
Thanks for update...
It seems information is enough for me though I am working on ESP32-idf RTOS SDK.
I will check and will let you know if need any other help.
Thanks for update...
It seems information is enough for me though I am working on ESP32-idf RTOS SDK.
I will check and will let you know if need any other help.
Regards,
Ritesh Prajapati
Ritesh Prajapati
- ESP_Me-no-dev
- Posts: 80
- Joined: Mon Jan 04, 2016 6:30 pm
Re: Need help regarding UART1 and UART2 communication for ESP32
@Ritesh esp32 Arduino can be used as an IDF component in your IDF projects, so you can access the drivers and familiar API from there while having full control of everything else.
In the root of your project, create a folder named "components". Open terminal/console into that folder and. From then on, you can include Arduino.h in your files and have access to the api.
In the root of your project, create a folder named "components". Open terminal/console into that folder and
Code: Select all
git clone https://github.com/espressif/arduino-esp32 arduino
Re: Need help regarding UART1 and UART2 communication for ESP32
thanks, got small error on class PrintESP_Me-no-dev wrote:@Ritesh esp32 Arduino can be used as an IDF component in your IDF projects, so you can access the drivers and familiar API from there while having full control of everything else.
In the root of your project, create a folder named "components". Open terminal/console into that folder and. From then on, you can include Arduino.h in your files and have access to the api.Code: Select all
git clone https://github.com/espressif/arduino-esp32 arduino
Code: Select all
In file included from C:/college/floh/01_hello_world/components/arduino/cores/esp32/Print.h:27:0,
from C:/college/floh/01_hello_world/components/arduino/cores/esp32/Stream.h:26,
from C:/college/floh/01_hello_world/components/arduino/cores/esp32/Arduino.h:136,
from C:/college/floh/01_hello_world/main/PIR_Nano32.c:36:
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Printable.h:25:1: error: unknown type name 'class'
class Print;
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Printable.h:33:1: error: unknown type name 'class'
class Printable
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Printable.h:34:1: error: expected '=', ',', ';', 'asm' or
'__attribute__' before '{' token
{
^
In file included from C:/college/floh/01_hello_world/components/arduino/cores/esp32/Stream.h:26:0,
from C:/college/floh/01_hello_world/components/arduino/cores/esp32/Arduino.h:136,
from C:/college/floh/01_hello_world/main/PIR_Nano32.c:36:
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Print.h:34:1: error: unknown type name 'class'
class Print
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Print.h:35:1: error: expected '=', ',', ';', 'asm' or '__a
ttribute__' before '{' token
{
^
In file included from C:/college/floh/01_hello_world/components/arduino/cores/esp32/Arduino.h:136:0,
from C:/college/floh/01_hello_world/main/PIR_Nano32.c:36:
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Stream.h:38:1: error: unknown type name 'class'
class Stream: public Print
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Stream.h:38:13: error: expected '=', ',', ';', 'asm' or '_
_attribute__' before ':' token
class Stream: public Print
^
In file included from C:/college/floh/01_hello_world/components/arduino/cores/esp32/Arduino.h:139:0,
from C:/college/floh/01_hello_world/main/PIR_Nano32.c:36:
C:/college/floh/01_hello_world/components/arduino/cores/esp32/IPAddress.h:29:1: error: unknown type name 'class'
class IPAddress: public Printable
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/IPAddress.h:29:16: error: expected '=', ',', ';', 'asm' or
'__attribute__' before ':' token
class IPAddress: public Printable
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/IPAddress.h:91:1: error: unknown type name 'IPAddress'
const IPAddress INADDR_NONE(0, 0, 0, 0);
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/IPAddress.h:91:29: error: expected declaration specifiers
or '...' before numeric constant
const IPAddress INADDR_NONE(0, 0, 0, 0);
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/IPAddress.h:91:32: error: expected declaration specifiers
or '...' before numeric constant
const IPAddress INADDR_NONE(0, 0, 0, 0);
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/IPAddress.h:91:35: error: expected declaration specifiers
or '...' before numeric constant
const IPAddress INADDR_NONE(0, 0, 0, 0);
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/IPAddress.h:91:38: error: expected declaration specifiers
or '...' before numeric constant
const IPAddress INADDR_NONE(0, 0, 0, 0);
^
In file included from C:/college/floh/01_hello_world/components/arduino/cores/esp32/Arduino.h:140:0,
from C:/college/floh/01_hello_world/main/PIR_Nano32.c:36:
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Client.h:26:1: error: unknown type name 'class'
class Client: public Stream
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Client.h:26:13: error: expected '=', ',', ';', 'asm' or '_
_attribute__' before ':' token
class Client: public Stream
^
In file included from C:/college/floh/01_hello_world/components/arduino/cores/esp32/Arduino.h:141:0,
from C:/college/floh/01_hello_world/main/PIR_Nano32.c:36:
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Server.h:25:1: error: unknown type name 'class'
class Server: public Print
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Server.h:25:13: error: expected '=', ',', ';', 'asm' or '_
_attribute__' before ':' token
class Server: public Print
^
In file included from C:/college/floh/01_hello_world/components/arduino/cores/esp32/Arduino.h:142:0,
from C:/college/floh/01_hello_world/main/PIR_Nano32.c:36:
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Udp.h:41:1: error: unknown type name 'class'
class UDP: public Stream
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Udp.h:41:10: error: expected '=', ',', ';', 'asm' or '__at
tribute__' before ':' token
class UDP: public Stream
^
In file included from C:/college/floh/01_hello_world/components/arduino/cores/esp32/Arduino.h:143:0,
from C:/college/floh/01_hello_world/main/PIR_Nano32.c:36:
C:/college/floh/01_hello_world/components/arduino/cores/esp32/HardwareSerial.h:35:1: error: unknown type name 'class'
class HardwareSerial: public Stream
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/HardwareSerial.h:35:21: error: expected '=', ',', ';', 'as
m' or '__attribute__' before ':' token
class HardwareSerial: public Stream
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/HardwareSerial.h:74:1: error: unknown type name 'HardwareS
erial'
extern HardwareSerial Serial;
^
In file included from C:/college/floh/01_hello_world/components/arduino/cores/esp32/Arduino.h:144:0,
from C:/college/floh/01_hello_world/main/PIR_Nano32.c:36:
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Esp.h:51:1: error: unknown type name 'class'
class EspClass
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Esp.h:52:1: error: expected '=', ',', ';', 'asm' or '__att
ribute__' before '{' token
{
^
C:/college/floh/01_hello_world/components/arduino/cores/esp32/Esp.h:83:1: error: unknown type name 'EspClass'
extern EspClass ESP;
^
make[1]: *** [c:/sdk32/esp-idf/make/component_common.mk:111: PIR_Nano32.o] Error 1
make[1]: Leaving directory '/c/college/floh/01_hello_world/build/main'
make: *** [c:/sdk32/esp-idf/make/project.mk:251: main-build] Error 2
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
- ESP_Me-no-dev
- Posts: 80
- Joined: Mon Jan 04, 2016 6:30 pm
Re: Need help regarding UART1 and UART2 communication for ESP32
you are trying to call CPP classes from C file You can use esp32-hal-*.h in C, the rest only in C++
Re: Need help regarding UART1 and UART2 communication for ESP32
Hi,
Thanks for quick reply...
Let me try in my code and will contact if any issue in compilation or configuration stuffs.
So, it seems using this Arduino components I can send or receive data to both UART on ESP32. Correct?
Thanks for quick reply...
Let me try in my code and will contact if any issue in compilation or configuration stuffs.
So, it seems using this Arduino components I can send or receive data to both UART on ESP32. Correct?
Regards,
Ritesh Prajapati
Ritesh Prajapati
Re: Need help regarding UART1 and UART2 communication for ESP32
thanks Me-no-dev, i did try with .c -> .cpp but this worked not in second try, i will try your #include esp32-hal-*.h next step, thanks!ESP_Me-no-dev wrote:you are trying to call CPP classes from C file You can use esp32-hal-*.h in C, the rest only in C++
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Re: Need help regarding UART1 and UART2 communication for ESP32
Hi,
I have cloned it using following commands into components and compiled my application in which whole Arduino module is compiled successfully without any issue.
Please let me know if you are still getting any compilation error.
I have cloned it using following commands into components and compiled my application in which whole Arduino module is compiled successfully without any issue.
I have also called some functions for that without any compilation error.cd esp-idf/components
git clone https://github.com/espressif/arduino-esp32 arduino
Please let me know if you are still getting any compilation error.
Regards,
Ritesh Prajapati
Ritesh Prajapati
- ESP_Me-no-dev
- Posts: 80
- Joined: Mon Jan 04, 2016 6:30 pm
Re: Need help regarding UART1 and UART2 communication for ESP32
@rudi I especially committed a change so you can safely include Arduino.h in C files as well
Who is online
Users browsing this forum: No registered users and 273 guests