ESP32 WROOM serial port woes

For general Flowcode discussion that does not belong in the other sections.
Post Reply
RGV250
Posts: 414
http://meble-kuchenne.info.pl
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 42 times
Been thanked: 42 times

ESP32 WROOM serial port woes

Post by RGV250 »

Hi,
I wonder if there is an issue or I am doing something wrong. I have my project working fine using A.12 (channel 2) which looking at the pinouts is not even a serial port?
The issue with this is that I have to disconnect the serial port every time I try to download or it fails, I did see somewhere this pin must be low on boot which is a bit of a limitation.
Anyway I tried to move to RX2 pin A.16 (channel 2) and I can now download but get no serial input. I tried software, channel 1 and 3 but nothing.
I looked at RX0 but the document I have says that is used for flashing and debugging so off limits.

Any suggestions as to what I am doing wrong with RX2, I cannot wait to migrate the project over to a Raspberry Pi to move away from this buggy thing.

Regards,
Bob

mnfisher
Valued Contributor
Posts: 1899
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 154 times
Been thanked: 895 times

Re: ESP32 WROOM serial port woes

Post by mnfisher »

I have used a second UART successfully - for example viewtopic.php?t=3542&hilit=LiDAR - however i did this in C...

Can you upload a code snippet and a bit more detail what's going wrong...

Martin

RGV250
Posts: 414
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 42 times
Been thanked: 42 times

Re: ESP32 WROOM serial port woes

Post by RGV250 »

Hi Martin,
I tried using that pin and got no serial input.
I have attached 2 files, identical apart from the serial port RX pin.
3A works and I can see data changing on the web app but if I use 3B I get nothing. I have also tried using GPIO19 and software but that did not work either.
I am not a fan of ESP32 as there seem to be so many different variations.
I think this is the device I have https://kunkune.co.uk/shop/esp32-esp826 ... bluetooth/
ESP_MQTT_Client_EcoEye3A.fcfx
(54.22 KiB) Downloaded 17 times
ESP_MQTT_Client_EcoEye3B.fcfx
(54.58 KiB) Downloaded 15 times
Regards,
Bob

mnfisher
Valued Contributor
Posts: 1899
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 154 times
Been thanked: 895 times

Re: ESP32 WROOM serial port woes

Post by mnfisher »

Hi Bob,

I did a quick demo program - and the UARTs seem to work okay.

I use two UARTs one (connected to UART1 - and thus to USB) and one to UART2 (I connected an FTDI convertor). Note that I also connected the Tx pin - and output a message here - as a sanity check.

It looks for data at UART2 (I used A16 as input here - but also tested other pins) - and outputs it to UART1 (USB) when enter is pressed (it looks for '\r' 0x0D) I also tested UART3 and that also works.

I think you will need to use an Rx interrupt (you use ReceiveString) - otherwise 'catching' the data is very much a matter of luck. Timing is very 'tricky' to say the least.

Note that (rather confusingly) the interrupt you need is 1 less than the UART number (so UART1 -> Use RxInt0 UART2 -> RxInt1 etc) - this is the same for all MCUs - but it is an odd naming convention (software is UART0).

To test open one PuTTY terminal on the esp32 COM port (in my case COM6) at 115200baud. Open a second COM port to your FTDI converter (COM13 for me) at 9600 baud. Note that you can alter the baud rates to suit... Type into the FTDI com port and it will 'appear' in the other when you hit enter.

Martin
Attachments
uart_2_test.fcfx
(15.22 KiB) Downloaded 15 times

RGV250
Posts: 414
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 42 times
Been thanked: 42 times

Re: ESP32 WROOM serial port woes

Post by RGV250 »

Hi Martin,
Thanks for that, it will help greatly. I do have another device (DF Robot Firebeetle 1.0), I thought a well established brand would be better but it is rubbish, even with the manual I am unsure what pins are what, I should have payed more attention when buying. The manual shows the pins for the ESP32 module but not for the actual board it is mounted on. I will not be buying anything else of theirs.

The data in is around 20 bytes every 4 seconds and seems OK but an interrupt will be better, I will have to read up on how that works here.

I will have a play later and let you know how I get on.

Regards,
Bob

mnfisher
Valued Contributor
Posts: 1899
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 154 times
Been thanked: 895 times

Re: ESP32 WROOM serial port woes

Post by mnfisher »

The esp32 does offer a remarkable amount of 'bang' for the buck....

The programming paradigm ( :-) ) - is slightly different to most MCUs - for the most part because of the (co-operative) multi-tasking system used. It's worth playing along though - because the performance for such a low-price device is very good indeed....

Reading 20bytes - just 'look for' pos == 20 though you might need to add a 'timeout' too?

I've not used the DFRobot board - but there is a wide range of kit available. I got some esp32-wroom-32 boards a while back - and they've proved very reliable (despite some getting rather warm - as a result of my suspect wiring skills). It's a pity they don't fit on a breadboard though :-(

Let us know how it goes - and of course any questions...

Martin
#

RGV250
Posts: 414
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 42 times
Been thanked: 42 times

Re: ESP32 WROOM serial port woes

Post by RGV250 »

Well, I cannot put my actual thoughts here for fear of being banned :x

Nothing worked, I then recalled I used the board with an RS485 module that used RS232 between ESP32 and the RS485 transciever. I dug out the old program and that used GPIO16 but the FC program had it down as GPIO22??? I recall there was some confusion way back then, I tried that and nothing.
I then decided to give the DF Robot module a try, used pin 16 and that worked straight away.
I think that is why I do not like ESP, apart from the dreadful gamble when setting up the toolchain you have all this to deal with. I have no idea where I got it from (probably Amazon or eBay) and even less chance of finding the actual datasheet so I will probably find my biggest hammer tomorrow and relegate the module to the WEE bin with no chance of return.

At least I have your code to look at for the interrupt which will make the code more robust.

regards,
Bob

Post Reply