• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Wifi disconnect with ESP32 issue

Q&A Forum › Category: ESP32 › Wifi disconnect with ESP32 issue
0 Vote Up Vote Down
David Hughes asked 6 years ago

I understand that using wifi wipes out some of the pins on the ESP32 (I can not remember which, help?).

However what would be great is to be able to connect wifi and then disconnect it. wifi.disconnect does not seem to work.

I heard there was a way round it using esp_wifi but I can’t figure out how to find our install this correctly.

At present when i use wifi a whole load of pins stop working.

Can you help out?

Question Tags: wifi
5 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 6 years ago

Hi.

When you use wi-fi, you cannot use analog input on ADC 2 pins.

When you say that wifi.disconnect() is not working, what do you mean?

After calling WiFi.disconnect() you can print the Wifi status with: WiFi.status()

Which pins stop working when using wifi and what functionalities are you trying to use on those pins?

Regards,

Sara

0 Vote Up Vote Down
David Hughes answered 6 years ago

Hi Sara, before connecting wifi in the sketch the analogue pins I am using only report a value of 4095 when before they were functional. 
What I wanted to do was connect wifi and then disconnect it, so I can use the pins as before. After calling wifi.disconnect, the problem continues. On searching on the web, i see others have had this issue. Apparently es_wifi_disconnect() needs to be used, but I am not sure how to implement that.
The pins I am using are 12, 14, 13, 39, 26, 15, 32, 27, 12, 23. Some of these are used as analogue pins and some enable power to sensors, so it will take a bit of digging to determine which is out, but some of these use ADC2. What I would like to do is use the pins, gather data, switch wifi on, report data, disconnect wifi and reuse the pins, but the issue is once wifi has been used once, wifi.disconnect does not release the pins. Do I need to resassign then perhaps or can I use a different disconnect command?
 
David
 
ps you guys do an awesome job!

0 Vote Up Vote Down
Sara Santos Staff answered 6 years ago

Hi David.

You’re using a lot of ADC2 pins. Those won’t work when the Wi-Fi is on.

I’ve searched about disconnecting Wi-Fi to read the ADC2 pins, and it seems that you need to call some commands after disconnecting WiFi to make the ADC2 work again.

I’ve read about it here: https://github.com/espressif/arduino-esp32/issues/102#issuecomment-496284224

You also need to include:

#include <soc/sens_reg.h>

I haven’t tested this, but accordingly to the comments on the forum, it should work.

Alternatively, you can consider using ADC1 pins.

I hope this helps and thank you for following and supporting our work.

Regards,
Sara

0 Vote Up Vote Down
David Hughes answered 6 years ago

Many thanks. I will look into that, but I have avoided the problem for now by changing rounds some pins and only use ADC1 for alanogue.
 
David

0 Vote Up Vote Down
Sara Santos Staff answered 6 years ago

Ok.
If you end up trying the other workaround, then let me know if it works.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.