Andreas the Legend! I wish I could be able to communicate so complicated things in such an easy way. The underground room explain a lot of the way you see the world today. I'll always remember this tour, Andreas. Hopefully it will make me a better human being as it, for sure, does for you! Danke's a lot! 😘
I think that you can call Serial.begin(baud_rate, config, , ) (or something like that) and define the pins you want to use without having to mess with the library files... I haven't tried it yet so I can't confirm if it works...
I like your videos. Well done. In this video you touched the subject of flow control and said that speed and buffers solved anything, but, look around, there's some kind of flow control everywhere in electronics.
Andreas Spiess I thought that only asynchronous communication (like rs-232) needed flow control but it looks that communication between chips use 1 pin to do some kind of flow control even when there is a clock.
Well, it's been over 5 years since you made the video, and your edit of the .cpp file is the only thing that worked for me for Serial1 😂!!! Even the suggestion to use Serial1.begin (115200, SERIAL_8N1, 4, 2) continued to result in crashes. thanks!!!
Hi Andreas, I made a design with ESP32-WROVER and I was shocked to find out that only 1 UART is free. I would be extremely happy if I can use the 3 uarts. Do you think it is possible to use any free pin for the TX and RX from Uart1,2,3? Is it possible to use interrupt buffers for every RX and TX ? IF so how to do that please? Thanks and kind regards.
1. You can try to use other pins. Most should work. 2. I do not know about the buffers 3. Maybe you watch this video: ruclips.net/video/eUPAoP7xC7A/видео.html
In the drawing at 4:05, RTS/CTS you show as one signal coming from the receiving computer, but RTS comes from the sender (also called Data Terminal Equipment) and CTS is on another separate pin coming from the receiver (called Data Communications Equipment). Often, this RTS to CTS delay was caused by slow modems that didn't empty-out their small send buffers quickly enough onto the analogue line, or modems still waiting on the process of dialing-out and/or carrier sync.
There was always some confusion with these names and who has which role, if I remember right. Fortunately, we do no more have to deal with them too much.
This might be a bit off topic, but would you have an insight into why an ESP32cam can send data to a serial monitor but when using pyserial it causes it to reset and no longer connect to wifi. As soon as I stop the program attempting to read from pyserial and go back to the serial monitor, the esp32 reboots and works fine. I have made sure my baudrate is set correctly.
Does anyone know where I can find this HardwareSerial.cpp file on a mac with Arduino installed? I have added ESP32 boards in my boards manager but I'm not sure if I need to do something else so I can get to this file.
I am working with nextion display and ESP32 earlier i uploaded the code in esp8266 to get value from the nextion using nextion.read using nextion.h library but now I am using ESP32 in ESP32 nextion.listen is working but nextion.read is not working i get value like 255 255 224 255 255 ...which are undesired values so kindly tell me what to do to solve this problem??
@@AndreasSpiess you don't need to debug I am just asking and can you guess what actually be a reason behind this because same code is working with esp8266 but when i use ESP32 it's not working 😅
I'm using Wemos LOLIN32 (Retired). HardwareSerial1(2); is not working for me. But by using Serial2.begin(115200); in the setup I get it working. Any idea why this is happening?
I have an issue with ESP32: I used it as a beacon scanner and tried two libraries different to scan(Using Arduino and Idf). Both, after a while, still searching for beacons but not finding anything at all and never back to find again untill reset!! Did you experienced the same? Thanks!!
Good fast lesson dear Mr. Andreas Spiess! The topic of ESP32 is in top priority for me. I am trying to learn how to work with IDF, ex how to "install" libraries in the Arduino IDE sense. It looks not easy at all though... If you know this topic please offer me/us a informative video when you can. Thanks in advance.
Andreas, i got 3 mA in deepsleep with the module you showed on this youtube videos, is it normal? maybe i will have to remove the red led ? thank you. Marc.
Thanks a lot for this very understandable video. Nowadays, the path to HardwareSerial2.cpp looks to have changed, not in ProgramFiles x86 anymore (only the one for AVR platform), do you know where the esp32 files are now located? I looked for in users folder without success.
Hi Andreas. I bought a Lolin32 board and it gets hot very quick. I will not use the sleep modes because it is for a robot that will transmit video. I've put it a heat sink and a fan and it remains cool. ¿Do your different modules also get hot when active and using the WiFi? Thanks
Finally I bought two of the cheapest ones. I measured the Lolin32: 140mA idle (making delay(1000) in a "for" loop), and between 300 and 350 mA with heavy processor and WiFi usage :-)
Great info, but I still don't get it to work, I'm messing things up. I have a Heltec WiFi kit 32, the one with Oled and a GPS6MV2 module. I can't get the GPS module and the Oled to work at same time. Like to show GPS info on the screen. Is it even possible? Tried many code example, changed the code, add, remove lines... GPS woks alone, Oled woks alone but not together. Can use all the help. Thanks
@@AndreasSpiess Can you explain how to connect a serial sensor on UART3 and show the values on the Oled. I'm trying to used a Heltec WiFi kit 32 and a GPS module to make a position device for my cat over wi-fi. Thanks
I believe the baud rates on these microcontrollers are configurable. In the setup code: Serial.begin(115200) change to Serial.begin(1200) to specify 1200 baud (after checking the datasheet specs to make sure 1200 baud is supported, of course)
Correct, the teensy does it, and I have tested most of my code on one, so I know that I can get the data I want from my power meter. I probably have to use the teensy to gather data from the meter, and pass it on to an ESP to send MQTT or modbus over to my node red or openhab server.
Hello @Andreas Spiess I am afraid to say that I tried it with ESP32 and not worked for me at all. Any further help will be greatly appreciated to fix this. Thanking you.
hi, thanks for your tutorial, it's really helpful, but when I try this "extra" serial, my wifi performance from esp32 down, and cannot connect.. do you experiencing this?
Maybe you watch my newest video and install the ESP32 accordingly. Then go to the directory where the preferences.txt file is installed. From there you go "packages\esp32\hardware\esp32\1.0.0\cores\esp32" and you will find hardwareserial.cpp
Andreas Spiess got it. I will do it that way. Thank you. It seems of you follow the official repos instructions, this file you say is not available. Thanks for quick response
Hi, thanks for your patience to teach us. I need to connect 3 serial ports on my esp32. Hw Serial 0 -> fw update and logs Hw Serial 2 -> gps Sw Serial -> gsm I already know that Serial 1 is connected to flash memory. So I need to emulate a serial port through GPIO's. I tried using an Arduino "Serial Software" library, but unfortunately on a compilation error. Reading in some forums and making some changes in the library, I was able to compile the "Sketch"; but the communication of my GSM modem via SoftwareSerial did not work. Note: By connecting the GSM modem separately to a USB / SERIAL converter the communication worked as expected. That is, the problem really is in SoftwareSerial emulation. Could you help?
Please, i want that you see my image in this link: screenshot.net/pt/d65llbv So. I need this configuration in my esp32 project: The GPS module sends data position to UART0. The GSM module sends data to UART0 It also receives commands that must be sent by UART0 (at commands, for example). Finally, "uart0" serves as interface for the computer or other microcontroller, both for data traffic and firmware update Please, can you help-me? /*********************************************************/ HardwareSerial Serial1(1); // is not linked to flash memory HardwareSerial Serial2(2); // hardware serial (uart2 on esp32) void setup() { Serial.begin (115200);//uart0 - flash firmware update and serial monitor interface Serial1.begin (9600) ;//uart1 - gps - only send data position to uart0 Serial2.begin (115200);//uart2 - gsm } void loop() { while(1) { char r = Serial1.read ( ); Serial.print (r); Serial2.println ("at"); Serial.print(Serial2.read () ); } } /*******************************************************************************/
Andreas Spiess if I didn’t change the library then I can use only two Uart even in that one goes to programming memory am I right so finally I can use only one
@@AndreasSpiess I believe the Arduino will allow you to use any pin for UART by implementing the UART through a serial library rather than the hardware that is built into the chip for specific pins. Is that what you are doing here or does the ESP32 allow for hardware UART on any pin?
@@philliptoone AFAIK the ESP32 has remappable PINs, thus it should still be hardware UART (see Chapter 4.2 and 4.3 Peripheral Output via GPIO Matrix in www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf)
Nice video, I am having some troubles setting the esp32 as a keyboard, I think either it's not yet implemented or I'm doing something wrong. I hope in your next videos you will cover this section :) !
Thanks for useful information I have some sensors and relays connected with arduino uno and i want to make a communication between UNO and esp32 via SDA and SCL pins... On the uno, both are mentioned and working fine whereas the problem is with esp32 Please guide me how to connect them and what code is required for esp32 for affective communication Regards
Thanks for yet another interesting video Andreas. As others have said, you do not have to mess with the esp files as you can define the pins you want to use during the call to serial.begin. Using the pins you choose, this would become: Serial1.begin(115200, SERIAL8_N1, 4, 2);
Hi Andreas, It seems I made a typo in my reply. Instead of SERIAL8_N1 you should use SERIAL_8N1 (note the location of the underscore). When I posted my comment I was on holiday in Austria so had no possibility to test it. I just looked up the relevant library files then on my iPad. Today, it took me quit some time before I found out that I made this typo. You'll find all possible definitions of the serial port settings (like SERIAL_8N1) in the header file "esp32-hal-uart.h" that lives in the same folder as the esp file you modified. Object variable Serial1 should be recognized as long as you instantiate it first (like you did in your example). Don't know what goes wrong there at your set up. Here's the code that works for me (Here I choose to change both serial 1 and 2 pins): HardwareSerial Serial1(1); HardwareSerial Serial2(2); #define TX1_pin 12 #define RX1_pin 13 #define TX2_pin 2 #define RX2_pin 4 void setup() { Serial.begin(115200); Serial1.begin(115200, SERIAL_8N1, RX1_pin, TX1_pin); Serial2.begin(115200, SERIAL_8N1, RX2_pin, TX2_pin); } void loop() { Serial.println("This message is sent to USB Seriall"); Serial1.println("This message is sent to UART1 Serial"); Serial2.println("This message is sent to UART2 Serial"); delay(1000); } Hope this helps.
hi guys can someone just clear something up for me? UART0 is the uart that is standard connected to the serial that one uses for the loading the sketch? which is pins marked RX and TX on the dev board...? Many thanks in advance!!!
Yes. Rx and Tx are GPIO pins 3 and 1 which are connected to UART chip to upload sketch to the Esp32. These pins are also used by UART0 to print text to the serial monitor (Serial.print(), you can see this in the HardwareSerial.h library). However UART0 is not tight to pins 3 and 1, you can change it to other pins but you can no longer use command Serial.print()
Hi Andreas, I knew you made a great video about getting both UARTS to work with ESP32. Unfortunately the content of the video results in a not working result if you use the latest ESP32 software. if i use the following lines: HardwareSerial Serial1(1); / HardwareSerial Serial2(2); the serial ports don't work at all. without using HardwareSerial lines, the ports work fine.
Andreas thank you for the very informative video ! I use an ESP32-S2-Saola-1R (WROVER). It has pin 43 marked as TXD and pin 44 as RXD. I see in the installed \cores\esp32\HardwareSerial.cpp the following(lines 63-69 #if CONFIG_IDF_TARGET_ESP32 rxPin = 3; txPin = 1; #elif CONFIG_IDF_TARGET_ESP32S2 rxPin = 44; txPin = 43; #endif so, I don't have to change the definition for rxPin and txPin.
Anybody getting this error when trying to use attachInterrupt() on esp8266 or esp32? (Arduino IDE v.1.8.5, esp8266 v.2.4.1, latest esp32 board defs as of this week)?... functions.h:164: error: invalid conversion from 'boolean (*)() {aka bool (*)()}' to 'void (*)()' [-fpermissive] attachInterrupt(digitalPinToInterrupt(stepCounterInterruptPin), stepCountHandler, RISING); ^ In file included from C:\Users\Bueno\_Arduino\hardware\espressif\esp32\cores\esp32/esp32-hal.h:52:0, from C:\Users\me\_Arduino\hardware\espressif\esp32\cores\esp32/Arduino.h:35, from sketch\exp32Driver_v0_01.ino.cpp:1: C:\Users\me\_Arduino\hardware\espressif\esp32\cores\esp32/esp32-hal-gpio.h:81:6: note: initializing argument 2 of 'void attachInterrupt(uint8_t, void (*)(), int)' void attachInterrupt(uint8_t pin, void (*)(void), int mode); ^ stepCounterInterruptPin is pin 2, aka '2', the unsigned, 8 bit integer. email me with solution if you have one (please)! mbueno0@gmail.com
@@AndreasSpiess The volt meter doesn't lie. GPIO 16 & 17 are reading high 4's. But you know what after trying out those esp32s wrooms I've come to the conclusion they are garbage. They go into a reboot cycle if you don't supply the exact volts/amps on the 5v pins.. but work fine when using the USB connector. My ai thinker esp32 cam works like a champ. Think I'll stick to AI thinker esp32s from now on.
@@AndreasSpiess thanks, now already solved, last i can't found hardwareserial. cpp on my hardisk 😁, and i can't install that library, anyways thanks a lot🙏
I am using Platform IO and aan ESP32-WROOM-32D bord, noticed that the HardwareSerial.ccp has been completely rewritten. It now detects by default if you use other pins for serial communication. But still in doubt for UART 1, because somehow i did not get that UART 1 to be used even on other pins defined. HardwareSerial Sender(0); // UART 0 => default pins TX0: 01 RX0: 03 HardwareSerial Receiver(2); // UART 2 => default pins TX2: 17 RX2: 16 Assigned receiver 2 to different pins as the default for testing; Sender.begin(115200); Receiver.begin(115200, SERIAL_8N1,/*Tx=*/ 13,/*Rx=*/ 12); Testing Sending and Receiving between those two UART's on the same ESP board, and that works without problems.
You may be using the esp32 as a control interface for an external device that doesn't talk i2c or spi. For example you may be using the esp32 to provide a wireless link for a weather station, or as a means of controlling a cellphone device to send sms text messages advising of something like a water leak filling your basement. Many of these devices either communicate via uart or rs232/serial. While you may only need a single serial connection for these most of the time, having a second, or third for some situations, may be the only way of debugging what the esp32 is seeing as you are developing your project.
i would think this is useful for offloading (sharing work), having more than 1 esp32 to do tasks, for example one could be used for motor control and one for balancing calculations, feeding data back to a central esp32, think of a robot dog (although there probably isnt enough power with the esp32), this way you technically increase the processing power by offloading work to other esp32's
Just a notice: A few days ago the github.com/espressif/arduino-esp32 has been updated. This also contains a new partition table (default.csv) for flash and a migration of EEPROM lib from ESP8266. And it works (up to 4096) as described there github.com/espressif/arduino-esp32/issues/525
Now I also have NTP and OTA running. OTA is not always shown in the arduino IDE but it works using espoty.py from Batch or command line. Now I have more hope in migrating some ESP8266 projects to ESP32
Great! I had some trouble with the migration of the webserver. But this github.com/espressif/arduino-esp32/tree/5e89f5e9fabe56d8e8af956bcd7635bf218e29a0/libraries/ESPWebServer/src helped. But as you can see there github.com/espressif/arduino-esp32/pull/430 unfortunately this will not be supported by the "official ESP32 community" in the future. But for now it seems to work.
Another quicky!!!! Keep them coming Andreas
Next two weeks it will be difficult...
Andreas Spiess Enjoy your holidays then Andreas (at least I hope that is the reason why it seems the coming two weeks we have to do without you 😀)
Great, thanks a lot! The lack of a second HW-Serial is one of the biggest disadvantages of the ESP8266
This is why I was disappointed at the beginning...
very useful, very clear, enough speed but at the same time no too fast.
Excellent. I subscribed
Welcome aboard the channel!
Andreas the Legend! I wish I could be able to communicate so complicated things in such an easy way. The underground room explain a lot of the way you see the world today. I'll always remember this tour, Andreas. Hopefully it will make me a better human being as it, for sure, does for you! Danke's a lot! 😘
Thank you for your compliment. I appreciate it!
I just discovered your channel right now, really nice ! Thanks a lot for your videos, you're great !
Welcome to the channel!
I think that you can call Serial.begin(baud_rate, config, , ) (or something like that) and define the pins you want to use without having to mess with the library files...
I haven't tried it yet so I can't confirm if it works...
Also mentioned here: www.esp32.com/viewtopic.php?t=328
Thanks for the tip.
I like your videos. Well done. In this video you touched the subject of flow control and said that speed and buffers solved anything, but, look around, there's some kind of flow control everywhere in electronics.
+Ocsav I I only referred to RS232 which is very slow. Faster protocols of course use flow controls.
Andreas Spiess I thought that only asynchronous communication (like rs-232) needed flow control but it looks that communication between chips use 1 pin to do some kind of flow control even when there is a clock.
Muchas gracias por compartir conocimientos Andreas, un cordial saludo desde Mar del Plata, Argentina.
:-)
Well, it's been over 5 years since you made the video, and your edit of the .cpp file is the only thing that worked for me for Serial1 😂!!! Even the suggestion to use Serial1.begin (115200, SERIAL_8N1, 4, 2) continued to result in crashes. thanks!!!
I think you can now specify the pins in the Serial.begin command
I continue to enjoy your clear and concise videos. Thanks 😊
You are so welcome!
Everytime I am trying to solve a problem you already have a solution you are like angel helping me out...thank you so much...😊
You are welcome. I am glad to help.
Great tutarial Andreas, as always :-) You are making incredeble work. I like you channel very much.
Mikołaj Wojciechowski Same here Mikolaj. He's the Best!
Thank you both!
You were just the solution for three days of search!! than you so much.
You are welcome! If you subscribe you do not need to search next time ;-)
Happy to help out fellow tinkerers,Cheers!
:-)
Back again, I knew id seen a video somewhere....... This has been a great help thank you
You are welcome. I recently myself had to go back to this video because I needed this info for a project...
Im still watching your old content :)
Obviously. This is truly an old one ;-)
Interesting as usual! Very clear and you hit the point.
Thanks
This is a game-changer -- you can use one serial port for your application, and use another to debug at the same time.
Exactly!
Does the ESP8266 /NodeMCU applies for this "hack" ?
No
@@AndreasSpiess Thanks Andreas ! And thanks so much for your channel!!
Just saved my project's butt Andreas. Thank you.
Glad to read that!
I owe you, you're a fantastic person. I think you're gonna be my first Patreon sub, you earned it.
Great video! That was exactly what I was looking for! Thank you!
You are welcome!
Hi Andreas, I made a design with ESP32-WROVER and I was shocked to find out that only 1 UART is free. I would be extremely happy if I can use the 3 uarts. Do you think it is possible to use any free pin for the TX and RX from Uart1,2,3? Is it possible to use interrupt buffers for every RX and TX ? IF so how to do that please? Thanks and kind regards.
1. You can try to use other pins. Most should work.
2. I do not know about the buffers
3. Maybe you watch this video: ruclips.net/video/eUPAoP7xC7A/видео.html
In the drawing at 4:05, RTS/CTS you show as one signal coming from the receiving computer, but RTS comes from the sender (also called Data Terminal Equipment) and CTS is on another separate pin coming from the receiver (called Data Communications Equipment). Often, this RTS to CTS delay was caused by slow modems that didn't empty-out their small send buffers quickly enough onto the analogue line, or modems still waiting on the process of dialing-out and/or carrier sync.
There was always some confusion with these names and who has which role, if I remember right. Fortunately, we do no more have to deal with them too much.
Maybe this is a silly question... but where is this file (HardwareSerial.cpp) located ?
Just search it on the PC. On my PC it is here: ruclips.net/video/GwShqW39jlE/видео.html
This might be a bit off topic, but would you have an insight into why an ESP32cam can send data to a serial monitor but when using pyserial it causes it to reset and no longer connect to wifi. As soon as I stop the program attempting to read from pyserial and go back to the serial monitor, the esp32 reboots and works fine.
I have made sure my baudrate is set correctly.
I never looked into these ESP32cam boards, so I do not know:-(
@@AndreasSpiess I sorted it out, it seems to be an issue with the flow control sequence, github.com/pyserial/pyserial/issues/124
Hi Andreas. Great video as usual! Helped me a lot. Thank you!
You are welcome!
What ESP32 do you use? Mine is a Geekcreit® ESP32 Development Board and only has 30 pins.
My LoLin board has 36 Pins
Does anyone know where I can find this HardwareSerial.cpp file on a mac with Arduino installed? I have added ESP32 boards in my boards manager but I'm not sure if I need to do something else so I can get to this file.
Great work again, very interesting. Thank you for taking the time to share your findings and knowledge.
:-)
Thank old man
your are the best
i search all RUclips and you like always help me
Thanks and stay safe
Thank you for yourkind words!
Joke:
- "What's the best thing about living in Switzerland?"
- "I don't know, but the flag is a big plus"
LoL
How do i clear serial buffer in the smallest amount of lines possible plz im using esp 8266?
Somethin like that?
void serialFlush(){
while(Serial.available() > 0) {
char t = Serial.read();
}
}
Thanks il try it out later :)
I am working with nextion display and ESP32 earlier i uploaded the code in esp8266 to get value from the nextion using nextion.read using nextion.h library but now I am using ESP32 in ESP32 nextion.listen is working but nextion.read is not working i get value like 255 255 224 255 255 ...which are undesired values so kindly tell me what to do to solve this problem??
Unfortunately, I cannot remote debug :-(
@@AndreasSpiess you don't need to debug I am just asking and can you guess what actually be a reason behind this because same code is working with esp8266 but when i use ESP32 it's not working 😅
@@windowofwords I have no idea 😞
If I understand correctly, pins 1,3 (tx,rx) are used for serial 0. Can I map serial 1 or 2 to these pins?
You only can use one pin once.
I'm using Wemos LOLIN32 (Retired). HardwareSerial1(2); is not working for me. But by using Serial2.begin(115200); in the setup I get it working. Any idea why this is happening?
No maybe they changed definitions since then.
I have an issue with ESP32: I used it as a beacon scanner and tried two libraries different to scan(Using Arduino and Idf). Both, after a while, still searching for beacons but not finding anything at all and never back to find again untill reset!! Did you experienced the same? Thanks!!
So far, I have no experience with ESP32 and bluetooth. Maybe another viewer?
Good fast lesson dear Mr. Andreas Spiess! The topic of ESP32 is in top priority for me. I am trying to learn how to work with IDF, ex how to "install" libraries in the Arduino IDE sense. It looks not easy at all though... If you know this topic please offer me/us a informative video when you can. Thanks in advance.
So far, I only know the Arduino IDE and have no other experience.
Andreas, i got 3 mA in deepsleep with the module you showed on this youtube videos, is it normal?
maybe i will have to remove the red led ?
thank you.
Marc.
There are a few things on these boards which consume current, the LED for sure, too
Andreas Spiess if i remove the led do u think i can sleep for years ?? Thanks. I got 1 week now... :(
No. You have to use a WROOM module only without the Serial to USB chip and the LDO. Development boards are not optimized for low current consumption
Andreas Spiess :-(
Andreas Spiess thank you.
Excellent video again Andreas! Thank you very much!
You are welcome!
Thanks a lot for this very understandable video. Nowadays, the path to HardwareSerial2.cpp looks to have changed, not in ProgramFiles x86 anymore (only the one for AVR platform), do you know where the esp32 files are now located? I looked for in users folder without success.
I do not know.
Can you help me? Is it possible that If the BLE of esp32 will not detect any beacons it will send a notification through the internet?
I have no experience with BLE
Hi Andreas. I bought a Lolin32 board and it gets hot very quick. I will not use the sleep modes because it is for a robot that will transmit video. I've put it a heat sink and a fan and it remains cool.
¿Do your different modules also get hot when active and using the WiFi?
Thanks
So far I have no experience with heavy Wi-Fi traffic. But it is well possible that the module heats up as Wi-Fi is quite power hungry.
Thanks. I must buy one of those USB mA and V display meters to see the current it consumes.
Or a electronic load/Monitor I showed in one of my latest videos... ( a little more expensive, but with PC connections for monitoring)
Very interesting. Unfortunately the software is for Windows only, and I use GNU/Linux. Do you know if the serial protocol is documented?
Finally I bought two of the cheapest ones. I measured the Lolin32: 140mA idle (making delay(1000) in a "for" loop), and between 300 and 350 mA with heavy processor and WiFi usage :-)
where can i find the folder location on mac? i use IDE 2.0
I do not know:-(
I'm searching for the excel file, you showed at 0:33. Where can i get it ?
I put it here: docs.google.com/spreadsheets/d/12qL3ui2BkSn91O0ISJU8QIL2mcG-r_vlX0briknA2QQ/edit?usp=sharing
Grüetzi und Vielen Danke. It works! -Frank
Thankyyou for the feedback!
Great info, but I still don't get it to work, I'm messing things up.
I have a Heltec WiFi kit 32, the one with Oled and a GPS6MV2 module.
I can't get the GPS module and the Oled to work at same time.
Like to show GPS info on the screen.
Is it even possible?
Tried many code example, changed the code, add, remove lines...
GPS woks alone, Oled woks alone but not together.
Can use all the help.
Thanks
Unfortunately I cannot do remote debugging... I usually start with a running system and add line by line till it stops working...
@@AndreasSpiess Im at the point were I using the UART1 to program the board and after to connect the GPS.
But this is not the ideal configuration.
@@AndreasSpiess Can you explain how to connect a serial sensor on UART3 and show the values on the Oled.
I'm trying to used a Heltec WiFi kit 32 and a GPS module to make a position device for my cat over wi-fi.
Thanks
is it possible to run one of the ports in 1200baud, 8n2? I have a meter I want to connect to that has those parameters..
I believe the baud rates on these microcontrollers are configurable. In the setup code: Serial.begin(115200) change to Serial.begin(1200) to specify 1200 baud (after checking the datasheet specs to make sure 1200 baud is supported, of course)
stryk187 he wants non parity, also 2 stop bits ( aka 8n2 ). That is not so easy or common...
Correct, the teensy does it, and I have tested most of my code on one, so I know that I can get the data I want from my power meter.
I probably have to use the teensy to gather data from the meter, and pass it on to an ESP to send MQTT or modbus over to my node red or openhab server.
Another great video Andreas. Please keep them coming! By the way, will you be testing the ESP32's CAN bus interface at any point?
I do not know for the moment. It has no high priority for me.
Awesome as usual. Thanks for the video. Very interesting.
You are welcome!
Hey thanks. I needed this exactly! Didn't know that pin routing for esp23 uarts was possible.
I also discovered it by chance and thought, it could be useful for others...
Yes, many Arduino users don't know about pin muxing. I've updated my original post here with a hackaday explanation.
Hello @Andreas Spiess I am afraid to say that I tried it with ESP32 and not worked for me at all. Any further help will be greatly appreciated to fix this. Thanking you.
Serial.print() and Google are your friends for debugging...
May i have 4 or 5 UART Channels by editing the file hardwarSerial.cpp?
Thanks
No
Thx for the video.
Do you have an example, where one esp sends data to another esp via UART?
No. I usually do this wirelessly ;-) I think you find such a project.
a very interesting video for me!! Thank you!
Glad you enjoyed it!
How did you implement flow control when you were a morse operator?
+Mike Hudson we stopped after a few words and the receiver either confirmed or asked what he did not understand. And we repeated
RTS/CTS stuff aren't unnnecesary nowdays, with it a MCU can archive higest speeds of UART.
You are right.
So, I can REMAP UART1 and UART2 to any GPIOs I want?
Yes. Just check: Not all pins can be used because they are used for other things.
hi, thanks for your tutorial, it's really helpful, but when I try this "extra" serial, my wifi performance from esp32 down, and cannot connect.. do you experiencing this?
No.
@@AndreasSpiess so any suggestion to check my this problem?
@@AndreasSpiess can I have your email? so we can discuss furthermore
I think there is software serials library even for esp32 now, it's easier to use
This is a very old video...
Thank u for sharing the knowledge
You are welcome!
Hi, the files no longer exist in that directory. Where can be locate the files? Have things changed now?
Maybe you watch my newest video and install the ESP32 accordingly. Then go to the directory where the preferences.txt file is installed. From there you go "packages\esp32\hardware\esp32\1.0.0\cores\esp32" and you will find hardwareserial.cpp
Andreas Spiess got it. I will do it that way. Thank you. It seems of you follow the official repos instructions, this file you say is not available. Thanks for quick response
I pinned a comment with the exact path. So it should be visible to everybody. A few other viewers asked the same question.
Andreas Spiess oh thank you. Will find it.
Hi, thanks for your patience to teach us.
I need to connect 3 serial ports on my esp32.
Hw Serial 0 -> fw update and logs
Hw Serial 2 -> gps
Sw Serial -> gsm
I already know that Serial 1 is connected to flash memory.
So I need to emulate a serial port through GPIO's.
I tried using an Arduino "Serial Software" library, but unfortunately on a compilation error. Reading in some forums and making some changes in the library, I was able to compile the "Sketch"; but the communication of my GSM modem via SoftwareSerial did not work.
Note: By connecting the GSM modem separately to a USB / SERIAL converter the communication worked as expected. That is, the problem really is in SoftwareSerial emulation.
Could you help?
Why do you not use this solution?
Andreas Spiess because this dont works too :(
Please, i want that you see my image in this link: screenshot.net/pt/d65llbv
So. I need this configuration in my esp32 project:
The GPS module sends data position to UART0.
The GSM module sends data to UART0 It also receives commands that must be sent by UART0 (at commands, for example).
Finally, "uart0" serves as interface for the computer or other microcontroller, both for data traffic and firmware update
Please, can you help-me?
/*********************************************************/
HardwareSerial Serial1(1); // is not linked to flash memory
HardwareSerial Serial2(2); // hardware serial (uart2 on esp32)
void setup()
{
Serial.begin (115200);//uart0 - flash firmware update and serial monitor interface
Serial1.begin (9600) ;//uart1 - gps - only send data position to uart0
Serial2.begin (115200);//uart2 - gsm
}
void loop()
{
while(1)
{
char r = Serial1.read ( );
Serial.print (r);
Serial2.println ("at");
Serial.print(Serial2.read () );
}
}
/*******************************************************************************/
Sir I am new in esp32 and arduno .i want communicate arduno mega to esp32 serialy.what can ido?
You have to connect the two serial connections and use serial.print() on one board and Serial.read() on the other.
Very nice as always
:-)
So efficiently we can use only 2 Uart for our purpose apart from programming am I right?
I am not sure what you mean. You can only use 2 if you do not want to change the library.
Andreas Spiess if I didn’t change the library then I can use only two Uart even in that one goes to programming memory am I right so finally I can use only one
You can use 2 UARTs on the ESP32 without changing the library.
I don't have "espressif" folder in arduino\hardware....
Maybe you watch the videos about installing the ESP32 in the Arduino IDE first
2:45 Is this "secret" UART using any arbitrary GPIO pin a software or hardware UART?
I do not understand what you mean.
@@AndreasSpiess I believe the Arduino will allow you to use any pin for UART by implementing the UART through a serial library rather than the hardware that is built into the chip for specific pins. Is that what you are doing here or does the ESP32 allow for hardware UART on any pin?
@@philliptoone AFAIK the ESP32 has remappable PINs, thus it should still be hardware UART (see Chapter 4.2 and 4.3 Peripheral Output via GPIO Matrix in www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf)
Helpful man I was wondering how to do this.
Thank you!
Thanks. Great Video. Very useful.
Glad you enjoyed it!
Nice video, I am having some troubles setting the esp32 as a keyboard, I think either it's not yet implemented or I'm doing something wrong. I hope in your next videos you will cover this section :) !
So far, I have many other topics which have a higher Prio. As you mention, maybe there is no library around...
This video was useful. Thanks.
You are welcome!
great explanation. thank you.
You are welcome!
What is use for 3rd? another tx?
Depends on your application.
Always enjoy your video....
:-)
Thanks for useful information
I have some sensors and relays connected with arduino uno and i want to make a communication between UNO and esp32 via SDA and SCL pins...
On the uno, both are mentioned and working fine whereas the problem is with esp32
Please guide me how to connect them and what code is required for esp32 for affective communication
Regards
Maybe you search for an I2C tutorial for the ESP32. It has some specialties like the wire command.
Thanks for yet another interesting video Andreas. As others have said, you do not have to mess with the esp files as you can define the pins you want to use during the call to serial.begin. Using the pins you choose, this would become: Serial1.begin(115200, SERIAL8_N1, 4, 2);
Unfortunately, this did not work in Arduino IDE when I tried (both, Serial1 and SERIAL8_N1 are not known)
Hi Andreas,
It seems I made a typo in my reply. Instead of SERIAL8_N1 you should use SERIAL_8N1 (note the location of the underscore).
When I posted my comment I was on holiday in Austria so had no possibility to test it. I just looked up the relevant library files then on my iPad.
Today, it took me quit some time before I found out that I made this typo.
You'll find all possible definitions of the serial port settings (like SERIAL_8N1) in the header file "esp32-hal-uart.h" that lives in the same folder as the esp file you modified.
Object variable Serial1 should be recognized as long as you instantiate it first (like you did in your example). Don't know what goes wrong there at your set up.
Here's the code that works for me (Here I choose to change both serial 1 and 2 pins):
HardwareSerial Serial1(1);
HardwareSerial Serial2(2);
#define TX1_pin 12
#define RX1_pin 13
#define TX2_pin 2
#define RX2_pin 4
void setup() {
Serial.begin(115200);
Serial1.begin(115200, SERIAL_8N1, RX1_pin, TX1_pin);
Serial2.begin(115200, SERIAL_8N1, RX2_pin, TX2_pin);
}
void loop() {
Serial.println("This message is sent to USB Seriall");
Serial1.println("This message is sent to UART1 Serial");
Serial2.println("This message is sent to UART2 Serial");
delay(1000);
}
Hope this helps.
Now the code compiles! Did not yet check the pins, but I assume, you did ;-) Thank you very much for this hint.
hi guys can someone just clear something up for me? UART0 is the uart that is standard connected to the serial that one uses for the loading the sketch?
which is pins marked RX and TX on the dev board...?
Many thanks in advance!!!
Yes. Rx and Tx are GPIO pins 3 and 1 which are connected to UART chip to upload sketch to the Esp32. These pins are also used by UART0 to print text to the serial monitor (Serial.print(), you can see this in the HardwareSerial.h library). However UART0 is not tight to pins 3 and 1, you can change it to other pins but you can no longer use command Serial.print()
Nice video, I want to build a PM2.5 monitor with three serial sensors and this could be very useful.
Good luck then!
Hi Andreas, I knew you made a great video about getting both UARTS to work with ESP32.
Unfortunately the content of the video results in a not working result if you use the latest ESP32 software.
if i use the following lines: HardwareSerial Serial1(1); / HardwareSerial Serial2(2); the serial ports don't work at all.
without using HardwareSerial lines, the ports work fine.
True. They changed the syntax. Thank you for mentioning it.
how to receive data from rs232 to esp32 using rts and cts in arduino
RTS and CTS do not carry data, they just signal readiness of the device.
Andreas thank you for the very informative video !
I use an ESP32-S2-Saola-1R (WROVER). It has pin 43 marked as TXD and pin 44 as RXD. I see in the installed \cores\esp32\HardwareSerial.cpp the following(lines 63-69
#if CONFIG_IDF_TARGET_ESP32
rxPin = 3;
txPin = 1;
#elif CONFIG_IDF_TARGET_ESP32S2
rxPin = 44;
txPin = 43;
#endif
so, I don't have to change the definition for rxPin and txPin.
Thanks for the update. This is an old video.
Great video, thanks alot.
You are welcome!
Wow, this really helps a lot!!!!!!! Thanks~~~
You are welcome!
What about a BlueTooth Serial? Is this possible?
I do not know, I never tried.
Hello sir can you do ESP32 Camera module and Arduino Serial communication? it doesn't work for me. Thank you so much for a wonderful tutorial❤️
Unfortunately, I cannot do remote debugging :-(
Thank you for your video !! It really helped me! You can make a link to the file with contact numbers and the notation of ESP32.xlsx?
You find the link in other ESP32 videos.
Anybody getting this error when trying to use attachInterrupt() on esp8266 or esp32? (Arduino IDE v.1.8.5, esp8266 v.2.4.1, latest esp32 board defs as of this week)?...
functions.h:164: error: invalid conversion from 'boolean (*)() {aka bool (*)()}' to 'void (*)()' [-fpermissive]
attachInterrupt(digitalPinToInterrupt(stepCounterInterruptPin), stepCountHandler, RISING);
^
In file included from C:\Users\Bueno\_Arduino\hardware\espressif\esp32\cores\esp32/esp32-hal.h:52:0,
from C:\Users\me\_Arduino\hardware\espressif\esp32\cores\esp32/Arduino.h:35,
from sketch\exp32Driver_v0_01.ino.cpp:1:
C:\Users\me\_Arduino\hardware\espressif\esp32\cores\esp32/esp32-hal-gpio.h:81:6: note: initializing argument 2 of 'void attachInterrupt(uint8_t, void (*)(), int)'
void attachInterrupt(uint8_t pin, void (*)(void), int mode);
^
stepCounterInterruptPin is pin 2, aka '2', the unsigned, 8 bit integer.
email me with solution if you have one (please)! mbueno0@gmail.com
why does uart2 have 5v on the rails tho? esp32 uart is so weird.
I do not think that any ESP32 pin has 5 volts.
@@AndreasSpiess The volt meter doesn't lie. GPIO 16 & 17 are reading high 4's. But you know what after trying out those esp32s wrooms I've come to the conclusion they are garbage. They go into a reboot cycle if you don't supply the exact volts/amps on the 5v pins.. but work fine when using the USB connector. My ai thinker esp32 cam works like a champ. Think I'll stick to AI thinker esp32s from now on.
very useful. thank you)
You are welcome!
But where location thats file?
I do not understand your question :-(
@@AndreasSpiess thanks, now already solved, last i can't found hardwareserial. cpp on my hardisk 😁, and i can't install that library, anyways thanks a lot🙏
I am using Platform IO and aan ESP32-WROOM-32D bord, noticed that the HardwareSerial.ccp has been completely rewritten. It now detects by default if you use other pins for serial communication. But still in doubt for UART 1, because somehow i did not get that UART 1 to be used even on other pins defined.
HardwareSerial Sender(0); // UART 0 => default pins TX0: 01 RX0: 03
HardwareSerial Receiver(2); // UART 2 => default pins TX2: 17 RX2: 16
Assigned receiver 2 to different pins as the default for testing;
Sender.begin(115200);
Receiver.begin(115200, SERIAL_8N1,/*Tx=*/ 13,/*Rx=*/ 12);
Testing Sending and Receiving between those two UART's on the same ESP board, and that works without problems.
no me funciono tengo esp32 con 38 pines
thank you!!
You're welcome!
very nice.. thank you.
You are welcome!
But... why would you ever want 2 serial buses, let alone 3?
Always if you want to connect one serial device and still need the Serial Monitor for debugging
aspuzling, excellent question; Andreas Spiess, perfect answer. Thankyou both!
Sorry, I still don't understand. What kind of serial device are you talking about? The only device I know of is the serial monitor.
You may be using the esp32 as a control interface for an external device that doesn't talk i2c or spi. For example you may be using the esp32 to provide a wireless link for a weather station, or as a means of controlling a cellphone device to send sms text messages advising of something like a water leak filling your basement. Many of these devices either communicate via uart or rs232/serial. While you may only need a single serial connection for these most of the time, having a second, or third for some situations, may be the only way of debugging what the esp32 is seeing as you are developing your project.
i would think this is useful for offloading (sharing work), having more than 1 esp32 to do tasks, for example one could be used for motor control and one for balancing calculations, feeding data back to a central esp32, think of a robot dog (although there probably isnt enough power with the esp32), this way you technically increase the processing power by offloading work to other esp32's
Thanks for sharing
:-)
Just a notice: A few days ago the github.com/espressif/arduino-esp32 has been updated. This also contains a new partition table (default.csv) for flash and a migration of EEPROM lib from ESP8266. And it works (up to 4096) as described there github.com/espressif/arduino-esp32/issues/525
Thanks for the tip!
Now I also have NTP and OTA running. OTA is not always shown in the arduino IDE but it works using espoty.py from Batch or command line. Now I have more hope in migrating some ESP8266 projects to ESP32
Great! I had some trouble with the migration of the webserver.
But this github.com/espressif/arduino-esp32/tree/5e89f5e9fabe56d8e8af956bcd7635bf218e29a0/libraries/ESPWebServer/src helped.
But as you can see there github.com/espressif/arduino-esp32/pull/430 unfortunately this will not be supported by the "official ESP32 community" in the future. But for now it seems to work.
:-)
you can specify pins in HardwareSerial.begin()
see here : github.com/G6EJD/ESP32-Using-Hardware-Serial-Ports/blob/master/ESP32_Using_Serial2.ino
You are right.
Please setup a patreon account so we can send you a few dollars a month!
Thank you for your offer. Maybe at 50'000 subscribers. For the moment, I can finance my hobby...
Here there are:
Patreon Page: www.patreon.com/AndreasSpiess
Alternative: flattr.com/@andreasspiess
Please make video about HTTPS request with esp32
This is for sure something I am interested in
Nice and concise! +1
:-)
there is no pin 16 and 17 in lolin32 pro
So you can shift these pins also to different pins using the method shown in this video. Or use another board ;-)