ESP32 - 토양 습도 센서 펌프 | ESP32 - Soil Moisture Sensor Pump

이 튜토리얼에서는 ESP32를 사용하여 용량성 토양 수분 센서에서 읽은 값에 따라 펌프를 제어하는 방법을 배우게 됩니다.

준비물

1×ESP-WROOM-32 Dev Module 쿠팡 | Amazon
1×USB Cable Type-C 쿠팡 | Amazon
1×Capacitive Soil Moisture Sensor Amazon
1×Relay Amazon
1×12V Pump Amazon
1×Vinyl Tube Amazon
1×12V Power Adapter Amazon
1×(Optional) DC Power Jack 쿠팡 | Amazon
1×Breadboard 쿠팡 | Amazon
1×Jumper Wires Amazon
1×(Recommended) ESP32 Screw Terminal Adapter 쿠팡 | Amazon
공개: 이 섹션에서 제공된 링크 중 일부는 제휴 링크입니다. 이 링크를 통해 구매한 경우 추가 비용없이 수수료를 받을 수 있습니다. 지원해 주셔서 감사합니다.

Buy Note: Many soil moisture sensors available in the market are unreliable, regardless of their version. We strongly recommend buying the sensor from the DIYables brand using the link provided above. We tested it, and it worked reliably.

토양 수분 센서 및 펌프에 관하여

펌프와 토양 수분 센서(핀배열, 작동 방식, 프로그래밍 방법 등)에 대해 잘 모른다면, 다음 튜토리얼에서 배워보세요:

작동 원리

ESP32는 주기적으로 정전 용량식 토양 수분 센서에서 값을 읽습니다. 토양의 수분 값에 따라 다음과 같은 조치를 취할 것입니다:

  • 만약 토양 수분 값이 임계값보다 낮으면, ESP32는 자동으로 릴레이를 활성화해 펌프를 켭니다.
  • 그렇지 않으면, ESP32는 자동으로 릴레이를 비활성화해 펌프를 끕니다.

선연결

ESP32 soil moisture sensor Pump Wiring Diagram

이 이미지는 Fritzing을 사용하여 만들어졌습니다. 이미지를 확대하려면 클릭하세요.

ESP32 및 다른 구성 요소에 전원을 공급하는 방법에 대해 잘 알지 못하는 경우, 다음 튜토리얼에서 안내를 찾을 수 있습니다: ESP32 전원 공급 방법.

ESP32 코드

/* * 이 ESP32 코드는 newbiely.kr 에서 개발되었습니다 * 이 ESP32 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/esp32/esp32-soil-moisture-sensor-pump */ #define RELAY_PIN 17 // ESP32 핀 GPIO17이 릴레이에 연결됩니다 #define MOISTURE_PIN 36 // ESP32 핀 GPIO36 (ADC0)이 수분 센서의 AOUT 핀에 연결됩니다 #define THRESHOLD 2800 // => 여기서 당신의 임계값을 변경하세요 void setup() { Serial.begin(9600); pinMode(RELAY_PIN, OUTPUT); } void loop() { int value = analogRead(MOISTURE_PIN); // 토양 수분 센서에서 아날로그 값을 읽습니다 if (value > THRESHOLD) { Serial.print("The soil moisture is DRY => activate pump"); digitalWrite(RELAY_PIN, HIGH); } else { Serial.print("The soil moisture is WET=> deactivate the pump"); digitalWrite(RELAY_PIN, LOW); } Serial.print(" ("); Serial.print(value); Serial.println(")"); delay(1000); }

사용 방법

  • ESP32를 처음 사용하는 경우, Arduino IDE에서 ESP32 환경 설정하는 방법을 참조하세요.
  • 젖은 상태와 건조한 상태의 기준값을 결정하기 위해 보정 작업을 수행하세요. ESP32 - 토양 수분 센서 보정하기를 참조하세요.
  • 보정된 값을 코드의 THRESHOLD에 업데이트하세요.
  • Arduino IDE에서 시리얼 모니터를 엽니다.
  • 코드를 ESP32로 업로드하세요.
  • 시리얼 모니터에서 결과를 확인하세요.
COM6
Send
The soil moisture is DRY => activate the pump The soil moisture is DRY => activate the pump The soil moisture is DRY => activate the pump The soil moisture is DRY => activate the pump The soil moisture is WET=> deactivate the pump The soil moisture is WET=> deactivate the pump The soil moisture is WET=> deactivate the pump The soil moisture is WET=> deactivate the pump
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

코드 설명

소스 코드의 주석 라인에서 줄별 설명을 읽어보세요!

동영상

비디오 제작은 시간이 많이 걸리는 작업입니다. 비디오 튜토리얼이 학습에 도움이 되었다면, YouTube 채널 을 구독하여 알려 주시기 바랍니다. 비디오에 대한 높은 수요가 있다면, 비디오를 만들기 위해 노력하겠습니다.

※ OUR MESSAGES

  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!