Skip to content

GPIO input mode with softAP #953

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

Closed
Aswinvt opened this issue Dec 29, 2017 · 2 comments
Closed

GPIO input mode with softAP #953

Aswinvt opened this issue Dec 29, 2017 · 2 comments

Comments

@Aswinvt
Copy link

Aswinvt commented Dec 29, 2017

Hardware:

Board: ESP32 Dev Module
IDE name: Arduino IDE
Flash Frequency: 80Mhz
Upload Speed: 115200

Description:

I am trying to read analog value from some sensors using ESP32 and that values are needed to be viewed in a browser, for that I have made ESP32 as AP, but after setting it as AP the only raw analog read value that I get is 4095.

Test code:

#include <WiFi.h>

 
const char *ssid = "TestAP";
const char *password = "testappwd";
 
void setup(){
  Serial.begin(115200);
  pinMode(0, INPUT);
  WiFi.softAP(ssid, password);
  Serial.println();
  Serial.print("IP address: ");
  Serial.println(WiFi.softAPIP());
}
 
void loop(){
  float IN = analogRead(0);
  Serial.println(IN);
  delay(1000);
}

Above is a test code to verify this issue after setting the ESP32 as AP the analogRead function only returns a value of 4095 only, otherwise it gives correct values.

I don't know whether I am missing out anything. Please help me out with this problem.

Thanks.

@beegee-tokyo
Copy link
Contributor

beegee-tokyo commented Dec 29, 2017

You might get this problem because ADC2 channel cannot be used when WiFi is in use or Conflict Between Wifi & analogRead()? . Try to use another ADC channel. I am using the following (just an extract of my code) to read the analog value from a LDR. No AP here though, I am using WiFi in STA mode:

/** Pin number for LDR analog input pin */
int ldrPin = 36;
/** LDR light value = 0 if not updated */
long newLDRValue = 0;

void setup(void) {
  // Initialize analog port for LDR
  pinMode(ldrPin,INPUT);
  adcAttachPin(ldrPin);
  analogReadResolution(11);
  analogSetAttenuation(ADC_6db);
}

void loop(void) {
  // Read analog value of LDR
  newLDRValue = analogRead(ldrPin);
}

I made a list of ADC channel pin assignments in my WiKi

@Aswinvt
Copy link
Author

Aswinvt commented Dec 29, 2017

Thank you for the reply. After changing to the ADC1 analog read is working without any problem.

@Aswinvt Aswinvt closed this as completed Dec 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants