Problem with esp32 WIFI + UVM-30a sensor

Hello every one.
i test UVM sensor with code this is work .
value in UVM sensor can read to Serial monitor.

int analogApin = 15; // define OUT signal pin
int analogA; // define variable to store value read from pin

void setup() {
Serial.begin(115200);
pinMode(analogApin, INPUT);
}
void loop() {
analogA = analogRead(analogApin); // read the voltage level on the A0
Serial.println((String)"UV level: " + analogA); // send the result to the serial monitor

delay(200); // pause for a moment before repeating
}

but if i write code WIFI to board esp32 , sensor just show 0 value only , no change value anything.

#include <WiFi.h>
#include <SPI.h>
char* ssid = "xxxxxxxxx";
char* password = "xxxxxxxx";

int analogApin = 15; // define OUT signal pin
int analogA; // define variable to store value read from pin
void setup() {
Serial.begin(115200);
pinMode(analogApin, INPUT);
WiFi.begin(ssid , password);
Serial.println("Flux Workshop Example");
// set the OUT signal pin as an input
}

void loop() {
analogA = analogRead(analogApin); // read the voltage level on the A0
Serial.println((String)"UV level: " + analogA); // send the result to the serial monitor

delay(500); // pause for a moment before repeating
}

what should i do , with problem this
thank you.

int analogApin = 15; // define OUT signal pin

Do not use any pins on the GPIO portA for analog to digital conversions with an ESP32. The GPIO pins on portB are set up for analog to digital conversions use pins 33+.

Setting up an ESP32 for analog to digital conversions using the ESP32 API is not that difficult and gives a more stable output.

Include the ESP32 adc library.

#include <driver/adc.h>

in setup() initialize the analog to digital channel.

// set up A:D channels, refer: https://dl.espressif.com/doc/esp-idf/latest/api-reference/peripherals/adc.html
  adc1_config_width(ADC_WIDTH_12Bit);
  adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_11);// using GPIO 36

Using analog to digital converter 1 (the esp32 has 2).

adc1_config_width(ADC_WIDTH_12Bit); sets the analog to digital converter to 12 bits.
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_11); set the analog converter on GPIO_NUM_36 to use the full range reference voltage of 3.3V.

adcValue = float( adc1_get_raw(ADC1_CHANNEL_0) ); //take a raw ADC reading

is used to take an AD reading.

pinMode( (36 or 39, or 35, or 35, or 33) , INPUT); works as well and may be easier.

Idahowalker:
Setting up an ESP32 for analog to digital conversions using the ESP32 API is not that difficult and gives a more stable output.

Include the ESP32 adc library.

#include <driver/adc.h>

in setup() initialize the analog to digital channel.

// set up A:D channels, refer: https://dl.espressif.com/doc/esp-idf/latest/api-reference/peripherals/adc.html

adc1_config_width(ADC_WIDTH_12Bit);
 adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_11);// using GPIO 36




Using analog to digital converter 1 (the esp32 has 2).

adc1_config_width(ADC_WIDTH_12Bit); sets the analog to digital converter to 12 bits.
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_11); set the analog converter on GPIO_NUM_36 to use the full range reference voltage of 3.3V.



adcValue = float( adc1_get_raw(ADC1_CHANNEL_0) ); //take a raw ADC reading



is used to take an AD reading.

pinMode( (36 or 39, or 35, or 35, or 33) , INPUT); works as well and may be easier.

Idahowalker:
Setting up an ESP32 for analog to digital conversions using the ESP32 API is not that difficult and gives a more stable output.

Include the ESP32 adc library.

#include <driver/adc.h>

in setup() initialize the analog to digital channel.

// set up A:D channels, refer: https://dl.espressif.com/doc/esp-idf/latest/api-reference/peripherals/adc.html

adc1_config_width(ADC_WIDTH_12Bit);
 adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_11);// using GPIO 36




Using analog to digital converter 1 (the esp32 has 2).

adc1_config_width(ADC_WIDTH_12Bit); sets the analog to digital converter to 12 bits.
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_11); set the analog converter on GPIO_NUM_36 to use the full range reference voltage of 3.3V.



adcValue = float( adc1_get_raw(ADC1_CHANNEL_0) ); //take a raw ADC reading



is used to take an AD reading.

pinMode( (36 or 39, or 35, or 35, or 33) , INPUT); works as well and may be easier.

thank you very much , i will do as your suggest me today this.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.