Smart Water Tap Leakage Controller IoT Project
Water is a very scarce resource that needs to be used sparingly by everyone. Many people around the world go for days without this very basic need. Many liters of water are lost through water taps that are either left unclosed or not closed properly every day, which is a concern for the world at large. Due to climate changes and other factors, we are gradually running out of underground water and the rain no longer falls as it used to do without the negative impact of climate changes. Everyone has a duty to save water and save lives. Using technology, we can make this a reality.Demo video
The demo video above shows how the final installation of the Smart Water Tap Leakage Controller IoT project works. The person in the video is a 30-year-old farm trainee fetching water after his launch. When he leaves the water tap open and walks away, it automatically closes the 12V water flow selenoid valve and saves water. When he comes back to fetch another cup of water, it automatically opens when the PIR motion detector sensor detects his motion near the water tap. This motion detector sensor can detect motion at an angle of 120 degrees, which I didn't want. I covered the bottom part of the sensor in order to reduce the angle so that it does not detect the motion of people passing by.Project Planning
The image above (Figure 1.) shows the Fritzing Breadboard with components that I have used to build a circuit that detects the motion of people near the water tap and switches ON and OFF the 12V water flow valve. I used an 80K0960 general-purpose switching transistor to control the 12V relay. The ON and OFF states of the relay are indicated by a 5mm LED connected to the Collector of the Bipolar Junction Transistor (80K0960).The Project Build
The image in Figure 2 shows the solder side of the prototyping PCB having been mounted on a transparent stand with 5mm spacers.
The image in Figure 3 shows both the prototyping PCB and the plastic enclosure of the Nordic Thingy:53 Bluetooth Low Energy Prototyping Platform mounted on a stand. I made two holes on one side of the enclosure in order to mount the Thingy:53 onto the stand.
The image in Figure 3 is a component side of the prototyping PCB with all the components soldered onto the Printed Circuit Board. The red 5mm LED with a 4.7K current limiting resistor indicates power ON of the 12V power adapter with a 2A current which can output 24W of power to the whole project. Even though the Thingy:53 is battery-powered, I also included a 5V fixed-voltage regulator to charge it. The 24W of power is enough to supply the two power-hangry output devices, i.e. 12V relay and 12V selenoid water valve.
Figure 5 shows both the component side of the prototyping PCB and the top side of the open enclosure of the Thingy:53 with a 3.7V Lithium Polymer battery. Connected to the SIL connector on PCB is a 4-way JST cable with black, yellow, green, and red wires. It connects to the I2C Grove port of the Nordic Thingy:52. In this project I used both as General Purpose Input Output pins (pin 4 and pin 5 of Port 0 in the nRF5340 SoC ) to control the PIR motion detector sensor and the 12V relay.
The image in Figure 6 shows 4 way JST cable connected to the enclosed Thingy:53. When the thingy:53 is enclosed like this, the only thing you can on the top side is a programmable user button.
Figure 7 in the above picture shows a PIR motion detector sensor mounted onto a piece of plastic with a conduit pipe attached to it to help install it on the water tap. This motion detector sensor is powered by a 5V fixed voltage regulator with Max output current of 1000mA.
The image in Figure 8 shows the 12V selenoid water valve with the two-wire cable attached to it. It is DC 12V 0.02-0.8Mpa insulated selenoid valve. The only problem I noticed with this 12V water flow selenoid is that it quickly gets hot when it is being switched ON and OFF at a fast speed. However, this is not a big problem in this application because it is normally closed and it is opened only when the PIR motion detector sensor detects motion in front of the water tap.
The image in Figure 9 shows a 12VDC, 2A power adapter that converts 220VAC mains supply voltage into 12VAC and rectifies this 12V alternating current voltage into 12V direct current voltage. The maximum output power of this power adapter is 24 watts.
Figure 10 is a 220mm long Type C USB cable that I have used to charge the 3.7V Lithium Polymer battery of the Thingy:53. This cable is of the right length given the distance from the Type C USB port on the Nordic Thingy:53 and the Type A USB connector on the prototyping PCB.
The above image (Figure 11) shows all the components connected together to make a complete working project with the top cover of the Thingy:53 enclosure removed. The lit red 5mm LED indicates that the project is ON.
The image in Figure 12 shows the fully-functioning Smart Water Tap Leakage Controller IoT project installed on a water tap on the back side view of a small house on a local Non-Profit Organisation Agriculture Training Farm. When there the PIR motion detector sensor does not detect any motion near in front of the water tap, the 12V water flow selenoid remains closed. This means that water does not flow out of the tap. If it happens that you leave it ( water tap) open, the Nordic Thingy:53 will immediately trigger (energize) the 12V relay and close the water.
==============================================================================================================================================The Programming Part
The above picture (Figure 13) is an nRF Connect for Desktop app with all the apps. In this project, I only used the apps in the below images.
The above image (Figure 14) is a Toolchain Manager app show the buttons that are used to open Microsoft Visual Studio Code Integrated Development Environment in which I wrote the main program that runs on the nRF5340 Silicon on Chip Cortex M33 processor.
The image in Figure 15 shows the opened Microsoft VS Code building a whole Zephry RTOS project. The output of the build process can be seen in the Terminal window of the VS Code. The build process takes time because the Zephry RTOS configures the project first and it has many files to include in the system build process. In this project, I used the machine learning sample as my template code I also want to include embedded machine learning and artificial intelligence that work with Edge Impulse Studio.
The image in the above Figure shows the app_signed.hex file loaded in the Programmer app. The programmer app has an MCUBootloarder that is used to program the hex file onto the nRF5340 SoC of the Thingy:53. The write button is disabled when there is no hex or zip loaded. It is enabled immediately after loading the hex/zip file.
The image in Figure 17 shows the successful writing of the app_signed.hex of the program onto the Thingy:53 prototyping platform. The green color in the middle of the image shows the program space occupied by the app_signed.hex in the nRF5340 Cortex M33 processor.