Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 89 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
89
Dung lượng
5,52 MB
Nội dung
MINISTRY OF EDUCATION AND TRAINING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY AND EDUCATION FACULTY FOR HIGH QUALITY TRAINING ELECTRONICS AND TELECOMMUNICATION ENGINEERING TECHNOLOGY IOT-BASED AUTOMATIC MONITORING AND CONTROL SYSTEM FOR AGRICULTURE LECTURER: DO DUY TAN STUDENT : DAO DUY TUNG VO BANG TRANH SKL 0 Ho Chi Minh City, August, 2020 HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY AND EDUCATION FACULTY FOR HIGH QUALITY TRAINING - - GRADUATION THESIS IOT-BASED AUTOMATIC MONITORING AND CONTROL SYSTEM FOR AGRICULTURE DAO DUY TUNG Student ID: 17141034 VO BANG TRANH Student ID: 17141146 Major: ELECTRONIC AND COMMUNICATION ENGINEERING TECHNOLOGY Advisor: DO DUY TAN, M.Eng Ho Chi Minh City, August 2022 HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY AND EDUCATION FACULTY FOR HIGH QUALITY TRAINING - - GRADUATION THESIS IOT-BASED AUTOMATIC MONITORING AND CONTROL SYSTEM FOR AGRICULTURE DAO DUY TUNG Student ID: 17141034 VO BANG TRANH Student ID: 17141146 Major: ELECTRONIC AND COMMUNICATION ENGINEERING TECHNOLOGY Advisor: DO DUY TAN, M.Eng Ho Chi Minh City, August 2022 ii THE SOCIALIST REPUBLIC OF VIETNAM Independence – Freedom– Happiness -Ho Chi Minh City, July 27th, 2022 ADVISOR’S EVALUATION SHEET Student name: Dao Duy Tung Student ID: 17141034 Student name: Vo Bang Tranh Student ID: 17141146 Major: Electronics and Communication Engineering Technology Project title: IOT-BASED AUTOMATIC MONITORING AND CONTROL SYSTEM FOR AGRICULTURE Advisor: M.Eng Do Duy Tan EVALUATION Content of the project: - The team implements the content that meets the requirements set out initially Strengths: - The group made the graduation thesis on schedule and reported on the complete process - The content of the report presents a clear layout Weaknesses: -The topic of designing a garden care system using IoT technology has been implemented by many groups before show before - It is recommended to supplement the garden monitoring table in a certain period of time to evaluate the effectiveness - Some images are not good quality Approval for oral defense? (Approved or denied): APPROVAL Overall evaluation: (Excellent, Good, Fair, Poor): Mark: 8.2 (in words: Eight point two ) Ho Chi Minh City, ADVISOR (Sign with full name) iii HCMC University of Technology and Education Faculty for High Quality training Socialist Republic of Vietnam Independence - Liberty – Happiness Ho Chi Minh City, July 27th, 2022 PROJECT ASSIGNMENT Name of Members: Dao Duy Tung Student ID: 17141034 Vo Bang Tranh Student ID: 17141146 Training system: Regular university Major: Electronics and communication engineering technology Class: 17141CLA2; 17141CLS I NAME OF PROJECT: IOT-BASED AUTOMATIC MONITORING AND CONTROL SYSTEM FOR AGRICULTURE II ASSIGNMENT Content of implementation - Present the theoretical basis of greenhouse models, wifi standards, protocols UART, I2C communication - Design block diagrams and schematic diagrams of the entire system - Present and analyze the operating modes of the system - Analyze and evaluate the resource usage of the design - Provide general conclusions and development direction of the topic Product - Evaluation results on the real paradigm III DATE OF RECEIVING TASK: IV DATE OF TASK COMPLETION: V ADVISOR: M.Eng Do Duy Tan CHAIR OF THE PROGRAM (Sign with full name) ADVISOR (Sign with full name) i HCMC University of Technology and Education Faculty for High Quality training Socialist Republic of Vietnam Independence - Liberty – Happiness Ho Chi Minh City, July 27th, 2022 PROJECT IMPLEMENT SCHEDULE Name of Members: Dao Duy Tung Student ID: 17141034 Vo Bang Tranh Student ID: 17141146 Class: 17141CLA2; 17141CLS Name of project: IOT-BASED AUTOMATIC MONITORING AND CONTROL SYSTEM FOR AGRICULTURE Week/Date 1st (7/3-13/3) Content Meet Instructor to disseminate regulations: choose topic, working time - Instructor conducts review of the topic 2st - Write a summary of the requirements of the (14/3-20/3) selected topic: Reasons and objectives of the topic, design content, limited parameters of the topic 3nd (21/3-27/3) 4rd (28/3-4/4) Write the plan and detail outlines for the topic - Design block diagram - Design the principal diagram and explain the function of each block - Search for knowledge, information about the 5th (5/4-11/4) characteristics, temperature, and humidity of plants - Find out the sensors used in the subject ii Lecture Confirm - Learn about how to program apps on smartphone phone 6th (12/4-18/4) 7th (19/4-25/4) 8th Calculate the parameter of component and choose the suitable material Complete schematic and layout of components on the circuit board Design and construction of central control block (26/4-2/5) 9th (3/5-9/5) 10th - Programming to connect operating modules in the system (10/5-16/5) - - Design the interface on Blynk App though 11th smartphone (17/5-23/5) 12th (14/5-30/5) 13th (31/5-6/6) 14th - Implement the circuit board - Model building (7/6-13/6) 15th (14/6-20/6) 16th (21/6-27/6) 17th (28/6-4/7) - Implement, test and fix the Project - Write the report Complete the report and send it to Instructor to review and comment for the last time before printing the report Summit the report and slide PowerPoint iii DISCLAIMER We guarantee that this project is our research, under M.Eng Do Duy Tan's guidance The results published in this project are honest and are not replicated from any other work STUDENTS Vo Bang Tranh iv Dao Duy Tung ACKNOWLEDGMENTS Foremost, our group would like to express our sincere thanks to the teachers in the Faculty of High Quality Training During the time studying at the school, the teachers were dedicated to teaching and imparting to their group knowledge, experience and motivation in the learning process We sincerely thank to my advisor for his continued support and encouragement: M.Eng Do Duy Tan We offer our sincere appreciation for the learning opportunities provided by my lecturer Besides my advisor, we would like to thank our friends who shared knowledge and valuable experiences during the implementation of the project Finally, we would like to thank our family for giving time to care and supporting us spiritually throughout our life Sincerely! STUDENTS Vo Bang Tranh v Dao Duy Tung TABLE OF CONTENTS PROJECT ASSIGNMENT i PROJECT IMPLEMENT SCHEDULE ii DISCLAIMER iv ACKNOWLEDGMENTS v TABLE OF CONTENTS vi LIST OF FIGURES viii LIST OF TABLES xi ABSTRACT xii Chapter 1: INTRODUCTION 1.1 PROBLEM STATEMENT 1.2 OBJECTIVES 1.3 METHODOLOGY Error! Bookmark not defined 1.4 LIMITATIONS 1.5 RESEARCH CONTENT Error! Bookmark not defined 1.6 THESIS REPORT OUTLINE Error! Bookmark not defined Chapter 2: LITERATURE REVIEW 2.1 GREENHOUSE MODEL 2.2 INTERNET OF THINGS (IoT) 2.3.COMMUNICATION PROTOCOLS 2.3.1 UART 2.3.2 I2C 2.3.3 WIFI Chapter 3: METHODOLOGY 12 3.1 HARDWARE DESIGN 12 3.1.1 System block diagram design 12 3.1.2 Circuit design and calculation 144 3.1.3 Hardware schematic 388 3.2 SOFTWARE DESIGN 400 vi Fig 4.14 Water pump is working Meanwhile, users can switch to manual mode and choose to sow or water for each specific location The user tried selecting watering and planting on all locations, the system worked correctly and the response time was only 0.5 to seconds depending on the network speed Moreover, it is necessary to check the tolerance between two axes when control a header move from number area to number area The current temperature is 27 degrees Celsius, so the system switches to Auto mode and sets the temperature to 25 degrees Celsius (suitable for growing plants growing well) When the system detects that the ambient temperature is higher than the set value, the system will automatically turn on the watering The water pump system for all positions may be started in less than 60 seconds Fig 4.21 shows the system being configured and watering plants in automatic mode Fig 4.15 below is the result of the system after more than 36 hours of monitoring and care, the tree has grown about cm The tree has grown better than the natural one 59 Fig 4.15 Image of the garden after 36 hours of sowing Fig 4.16, after one week, the experiment was over with a height of cm This is cm taller than the typical tree in this situation Despite the expansion, it was disconcerting to observe that the roots did not expand as much and appeared to be having trouble supplying water Additionally, it appears that the plant was planted in an area with insufficient light, as plants grow and follow the sun However, this thesis is of the opinion that there is still room for development 60 Fig 4.16 Image of the garden after days of sowing 61 Chapter 5: CONCLUSIONS AND RECOMMENDATIONS 5.1 CONCLUSIONS After the process of research, understanding, construction, and calibration, the group's project " Automatic Monitoring and Control System in Agriculture based on IoT" has worked relatively accurately and fully met the requirements Specifically, the system has the function of choosing the location for the planting and watering automatically, and gathering environmental data The system may be operated from anywhere as long as the system and the control device are connected to the internet via Wi-Fi, according to the suggested thesis, which also incorporates the 4.0 technology trend The system is quick and convenient to control and operates with stability The entire system has a long lifespan, is largely stable, and produces favorable outcomes In addition, constructing the key elements that gardeners care about most at a reasonable cost for installation and practical use However, for the best performance and application design in practice, there are still several obstacles to be resolved in terms of expertise, time, and resources The purchased motor is of a poor quality, so there is still some variation in speed and error Additionally, because the processor and camera depend on the Wi-Fi network's speed, it can occasionally be slow and annoying The control system's aesthetics and security are not very good 5.2 RECOMMENDATIONS This suggested solution would address the aforementioned issues and add additional new features to enable the creation of a full product, such as replacing the honeycomb source with solar energy to aid in environmental protection and electricity conservation Add a selection feature and a plow/fill function before and after sowing to enhance the seeding method The system also has to have automatic harvesting and fertilization features so that the garden may fully automate itself 62 REFFERENCES [1] Smart Agriculture Market by Type (Precision Farming, Livestock, Aquaculture, and Greenhouse), and Component (Solution, Service, and Connectivity Technology): Global Opportunity Analysis and Industry Forecast, 2021–2027 [2] Agriculture in 2050: Recalibrating Targets for Sustainable Intensification [3] Kumar, S., Tiwari, P & Zymbler, M Internet of Things is a revolutionary approach for future technology enhancement: a review J Big Data 6, 111 (2019) [4] Ravesa Akhter, Shabir Ahmad Sofi, “Precision agriculture using IoT data analytics and machine learning”, Journal of King Saud University - Computer and Information Sciences, 2021, ISSN 1319-1578 [5] Ngo Thanh Dat, Le Hai Nguyen, “Thiết kế thi công hệ thống trồng rau”, 2018 [6] PaulBrous, MarijnJanssen, PaulienHerder, “The dual effects of the Internet of Things (IoT): A systematic review of the benefits and risks of IoT adoption by organizations”, Volume 51, April 2020, 101952 [7] Jovita Aranha, Set Up Smart Gardens That Let You Grow Veggies Inside Your Home [8] Horteng, Open - Roof greenhouse project [9] Paridhi Joshi, Best IoT Applications [10] DIGISTAR, Giới thiệu chuẩn Wi-Fi Link: http://hgsi.com.vn/cac-chuan-wifi-802-11b-802-11a-802-11g-802-11n-va-80211ac-c2-710-734 233.html [11] POWER GEN, LM 2596 DC -DC Buck converter [12] Espressif, ESP32 Series Datasheet [13] Rui Santos, ESP32-CAM Video Streaming and Face Recognition with Arduino IDE [14] Components101, DHT22 – Temperature and Humidity Sensor Link: https://components101.com/sensors/dht22-pinout-specs-datasheet [15] Jojo, Arduino and Soil Moisture Sensor -Interfacing Tutorial [16] Nshop, Arduino CNC Shield V3 63 Link: https://nshopvn.com/product/arduino-cnc-shield-v3/ [17] Allegro MicroSystems, DMOS Microstepping Driver with Translator and Overcurrent Protection [18] Components101, L298N Motor Driver Module Link: https://components101.com/modules/l293n-motor-driver-module [19] Components101, Servo Motor SG-90 Link: https://components101.com/motors/servo-motor-basics-pinout-datasheet [20] banlinhkien, Động bước 1.8 độ STP-43D3014 Link: https://banlinhkien.vn/goods-8072-dong-co-buoc-1-8-do-stp-43d3014.html [21] Hzshop, Động Cơ DC Bơm Nước Water Pump P385 12VDC Link: https://hshop.vn/products/dong-co-bomp385-12vdc-3w-1-8l-phyt [22] Components101, 16x2 LCD Module Link: https://components101.com/displays/16x2-lcd-pinout-datasheet [23] IoT Maker Việt Nam, Mạch chuyển đổi I2C cho LCD Link: https://iotmaker.vn/mach-chuyen-doi-i2c-cho-lcd.html [24] How Blynk Works Link: https://docs.blynk.cc 64 APPENDICES Appendix 1: Program (simulation, code of microcontroller, computer interface) ESP32 CONTROL PROGRAM CODE ESP32-CAM CONTROL PROGRAM CODE // KHAI BAO THU VIEN #DEFINE BLYNK_PRINT SERIAL #INCLUDE #INCLUDE #INCLUDE #INCLUDE #INCLUDE #INCLUDE #INCLUDE #INCLUDE // KHAI BÁO CHÂN KẾT NỐI #DEFINE PIN_BOM #DEFINE PIN_DEN 32 #DEFINE PIN_QUAT 23 #DEFINE CBD 36 #DEFINE CTHT1 18 #DEFINE CTHT2 19 #DEFINE DHTPIN 15 #DEFINE DHTTYPE DHT22 // CHÂN KẾT NỐI DRIVER STEP A4988 CONST INT DIRPIN1 = 14; CONST INT STEPPIN1 = 27; CONST INT DIRPIN2 = 26; CONST INT STEPPIN2 = 25; INT HOMESTATE = 0; LONG INITIAL_HOMING = 1; INT STEPINX = 0, STEPINY = 0; LONG INITIAL1 = 1, INITIAL2 = 1; CHAR AUTH[] = "B_CNSTTHKPY_M5LVKQPBCQKR291MOMGM"; CHAR SSID[] = "MCK"; CHAR PASS[] = "12345678"; CHAR SERVER[] = "BLYNK-CLOUD.COM"; // URL FOR BLYNK CLOUD SERVER INT PORT = 8080; INT MKN = 1, DENSTATE = 0, BOMSTATE = 0, MODESTATE = 0, GIEOHATSTATE = 0, VITRI = 0, QUATSTATE = 0; INT TIMEXOAY = 500, TIMEBOM = 1000; // SET THOI GIAN GIEO VÀ THỜI GIAN BƠM INT H , T, DOAMDAT, DOAMDATCAI = 0, NHIETDOCAI = 29; BYTE KTDEGREE[8] = {0B01110, 0B01010, 0B01110, 0B00000, 0B00000, 0B00000, 0B00000, 0B00000}; // KÝ TỰ ĐỘ C TRÊN LCD ACCELSTEPPER STEPPER1(1, STEPPIN1, DIRPIN1); // KHỞI TẠO ĐK ĐỘNG CƠ BƯỚC ACCELSTEPPER STEPPER2(1, STEPPIN2, DIRPIN2); 65 SERVO SERVO; DHT DHT(DHTPIN, DHTTYPE); LIQUIDCRYSTAL_I2C LCD(0X27, 16, 2); BLYNKTIMER TIMER; WIDGETBRIDGE BRIDGE1(V11); VOID SETUP() { SERIAL.BEGIN(9600); PINMODE(CTHCTHT1T1, INPUT_PULLUP); PINMODE(CTHT2, INPUT_PULLUP); PINMODE(PIN_DEN, OUTPUT); PINMODE(PIN_BOM, OUTPUT); PINMODE(PIN_QUAT, OUTPUT); DIGITALWRITE(PIN_DEN, LOW); SERVO.ATTACH(33, 500, 2400); // KHAI BÁO CHÂN SERVO CHÂN GPIO 33 DHT.BEGIN(); LCD.BEGIN (); LCD.BACKLIGHT(); LCD.SETCURSOR(0, 0); LCD.PRINT("VUON IOT"); LCD.CREATECHAR(1, KTDEGREE); STEPPER1.SETMAXSPEED(400); // SET MAX SPEED OF STEPPER (FASTER FOR REGULAR MOVEMENTS) STEPPER1.SETACCELERATION(1500); STEPPER2.SETMAXSPEED(400); // SET MAX SPEED OF STEPPER (FASTER FOR REGULAR MOVEMENTS) STEPPER2.SETACCELERATION(1500); HOME(); TIMER.SETINTERVAL(100L, SENDSENSOR); TIMER.SETINTERVAL(5000L, XOALCD); MKN = 1; } VOID LOOP() { IF (MKN == 1) { WIFI.BEGIN(SSID, PASS); ANALOGWRITE(PIN_BOM, 0); ANALOGWRITE(PIN_QUAT, 0); MODESTATE = 0; LCD.CLEAR(); WHILE (WIFI.STATUS() != WL_CONNECTED) { TIMER.RUN(); LCD.SETCURSOR(15, 0); LCD.PRINT("!"); LCD_HT(); SERIAL.PRINTLN("."); } LCD.CLEAR(); BLYNK.CONFIG(AUTH, SERVER, PORT); BLYNK.CONNECT(); MKN = 0; } IF (WIFI.STATUS() != WL_CONNECTED) { 66 MKN = 1; } LCD_HT(); IF (MODESTATE == 0) { LCD.SETCURSOR(14, 1); LCD.PRINT("MA"); MANMODE(); } ELSE { LCD.SETCURSOR(14, 1); LCD.PRINT("AU"); AUTOMODE(); } BLYNK.RUN(); TIMER.RUN(); } ////////////////////////////////////////////////// VOID XOALCD() { LCD.CLEAR(); } /////////////////////////////////////////////////// VOID LCD_HT() { LCD.SETCURSOR(0, 0); LCD.PRINT("T:"); LCD.PRINT(T); LCD.WRITE(1); LCD.PRINT("C"); LCD.SETCURSOR(8, 0); LCD.PRINT("H:"); LCD.PRINT(H); LCD.PRINT("%"); LCD.SETCURSOR(0, 1); LCD.PRINT("HUMG: "); LCD.PRINT(DOAMDAT); LCD.PRINT("%"); } /////////////////////////////////////////////////// VOID SENDSENSOR() { H = DHT.READHUMIDITY(); T = DHT.READTEMPERATURE(); // OR DHT.READTEMPERATURE(TRUE) FOR FAHRENHEIT INT CBD_VALUE = ANALOGREAD(CBD); DOAMDAT = MAP( CBD_VALUE, 0, 4095, 100, 0); BLYNK.VIRTUALWRITE(V6, H); BLYNK.VIRTUALWRITE(V5, T); BLYNK.VIRTUALWRITE(V7, DOAMDAT); } ////////////////////////////////////////////////// VOID MANMODE() { IF (BOMSTATE == 1) { VT(VITRI); BAT_BOM(); HOME(); } 67 IF (GIEOHATSTATE == 1) { VT(VITRI); GIEO_HAT(); HOME(); } IF (QUATSTATE == 1) ANALOGWRITE(PIN_QUAT, 255); ELSE ANALOGWRITE(PIN_QUAT, 0); DIGITALWRITE(PIN_DEN, DENSTATE); } //////////////////////////////////////////////// VOID AUTOMODE() { IF (BOMSTATE == 1) { VT1(); BAT_BOM(); VT2(); BAT_BOM(); VT3(); BAT_BOM(); VT4(); BAT_BOM(); HOME(); } IF (GIEOHATSTATE == 1) { VT1(); GIEO_HAT(); VT2(); GIEO_HAT(); VT3(); GIEO_HAT(); VT4(); GIEO_HAT(); HOME(); } IF ( DOAMDAT < DOAMDATCAI) { BOMSTATE = 1; BLYNK.VIRTUALWRITE(V1, HIGH); } ELSE { BOMSTATE = 0; BLYNK.VIRTUALWRITE(V1, LOW); } IF ( T > NHIETDOCAI) { ANALOGWRITE(PIN_QUAT, 255); BLYNK.VIRTUALWRITE(V9, HIGH); } ELSE { ANALOGWRITE(PIN_QUAT, 0); BLYNK.VIRTUALWRITE(V9, LOW); } DIGITALWRITE(PIN_DEN, DENSTATE); } //////////////////////////////////////////////// 68 VOID VT(INT N) { // VI TRÍ MANUAL IF ( N == 1) { STEPPER1.RUNTONEWPOSITION(-630); STEPPER1.SETCURRENTPOSITION(0); DELAY(200); STEPPER2.RUNTONEWPOSITION(-630); STEPPER2.SETCURRENTPOSITION(0); DELAY(300); BLYNK.RUN(); } IF (N == 2) { STEPPER1.RUNTONEWPOSITION(-1890); STEPPER1.SETCURRENTPOSITION(0); DELAY(200); STEPPER2.RUNTONEWPOSITION(-630); STEPPER2.SETCURRENTPOSITION(0); DELAY(300); BLYNK.RUN(); } IF ( N == 3) { STEPPER1.RUNTONEWPOSITION(-630); STEPPER1.SETCURRENTPOSITION(0); DELAY(200); STEPPER2.RUNTONEWPOSITION(-1890); STEPPER2.SETCURRENTPOSITION(0); DELAY(300); BLYNK.RUN(); } IF ( N == 4) { STEPPER1.RUNTONEWPOSITION(-1890); STEPPER1.SETCURRENTPOSITION(0); DELAY(200); STEPPER2.RUNTONEWPOSITION(-1890); STEPPER2.SETCURRENTPOSITION(0); DELAY(300); BLYNK.RUN(); } } ///////////////////////////////////////////////// BLYNK_WRITE(V0) { MODESTATE = PARAM.ASINT(); } BLYNK_WRITE(V1) { BOMSTATE = PARAM.ASINT(); } BLYNK_WRITE(V2) { DENSTATE = PARAM.ASINT(); } BLYNK_WRITE(V3) { GIEOHATSTATE = PARAM.ASINT(); } BLYNK_WRITE(V4) { 69 VITRI = PARAM.ASINT(); } BLYNK_WRITE(V8) { DOAMDATCAI = PARAM.ASINT(); } BLYNK_WRITE(V9) { QUATSTATE = PARAM.ASINT(); } BLYNK_WRITE(V10) { NHIETDOCAI = PARAM.ASINT(); } BLYNK_CONNECTED() { BLYNK.SYNCVIRTUAL(V0); BLYNK.SYNCVIRTUAL(V1); BLYNK.SYNCVIRTUAL(V2); BLYNK.SYNCVIRTUAL(V3); BLYNK.SYNCVIRTUAL(V4); BLYNK.SYNCVIRTUAL(V5); BLYNK.SYNCVIRTUAL(V6); BLYNK.SYNCVIRTUAL(V7); } ///////////////////////////////////////////////// VOID VT1() { // VỊ TRÍ AUTO STEPPER1.RUNTONEWPOSITION(-630); STEPPER1.SETCURRENTPOSITION(0); DELAY(200); STEPPER2.RUNTONEWPOSITION(-630); STEPPER2.SETCURRENTPOSITION(0); DELAY(300); BLYNK.RUN(); } VOID VT2() { STEPPER1.RUNTONEWPOSITION(-1260); STEPPER1.SETCURRENTPOSITION(0); DELAY(300); BLYNK.RUN(); } VOID VT3() { STEPPER2.RUNTONEWPOSITION(-1260); STEPPER2.SETCURRENTPOSITION(0); DELAY(300); BLYNK.RUN(); } VOID VT4() { STEPPER1.RUNTONEWPOSITION(1260); STEPPER1.SETCURRENTPOSITION(0); DELAY(300); BLYNK.RUN(); } /////////////////////////////////////////////////// VOID HOME() { WHILE (DIGITALREAD(CTHT1)) { // MAKE THE STEPPER MOVE CCW UNTIL THE SWITCH IS ACTIVATED STEPPER1.MOVETO(INITIAL_HOMING); // SET THE POSITION TO MOVE TO INITIAL_HOMING++; // DECREASE BY FOR NEXT MOVE IF NEEDED 70 STEPPER1.RUN(); // START MOVING THE STEPPER DELAY(1); BLYNK.RUN(); } STEPPER1.SETCURRENTPOSITION(0); // SET THE CURRENT POSITION AS ZERO FOR NOW // SET ACCELERATION OF STEPPER INITIAL_HOMING = -1; WHILE (!DIGITALREAD(CTHT1)) { // MAKE THE STEPPER MOVE CW UNTIL THE SWITCH IS DEACTIVATED STEPPER1.MOVETO(INITIAL_HOMING); STEPPER1.RUN(); INITIAL_HOMING ; DELAY(1); BLYNK.RUN(); } STEPPER1.SETCURRENTPOSITION(0); SERIAL.PRINTLN("HOMING COMPLETED"); SERIAL.PRINTLN(""); INITIAL_HOMING = 1; WHILE (DIGITALREAD(CTHT2)) { // MAKE THE STEPPER MOVE CCW UNTIL THE SWITCH IS ACTIVATED STEPPER2.MOVETO(INITIAL_HOMING); // SET THE POSITION TO MOVE TO INITIAL_HOMING++; // DECREASE BY FOR NEXT MOVE IF NEEDED STEPPER2.RUN(); // START MOVING THE STEPPER DELAY(1); BLYNK.RUN(); } STEPPER2.SETCURRENTPOSITION(0); // SET THE CURRENT POSITION AS ZERO FOR NOW // SET ACCELERATION OF STEPPER INITIAL_HOMING = -1; WHILE (!DIGITALREAD(CTHT2)) { // MAKE THE STEPPER MOVE CW UNTIL THE SWITCH IS DEACTIVATED STEPPER2.MOVETO(INITIAL_HOMING); STEPPER2.RUN(); INITIAL_HOMING ; DELAY(1); BLYNK.RUN(); } STEPPER2.SETCURRENTPOSITION(0); SERIAL.PRINTLN("HOMING COMPLETED"); SERIAL.PRINTLN(""); } VOID GIEO_HAT() { SERVO.WRITEMICROSECONDS(2000); // QUAY NGHỊCH DELAY(200); SERVO.WRITEMICROSECONDS(1500); // DỪNG DELAY(50); SERVO.WRITEMICROSECONDS(1000); //QUAY THUẬN DELAY(TIMEXOAY); SERVO.WRITEMICROSECONDS(1500); // DỪNG } VOID BAT_BOM() { 71 ANALOGWRITE(PIN_BOM, 255); DELAY(TIMEBOM); ANALOGWRITE(PIN_BOM, 0); }Code of AlphaBot2 Appendix 2: User manual (hardware, software) Step 1: Plug in the power to the system, wait a while for the system to start up Step 2: After booting is complete, the LCD screen will display a screen including temperature, air humidity, soil moisture, current Auto/Manual mode, and Wi-Fi connection status Step 3: Download and log in to the Blynk App on your smartphone (if you want to know how to log in to this project, please contact the author of this topic) Step 4: After successful login, the system will run by default in AUTO mode and show an area to display the values of sensors, real-time video from the camera, heat graphs sent up from the system There is also an area to set the value of soil moisture, temperature, if the actual value is greater than the set value, the system will automatically turn on the light, fan or water pump Step 5: If it is required to switch to Manual mode, by pressing the Mode button, there will be an area displaying the status of the devices in the system, and there will be buttons, if user wants to control the on/off switch of the devices 72 S K L 0