# A Smart Sensing System of Water Quality and Intake Monitoring for Livestock and Wild Animals
## 2 System Design and Implementation
### Power Distribution and Data Communication  
The major design considerations of the water intake monitoring system are the power distribution and data communication from multiple sensors. The system has two power interfaces: one is 12 V Direct Current (DC) from the solar panel and the other is 120 V Alternating Current (AC) from the AC power source. A power source automatically selects the AC source if the AC source is available; otherwise, the system uses DC solar power. The AC power goes through a power adapter which turns the voltage into 12 V DC. The 12 V DC source powers the Microcontroller Unit (MCU) board. A voltage regulator that can handle up to 1A converts the 12 V DC to 5 V DC that is usable by the electronic components. The electronic components that connect the MCU board include a Real-Time Clock (RTC), an SD card for data storage, two Light-Emitting Diode (LED) light indicators, and three Metal Oxide Semiconductor Field Effect Transistor (MOSFET) switches. These components are hosted in an electronic box with the MCU. The MOSFET switches are controlled by the MCU to power the warning lights, the Top of Trough sensors, and the Inside Water Trough sensors. The Top of Trough sensors are the RFID Reader, the Camera, and the Motion Detector sensor to detect the animal visits. The Inside Water Trough sensors are deployed inside the water trough, including the temperature sensor, the water level sensor, and the water turbidity sensor. The RTC controls the timing information of the overall system. The RTC communicates with the MCU via the Inter-Integrated Circuit (I2C) bus and the SD card via the Serial Peripheral Interface (SPI) bus. The external wiring and connectors connect the electronics packaging to the sensors. The system also has a water measurement unit, which is a water flowmeter that is in line with the water line that feeds water to the trough. The overall water sensing system is shown in Figure 2.  
Figure 2: Hardware block diagram of the smart water intake monitoring system.  
The overall sensing system can be divided into one central control subsystem and two sensing subsystems. The central control system has an Arduino Mega 2560 MCU, the RTC, and the Micro SD Card adapter. The Arduino Mega 2560 is the central processing unit of the system. It is connected to all the components of the system through a custom-designed Printed Circuit Board (PCB) and ethernet cable. All the software and signal processing of the system is also executed on the Arduino Mega. One of the sensing subsystems is for animal sensing and the other is for water sensing. The individual component implemented in the animal sensing subsystem includes an RFID tag reader and a weatherproof Adafruit TTL Serial JPEG Camera with the motion detector. The RFID reader identifies individual cows when the RFID tag approaches the drinking station. The RFID tags are attached to the ears of the cows. During each drinking event, the ID numbers of the RFID tag are recorded along with the amount of time spent on the drinking station as well as the volume of water consumed. The weatherproof TTL camera visually records the animals drinking by taking several pictures of them. The camera uses a built-in motion detector to activate and start recording. This can sometimes cause issues such as the movements of the objects in front of the camera. Sometimes, even strong winds can cause the camera to activate and take pictures, even though none of the livestock is using the drinking station. This problem is solved using the RFID system by only allowing the images taken by the camera during the RFID event to be stored in the SD card. The water sensing subsystem has a temperature sensor, a sonar sensor, a water flow meter, and a water turbidity sensor. The sonar sensor measures the depth of the water within the water tank. Should the water level drop beneath a specific amount, the sensor would contact the CPU, which would open the flow meter and refill the water tank to raise the water volume to ensure animal welfare.