ESP32 WiFi / ADC conflict

Use this section to discuss your embedded Flowcode projects.
Post Reply
nmjb18
Posts: 22
http://meble-kuchenne.info.pl
Joined: Mon Apr 19, 2021 4:47 pm
Has thanked: 10 times
Been thanked: 1 time

Flowcode v10 ESP32 WiFi / ADC conflict

Post by nmjb18 »

Hi,

Has anyone else experienced issues using both an ADC and the WiFi components on a ESP32 Vroom? When I sample the ADC following connecting to a WiFi network the ESP does not respond as expected and restarts the program. If I run the program without a WiFi connection it is stable. Similarly, if I run the program with WiFi but don't sample the ADC it's also stable. Call the two together and it falls over.

Attached bellow is a stripped down version of a much larger automation project. This was the least functionality I could maintain and still demonstrate the issue. The complete program works well, unless you connect to a WiFi network, then its erratic. If any one fancies taking a look, if you run the program as is, it will fall over if the 'Up' or 'Down' inputs are triggered following the initial start-up routine. If you remove the ADC sampling before the main loop the program will run as expected.

I don't know if this is a bug in FC, or there is a strange conflict internal to the ESP between the ADC on channel An38 and the WiFi processes? Any advice or insight would be much apricated!

Cheers,

MB
Attachments
Sample code.fcfx
(56.46 KiB) Downloaded 133 times

mnfisher
Valued Contributor
Posts: 1133
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 114 times
Been thanked: 596 times

Re: ESP32 WiFi / ADC conflict

Post by mnfisher »

As a test - connect to the esp 32 via serial and open a terminal program on your pc.. I use PuTTY but there are many such as realterm which work well.

When the mcu crashes it will spit some debug info out.. Connect at 115200 baud and compile in debug mode (the default)

Martin

mnfisher
Valued Contributor
Posts: 1133
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 114 times
Been thanked: 596 times

Re: ESP32 WiFi / ADC conflict

Post by mnfisher »

I'd hazard a guess that it's a WDT issue...

Martin

nmjb18
Posts: 22
Joined: Mon Apr 19, 2021 4:47 pm
Has thanked: 10 times
Been thanked: 1 time

Re: ESP32 WiFi / ADC conflict

Post by nmjb18 »

Thanks Martin, I will give it a go and report back.

medelec35
Matrix Staff
Posts: 1560
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 555 times
Been thanked: 514 times

Re: ESP32 WiFi / ADC conflict

Post by medelec35 »

Hello.
I have Just looked at the Eblocks2 datasheet for the ESP32 Upstream board.
On page 59 there is a diagram illustrating what ADC channels you can use at the same time as Bluetooth and WiFi.
You are using An38
Available ADC channels.png
Available ADC channels.png (48.6 KiB) Viewed 2116 times
On the ESP32 you get ADC1 (White background) and ADC2 (Orange background).
The issue will be WiFi shares with ADC2, hence there will be issues with ADC as WiFi will have priority.
This is from espressif inc.
To avoid confusion, the above espressif inc link refers to IO channels which are the channels NOT within brackets on the EBlocks 2 document, which was included as it shows the ADC channels within Flowcode.
Martin

nmjb18
Posts: 22
Joined: Mon Apr 19, 2021 4:47 pm
Has thanked: 10 times
Been thanked: 1 time

Re: ESP32 WiFi / ADC conflict

Post by nmjb18 »

Hi Martin,

Thanks for the additional info, I can confirm this was the issue. Further reading reinforces your post that all ADC2 pins are affected and cannot be used when either Bluetooth or WiFi is implemented. Moving my current sensing to a pin on ADC1 solved the problem.

Thanks again for your attention.

MB

Post Reply