我正在尝试从电容性水分传感器中读取价值()来自ESP32。
我将传感器连接到PIN GPIO 0,但是即使传感器干燥或潮湿,返回的值也是恒定的4095。我尝试使用3.3V和5V,但结果是相同的。
即使我断开数据销,值仍然为4095。
我读到4095是连接到5V的传感器上返回的最大值,但不确定我在这里做什么。
这是我使用的代码:
const int moisturePin = 0;
void setup() {
Serial.begin(115200);
}
void loop() {
float moistureValue = analogRead(moisturePin);
Serial.println(moistureValue);
delay(30000);
}
感谢您的任何帮助。
I am trying to read value from a capacitive moisture sensor (https://www.amazon.fr/Capacitive-Moisture-Corrosion-Resistant-Raspberry/dp/B07FLR13FS) from an ESP32.
I connected the sensor to pin GPIO 0 but the value returned is a constant 4095 even if the sensor is dry or wet. I tried to use 3.3v and 5v but the result is the same.
Even if I disconnect the data pin the value is still 4095.
I've read that 4095 is the max value returned on a sensor connected to 5v but not sure what I am doing here.
This is the code I am using:
const int moisturePin = 0;
void setup() {
Serial.begin(115200);
}
void loop() {
float moistureValue = analogRead(moisturePin);
Serial.println(moistureValue);
delay(30000);
}
Thanks for any help.
发布评论
评论(1)
GPIO 0是连接ADC2的,如果也使用WiFi,则不使用。
将传感器连接到GPIO 34/35,然后重试。而且切勿将5V连接到ESP…可能没有生存。
还设置了pinmode(函数arduino),因此引脚是输入。在ESP32数据表中,您可以找到对每个引脚编号的引用,以及它属于ADC1/2
GPIO 0 is ADC2 connected, which is not to be used if WiFi is also used.
Connect the sensor to GPIO 34/35 and try again. And never attach 5V to the ESP… possibly that one didn’t survive.
Also set pinMode (function Arduino), so the pin is an input. In the ESP32 datasheet you can find the reference to each pin number and if it belongs to ADC1/2