Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict Between Wifi & analogRead() in ESP32s #4187

Closed
marwinwijaya opened this issue Jul 19, 2020 · 8 comments
Closed

Conflict Between Wifi & analogRead() in ESP32s #4187

marwinwijaya opened this issue Jul 19, 2020 · 8 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@marwinwijaya
Copy link

ESP32-Pinout
I have a problem about esp32s, where when I use the Wifi.h lib some analogRead () always produces a value of 4095, I try on pin 0 of esp32s, is there a pin that can be used simultaneously between wifi and analogRead ()? I attach a picture pinout esp32s Thanks you

@sansillusion
Copy link

sansillusion commented Jul 19, 2020 via email

@marwinwijaya
Copy link
Author

ADC1 pin is IO34, IO35, IO32, IO33 @sansillusion ?

@sansillusion
Copy link

I would think so, I did not have to use ADC yet, just remember seeing this being a recurrent issue for people here.

@atanisoft
Copy link
Collaborator

@marwinwijaya all pins above 30 are ADC1.

@marwinwijaya
Copy link
Author

thank you @sansillusion and @atanisoft

@stale
Copy link

stale bot commented Sep 18, 2020

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Sep 18, 2020
@stale
Copy link

stale bot commented Oct 3, 2020

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Oct 3, 2020
@qiaoyukeji
Copy link

我在用 esp32cam 时,wifi 与 adc2 不能同时使用,使用 wifi 时 adc2 读数一直为0。后来,我尝试交替使用 wifi 与 adc2 ,例如每10秒钟断开wifi一次,读取adc2的值,然后重新连接wifi,使两个功能都能使用,经过测试,能够正常使用。

Arduino 的代码如下:

#include <Arduino.h>
#include <WiFi.h>
#include "esp_camera.h"
#include <vector>
#include <string.h>
using namespace std;

// ph and tem 变量设置
const int phPin = 2;
float ph;
float Value = 0;

// wifi 
const char *ssid = "TP-LINK_1760";
const char *password = "987654321";

void wifi_init() {
  WiFi.mode(WIFI_STA);
  WiFi.setSleep(false);  //关闭STA模式下wifi休眠,提高响应速度
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("WiFi Connected!");
  Serial.print("IP Address:");
  Serial.println(WiFi.localIP());
}



void setup() {

  Serial.begin(115200);
  //  wifi 初始化
  wifi_init();

  pinMode(phPin, INPUT);
}
void loop() {
  // 关闭 wifi
  WiFi.disconnect(true);
  WiFi.mode(WIFI_OFF);
  
  // adc2 读取 phPin 上的数据
  pinMode(phPin, INPUT);
  Value = analogRead(phPin);
  
  // 打开 wifi
  wifi_init();
  Serial.print(Value);
  delay(500);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

4 participants