一、硬件上:
1、使用esp32开发板的04引脚与AO连接,检测AO引脚的电平
二、软件上:
1、使用Arduino快速完成开发
2、源码:
// Potentiometer is connected to GPIO 04 (Analog ADC1_CH3)
const int adcPin = 4;
// variable for storing the potentiometer value
int adcValue = 0;
float AirQuality;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
// Reading potentiometer value
adcValue = analogRead(adcPin);
// Serial.println(adcValue);
//Convert to air quality
AirQuality = ((float)((float)adcValue * 3.3)/4096);
Serial.printf("adc: %d,air: %f\r\n",adcValue,AirQuality);
delay(500);
}