Intermediate ProjectIntelligent Sprinkler Irrigation System Controller
with Web Server
Author: Piotr MichońskiInstructor: Witold Paluszyński Ph.D.
Abstract:The goal of the project was to design and construct
an electronic device which would allow remotely con-trolling a sprinkler irrigation system. The core of thesystem is ESP8266 chip with Wi-Fi. The controller wasintended to store several programs selected by the userby the web user interface. The device has three outputterminals (sections) through which it can control threesolenoid valves. Moreover the controller should be ableto decide, whether to suspend current watering eventdue to measured environment conditions. The boardwas designed to connect 2 sensors such as soil moisturesensor or rain sensor.
The result of the project is a device on a PCB board,with an adapter for a ESP8266 chip. A web page withuser interface was designed, it allows setting programs,visualising sensor data and inner state of the controllerprogram.
Wroc law University of Science and TechnologyDepartment of Cybernetics and Robotics
Faculty of Electronics
January 29, 2019
This work is licensed under a Creative CommonsAttribution-NonCommercial-ShareAlike 4.0 International License.
(a) 3D visualisation of a PCB (b) Prototype of the device
Figure 1: Controller’s design
1 Introduction
The project was intended to provide a solution for home irrigation problem. Watering theplants is a time consuming process which needs to be performed regularly. Instead of doing itmanually, one may use a programmable device which would control the process of watering. Forconvenience, it could be set in a wireless way. Hence, built device realises such functionality,allowing simple programs setting via web server.
Several assumptions concerning the board design were made. First, it should be placed ina possibly small cover with terminals for sensors connection. Moreover, the device should bepowered from 230V/AC as it is easily accessible in home buildings. The power section of theboard should also drive the solenoid valves through relays. Three output relays were neededto partition the watering area into three independent sections. To obtain precise informationabout time, regardless to current wireless connection state, the external Real-Time Clock shouldbe used. It should be battery-backed. In case of blackout, program data should be kept innon-volatile memory.
The user interface was meant to be simple and user friendly. There were 2 types of programsplanned. First – basic program, executing regularly until its cancellation by a user, second –additional program, overwriting the basic one. The additional program executes in a specifiedperiod of time. The web page should also present some internal data and measurements’ results.
Furthermore, the device was expected to use external sensors, like soil moisture sensor orrain sensor, to make a decision, whether to suspend watering event or not. The sensors can beconnected to the device through an Analog-Digital Converter.
2 Design
The following section describes the mechanical and electronic design of the controller. Then,the software structure is discussed. In the and an overview of the user interface was presented.
2.1 PCB Board
All the controller’s electronics were placed on a PCB, the project and prototype werepresented on a figure 1. The board consists of several sections. In power supply section, thereare two transformers, one 24V/AC drives the solenoid valves, the second one reduces voltage
1
which is then rectified and lowered to supply power to RTC, ADC and ESP chips. ESP[1] canbe programmed using UART, so a programming connector is placed on the board. To programthe ESP8266, programming switch must connect one of its pins to the ground. Then wholesection of relays become cut off. The last section is the section of terminals – power supplyconnectors and sensors connectors.
The board was first soldered on a prototyping board. The layout and the behaviour of thedevice were tested. This helped to make small improvements and avoid major errors in PCBdesign. Thanks to that, the current (first) version of PCB is functional, although there weresome minor errors, which needed to be manually corrected.
The schematics of the device were presented in the end of the document, on figure 3.
2.2 Sensors and electronics
The main unit on the PCB board is ESP8266 chip. It is a Wi-Fi module with microcontrollercapability. It has 80MHz CPU, GPIOs, internal ADC and I2C peripherals. It fulfilled theexpectations as it is low-cost, widely used and can emulate EEPROM. It also comes with bigmemory, which is important to store the web page.
In addition to ESP chip, an external ADC was used. However the chip has built-in converter,in available version it is not available on the external pins. Moreover external ADC has biggerresolution and higher accuracy. MCP3423[2] converter was used as it has 2 channels, highresolution and communicates through I2C.
For time measurement, Real-Time Clock MCP7940N[3] was used. It has battery back-upoption and communicates via i2C.
2.3 Software
The main loop of the program consists of two parts. The first one handles incoming clientrequests and executes the program check function. Program check function determines, whetherto start or stop the watering program. It checks all start and stop dates for active programsand compares it to the current time received from Real-Time Clock.
The software is written in C++ and is being flashed to the ESP board using an extensionfor Arduino IDE. For circuit and PCB design, KiCAD software was used.
2.4 User interface
The web page was designed basing on free templates from w3schools web page[4]. It iscompatible with devices with different screen sizes. A screenshot of the interface was presentedon a figure 2. Home page consists of info section: presenting real time, soil moisture sensormeasurements and placeholders for future variables. Below there is a section with listed activewatering programs. Beneath, there are buttons with hyper-references to some sub-pages al-lowing to set/clear programs, test the outputs or set current time (necessary in a case, wherethere is no battery power supply).
3 Summary
The result of the project is a working controller. It connects to the network and handles webclients’ requests. It is possible to set and clear programs, which are being saved in non-volatilememory. It also drives the outputs. The operation of the device is controlled by user interfaceon a designed web page. The assumptions were realised, although the device itself may beimproved in some ways. First, the location of the Wi-Fi chip could be moved further from
2
Figure 2: Screenshot of the home web page
relays, to eliminate the influence of the magnetic field on the operation of the chip. The powersupply should be additionally filtered with a few capacitors. Moreover the user interface canstill be extended and simplified. The footprints for transistors and rectifier may be changed asthere are more alternatives for these components with different pinout.
The user interface will be under development during the test on the real object.
References
[1] Espressif Systems. ESP8266EX Datasheet, 6.0 edition, 2018.
[2] Microchip Technology Inc. 18-Bit, Multi-Channel Analog-to-Digital Converter with I2CInterface and On-Board Reference, 2009.
[3] Microchip Technology Inc. Battery-Backed I2C Real-Time Clock/Calendar with SRAM,2018.
[4] W3.css website templates. [https://www.w3schools.com/w3css/w3css_templates.asp].[accessed: 2019-01-28 20:48].
3
https://www.w3schools.com/w3css/w3css_templates.asp
1 2 3 4 5 6
1 2 3 4 5 6
A
B
C
D
A
B
C
D
Date: KiCad E.D.A. eeschema 5.0.2-bee76a070ubuntu16.04.1
Rev: Size: A4Id: 1/1
Title: File: nawadnianie.schSheet: /
1
2 3
4
T1TSZZ 1,5/005MP
1
2 3
4
T2TSZZ 18/013M
GN
D1
VO 2VI3
U3LD1117
R123,3K
C2470
C1100n
F1100mA
F2
250m
A
GND
R251
C3220
GND GND GNDGND
C5100n
GND
C7220
C8100n
GND GND
+12V +3.3V
111214
212224 A
1A
2
K1P
1234
5678
J4ESP-01
+3.3V
CH_PDRST
TX
RXGPI00GPI02
GND
1112
14
2122
24
A1A2
K2P
R133,3K
R143,3K
R153,3K
R163,3K
R173,3K
R10330
R11330
I2C_SDA
I2C_SCL
TX
RX
GPI00
GPI02
RST
CH_PD
X1 1
X2 2
VB
AT
3V
SS
4
SDA5SCL6
MFP7
VC
C8
U4MCP7940N-xP
Y132,768kHz
C1110p
C1210p
GND
+3.3V
C9100n
GND
C10100n
R91k
D6BAS81
GND
BT1Battery_Cell
GND
GND
123
J2
Zcze programatoraR1330
GND
RXTX
ADC
CN
TR
L
MU
X&
PG
A
Vref
CH1+1
A1 10
CH1-2
Vss
3
CH2+4
CH2-5
Vdd
6
SDA 7SCL 8
A0 9
U2MCP3423
C6100n
123
J3
pomiar drugi
GND
GND
I2C_SCLI2C_SDA
GND
+3.3V
12
J1zasilanie
D3BAS81
1
2
3
Q1BC817
R4
20k
12
3Q2
BC807
+12V
R3
20k
+3.3V GPI00
1112
14
2122
24
A1A2
K3P
D4BAS81
1
2
3
Q3BC817
R6
20k
12
3Q4
BC807
+12V
R5
20k
+3.3V
1112
14
2122
24
A1A2
K4P
D5BAS81
1
2
3
Q5BC817
R8
20k
+12V
R7
20k
+3.3VGPI02
I2C_SCLI2C_SDA
MFP
MFP
1234
J5zawory
D1BAS81
12
3
SW1SW_SPDT
GND
GPI00
Programator automatycznego podlewania ogrodu
2018-11-20
+1
2
-3
4
D2
B80S
12
3Q6
BC807
123
J6
pomiar wilgoci
GND
R181k R191k R201k
D7LED
D8LED
D9LED
+3.3V
+3.3V
Figure 3: Electronic circuit schematics
4
IntroductionDesignPCB BoardSensors and electronicsSoftwareUser interface
Summary