-
Notifications
You must be signed in to change notification settings - Fork 7.6k
ADC2 Channel cannot be used when WiFi is in use #440
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
Comments
I was just tracking this. I set up a simple circuit with a pot from VCC to GND with the wiper connected to IO34 and IO25. IO34 is ADC1, IO25 is ADC2. I used the following code in the Arduino IDE v1.8.1:
Results with WiFi.begin() in the code (binary size 507808 bytes):
Results with WiFi.begin() commented out (binary size 299472 bytes):
Before testing I completely wiped the flash on the device using
Let me know if there is any more information you need. |
I found some information here: The comment is from igrr saying: I have yet to find confirmation of this in the data sheets, but I am still looking. |
Seems now I have confirmation that this is not a software bug. It is the chip itself. This will not get fixed in software. |
It seems that ADC2 is used with WiFi and maybe BlueTooth. That is why it is unavailable. So this might be fixed, but won't be fixed in this software. It will get fixed in the SDK. |
Let's concentrate ADC2 conflict with wifi here: #440 |
I am just curious that you said we should concentrate the discussion in this bug, then closed this bug. Did you mean to point to a different bug? |
Oh, I linked the wrong issue, this is the correct one (which I think is the same discussion): #102 |
For the record, resetting registers SENS_SAR_START_FORCE_REG and SENS_SAR_READ_CTRL2_REG to the old values they had before WiFi was turned seem to be a work around for this issue. And will allow you to use ADC2 again after you stop and deinitialize WiFI. An algorithm here would be something like: |
I forgot to include the SENS_SAR_MEAS_START2_REG register. This one is important too. |
@danielcolchete, do you have the Arduino code to fix the ADC2 problem by any chance? I'm trying to use Bluetooth to send analog values from ADC2. I have no luck so far. |
ADC2 cannot be used with WiFi or Bluetooth? Well this code just proves that statement wrong!
When doing a varistor sweep + using a DualShock PS4 controller via bluetooth connected to my ESP32:
|
@grasmanek94 I did this your way, but it won't work. Only after removing the writing of reg_a and reg_c will I get some differing values although they are inverted and only have attenutation of 1db |
In the technical reference you probably can find the registers for the inverted values (something that can be disabled) and also change the attenuation, I think. The code I posted is created from multiple snippets throughout my codebase but simplified, It's possible that I missed analogSetAttenuation (or whatever the function is called). |
To fix the inverted values: #102 (comment) |
ESTO ME FUNCIONO!!!!!!!!!!! Muchas gracias por los aportes. Les cuento: Tengo un ESP32 TTGO HIGROW, necesito leer en pin ADC 15 un sensor de humedad del suelo y enviarlo a mi plataforma IoT, obviamente necesito WiFI para eso. Aquí mi proyecto: https://github.com/ISProjectsIoTCR/SensorSueloTTGO Lo hice asÍ: 1-Leer sensores La primer lectura del sensor lo hacía bien, pero despues del lapso en sueño profundo, me disparaba un valor en alto de mi pin analógico. Eso pasa porque despues de usar analogRead iniciaba mi Wifi y modificaba esos registros que se mencionan en este hilo. Aun no entiendo mucho sobre esos regitros pero hice lo que pude leer aquí. Lo mejoré asÍ: 1-Leer sensores AL INICIO DEL CODIGO=> #define DR_REG_SENS_BASE 0x3ff48800 DECLARAR VARIABLES GLOBALES "uint64" => uint64_t reg_a; JUSTO ANTES DE INICIAR LA CONEXIÓN WIFI=> reg_a = READ_PERI_REG(SENS_SAR_START_FORCE_REG); ANTES DE IR A DORMIR=> WRITE_PERI_REG(SENS_SAR_START_FORCE_REG, reg_a); // fix ADC registers Y LISTO!!! FUNCIONÓ |
I can confirm that this is working as a workaround.
BUT, its broken in the newer version of ESP32 in arduino. This works on 1.0.3 at the moment. I cant understand why they took it away. |
When
WiFi.begin(...)
, I can't read all ADC2's channel.All value is incorrect.
The text was updated successfully, but these errors were encountered: