วันอาทิตย์ที่ 21 ตุลาคม พ.ศ. 2561

Microcontroller16

โปรเจคเครื่องรดน้ำต้นไม้อัตโนมัติ ด้วย Arduino ราคาถูก พร้อม Code ตัวอย่าง



อุปกรณ์

Arduino Uno R3 พร้อมสาย USBModule รีเลย์ relay 1 Chanel 250V/10A Active HIGH IISoil Moisture Sensor Module วัดความชื่นในดินปั๊มน้ำ DC ขนาดเล็กสายยางปั้มน้ำ DC ยาว 1 เมตรAdapter 5V 1A หม้อแปลง 5V 1 แอมป์ IIPower connector 5.5 mm (ตัวเมีย) PCBสายแพร Jumper Male to Female ยาว 20CM จำนวน 10 เส้น

Wiring diagram





Code ทดสอบการทำงาน

const int analogInPin = A0; const int Relay = 2;

int sensorValue = 0;        // ตัวแปรค่า Analog int outputValue = 0;        // ตัวแปรสำหรับ Map เพื่อคิด %

void setup() {   Serial.begin(9600);   pinMode(Relay, OUTPUT); }

void loop() {   sensorValue = analogRead(analogInPin);

  Serial.print("Soil Moisture = ");   Serial.print(outputValue);   Serial.println(" %");

  if (outputValue <= 40) {  //ตั้งค่า % ที่ต้องการจะรดน้ำต้นไม้     digitalWrite(relay, HIGH);   }   else {     digitalWrite(relay, LOW);   }   delay(1000); }

หลักการทำงานของระบบรดน้ำต้นไม้อัตโนมัติ

โดยปกติแล้ว พืชจะต้องการความชื้นในดินอยู่ที่ประมาณ 40% (แล้วแต่พิชในแต่ละชนิดด้วยน่ะครับ) Sensor วัดความชื้นในดินจะทำการวัดค่าความชื้นในดิน โดยสัญญาณที่ได้ออกมาจะเป็นแบบ Analog ป้อนไปยัง Arduino เพื่อประมวลผล เมื่อ Arduino ได้ทำการวัดตรงตามเงือนไข ก็จะทำการส่ง Logic ไปยัง Relay เพื่อทำการเปิดปั้มน้ำไปรดน้ำต้นไม้ แค่นี้ก็จะได้ โปรเจครดน้ำต้นไม้แบบง่ายๆ

ไม่มีความคิดเห็น:

แสดงความคิดเห็น