电容性水分传感器+ ESP32常量4095

发布于 2025-01-30 20:04:13 字数 664 浏览 4 评论 0 原文

我正在尝试从电容性水分传感器中读取价值()来自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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜巴黎 2025-02-06 20:04:13

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文