Home » Basic analog test example for an ESP32 board

Basic analog test example for an ESP32 board

by shedboy71

This is a very basic example for the ESP32 board, the only reason for this is to show that unlike the ESP8266 boards the ESP32 has more than one Analog pins – in fact it has 12 analog pins

Once you have added ESP32 support to the Arduino IDE then select the Wemos Lolin 32 board and the correct port.

Code

 

int analog0;
int analog1;
int analog2;
int analogVal0 = 0;
int analogVal1 = 0; 
int analogVal2 = 0; 

void setup() 
{
Serial.begin(9600); // use the serial port to send the values back to the computer 
}

void loop()
{
analogVal0 = analogRead(analog0); // read the value from the sensor
analogVal1 = analogRead(analog1);
analogVal2 = analogRead(analog2);

Serial.println("analogVal0"); // print the value to the serial port 
Serial.println(analogVal0);
Serial.println("analogVal1"); // print the value to the serial port
Serial.println(analogVal1);
Serial.println("analogVal2"); // print the value to the serial port
Serial.println(analogVal2);
}

 

Output

Open the serial monitor and you should see something like this

analogVal0
404
analogVal1
384
analogVal2
364
analogVal0
416
analogVal1
393
analogVal2
368

 

Link

WEMOS LOLIN32 V1.0.0 Wifi Bluetooth Board ESP-32 4MB Flash

You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.