This is a smart home project I individually made from scratch at my home in China. My parents like growing flowers and vegetables. However, this hobby limits them from travelling together — there has to be someone at home to water the plants! Since we have Internet at my home, why don’t we make a remote controller over the Internet? This project then came into my mind.
I was learning mobile app development online at that time. As my practice, I decided to build a mobile app for the system. I decided to use a Raspberry Pi as the controller, a solenoid valve as the physical water switch, and a pipe system that connects to every pot.
What are there?
In order to water all the plants, a pipe system is connected around all the pots that desire water. It allows water to flow from the domestic water supply to every pot. The orange knob at the tip is for adjusting the water strength.
In order to control the water flow, A solenoid valve is connected between the domestic water supply and the pipe system. A relay is used as the switch for the valve. I also connected a DHT11 temperature/humudity sensor onto Raspberry Pi, just so that it would be nice to know the weather condition at home instead of looking at the weather forcasting.
The brain of the system — the microcontroller Raspberry Pi and the relay module are located in the sealed control box. We would close and seal the box to protect the electronics from being damaged by bad weather.
The most challenging part is the software. Since I am building the system from scratch, there is a lot of extra coding underneath the system in order to connect the Raspberry Pi under a local area network onto the mobile phone. Since the Raspberry Pi is under local area network, and for security reasons, there is no way to access the Raspberry Pi directly from mobile phone out of the home WiFi. After some research, I found out the easiest way would be using a server to forward all the requests and data between phone and the Raspberry Pi.
Long story short, there are three programs included in this system. One on Raspberry Pi to handle requests, and control the solenoid valve, which is the switch for the water. There will be one mobile phone app to control the Raspberry Pi apparently, and additionally, a program on a server handles all the communication between the phone and Raspberry Pi.
The mobile app is built on Flutter, a new cross-platform framework based on Dartlang. The server and Raspberry Pi scripts are built in Python. All the programs use websocket for communication. Both Raspberry Pi and mobile app connects to the server via websocket. Once the mobile app sends a request, the server will forward it to Raspberry, and Raspberry Pi controls the valve to physically let the water flow and come out from the pipe system. This is the idea.
The implementation takes some work to handle the connection, authentication and reconnecting. The project code will be posted on my Github soon!