Detailed explanation of application effect and code of soil humidity sensor base on nodemcu/ESP12F

9 篇文章 0 订阅
8 篇文章 0 订阅

First, attach the effect drawing. In order to facilitate debugging and writing code, I use ** Arduino ide ** to write code.
Window monitor print real-time effect:
Window monitor print real-time effect

The hardware circuit diagram is drawn by myself and made by the merchant. The following figure is my actual hardware diagram.
Hardware diagram

The soil moisture sensor I use

This is the soil moisture sensor I bought

Pin details as shown in the figure

Pin details

Wiring between soil moisture sensor and nodemcu(ESP12F/ESP8266 can also be referred)

Wiring diagram

What is read in the code is the analog signal value. In fact, only three pins * AO, GND and VCC * are connected

Next is the code section:

/**********************************************************************
author:燊哥仔
bilibili Video Explanation:https://www.bilibili.com/video/BV1Lp4y1s7J4
The code is very simple. You can see the effect by using the serial port monitor of IDE
Actually connect three pins is OK AO、GND、VCC
***********************************************************************/
int sense_Pin = 0; // Soil sensor input connected to analog pin A0
int value = 0; //initialize variable value

void setup() {
  Serial.begin(115200);//Set baud rate to115200
  Serial.println("\n");//Newline
}

void loop() {
  
  value = analogRead(sense_Pin);//Analog data reading(A0 pin input data)
  value = value / 10;    //The above value divided by ten is assigned to value
 
  Serial.print(value);
  Serial.println("%");
 
  if (value < 50)//When the value is less than 50, judge the result
  {
    
    Serial.println("The soil is WET");//Window monitor print the situation
  }
  else
  {
  
    Serial.println("The soil is dry");
  }
  delay(1000);//Delay1 second. Read every second
}

Download code from CSDN

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值