If you use the Arduino IDE to program the ESP32, you might be interested in [Andreas Spiess’] latest video (see below). In it, he shows an example of using all three ESP32 UARTs from an Arduino program. He calls the third port “secret” although that’s really a misnomer. However, it does require a quick patch to the Arduino library to make it work.
Just gaining access to the additional UARTs isn’t hard. You simply use one of the additional serial port objects available. However, enabling UART 1 causes the ESP32 to crash! The reason is that by default, UART 1 uses the same pins as the ESP32 flash memory.
Luckily, the chip has a matrix switch that can put nearly any logical I/O pin on any physical I/O pin. [Andreas] shows how to modify the code, so that UART 1 maps to unused pins, which makes everything work. it is a simple change, replacing two parameters to a call that — among other things — maps the I/O pins. You could use the technique to relocate the UARTs to other places if you choose.
If you want to learn more about the ESP32, we covered a good set of tutorials for you to check out. Or if you just want a quick overview, you can start here.
You fall for all those “Windows Secrets” books, don’t you?
an no doubt those “you’ll be amazed at what happens next” videos
It’s honestly stuff like this that makes me dislike Arduino. Remapping pins should be an obvious solution, and yet it’s masked by this goofy IDE and frameworks.
It’s not hidden, the guy is just didn’t RTFM. The HardwareSerial::begin function he modifies can take parameters to override default assignments (as can be seen at 3:14). Had he simply ran Serial1.begin(115200, config, 4, 2) it would work without changing any “hidden” code (although I would have to read more of that file to find value for config).
This is already a feature in arduino/esp32? Rx/Tx can be mapped to any pin?
I have no idea about arduino backend code, I only know what I saw in the video – the constants he’s modyfying are overriden by parameters this function takes.
As MikrySoft mentions, the Arduino-core for the ESP32 already internally uses this feature. Take a look at https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/HardwareSerial.cpp and https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/HardwareSerial.h — it’s literally that easy to change the pin-configuration for each of the UARTs.
Thanks! Didn’t know about this.
For config use SERIAL_8N1 – I saw it in the .h file, tried it and it worked. It must be a pre-defined constant.
Some dislike Arduino for perpetuating bad coding practices.
However, like Visual Basic it will have a fanatical user base for years to come, and the ESP32 hardware at least has better options like the FreeRTOS SDK.
Anybody know about an 8-pin ESP module which doesn’t waste a pin on something as useless as CH_EN/CH_PD (Enable, power down)? Maybe someone has found a way to re-route it?
Having an ESP32 module now for a week I can say: There is still a loooong road ahead until it becomes useable in Arduino or even in general. I will give it some time…
Look at the real ESP-IDF, which is a lot more mature than the Arduino environment. Alternatively, if you want easy: go for Micropython. That ecosystem is maturing relatively fast, especially with the SHA2017 badge happening. It’s actually quite usable.
Because this is not an Arduino.
The fake Arduino core is just a wrapper around the ESP-IDF.
Before getting my ESP32 I read documentation and looked in Github at both ESP-IDF and Arduino-ESP32.
The official framework is under heavy development, and the Arduino core is a bit behind that. But if you really want to use something which is not in the Arduino core, you can always use the original C stuff.
For example I’m now making myself a C++ wrapper class for the IR remote controller code, which is “hidden”.
I never thought that is secret !!
Andreas Spiess has a great channel. Highly recommended for electronics hobbyist (read: doing electronics without higher math). I’m definitely a big fan.
esp32 is verry cheap at banggood.com
$ 4.29 bare module
https://goo.gl/9Kg17w
$ 6.79 without battery connector/charging controller
https://goo.gl/1uqa6F
$ 7.79 with battery connector/charging controller
https://goo.gl/L6TGyb
I suspect this is why my attempt at setting up an Iridium ROCKBlock 2 modem is failing.
Well i am hoping that is all it is. Tried sefining Serial2 and the ESP32 just keeps crashing.
any update on getting the ESP32 to work with the RockBlock? I have been trying to figure it out and tried out all kinds of things to get no where.