Inspiration is here

Water scarcity and water management topics are very closely related to each other. Improper water management leads to water scarcity and vice versa. Way before starting our IoT & Robotics journey I always wanted to solve the problem of overflowing water tanks. So, after understanding what do Internet of Things & Machine Learning means we thought of making a project which will eliminate this traditional problem to the full extent. But we were startled to see that there were already thousands of projects covering this area. Almost every sensor out there has been used in these projects.

So, we wanted to make a project which must be very different from the existing projects. Then we came up with the project Wheels 4 Water, a perfect amalgamation of IoT, Machine Learning & Cloud. Let us point the main highlights of my project, which make our project stand out from others.

What it does

We think all of the projects which were made earlier have the following drawbacks:

  1. In the real world scenario the water supply chain, from the water source (eg dam, water facility) to water tanks in our home, is a very long one and we have to admit that the problem of water wastage starts from the initial end of the cycle and penetrates through the very last end of that cycle. All of the previous projects only focus on the very last end of the cycle i.e. the project only deals with the water tanks of our homes.

  2. The projects were almost passive. By passive we mean that they will monitor the water level and will turn the water motor off when the water reaches a certain level. This whole computation would be done within the microprocessor and the end-user can’t get to know what is happening inside the code at the moment!

  3. Less interactive projects. If one can provide some motion or life to the immobile projects then it will greatly enhance the chances of implementing the project in real life.

  4. Very few of the projects use the concept of Machine Learning. Those who use the ML concepts are just using the pre-built easy structured graphs and anomaly detection things which actually don’t make much more sense!!

So, we wanted to make a project which must be very different from the existing projects. Then we came up with the project Wheels 4 Water, a perfect amalgamation of IoT, Machine Learning & Cloud. Let us point the main highlights of our project, which makes the project stand out from others.

  1. Apart from the basic sensors, we have used many different sensors. Be it a water flow sensor, solenoid valve, or an analog multiplexer IC (CD4051), all these sensors helped us to almost nullify the water wastage through the whole water supply chain. In this manner, we focused on the whole water supply chain.

  2. At every instance of the project execution, the end-user will be updated and informed about each major workflow. The project will talk with the user. Thus making the project active.

  3. In order to make this project more interactive, we dumped the old idea of integrating IFTTT or using the CLI. Even we have not used either the blynk application or the normal switches in our project. Instead of all this, we have provided four custom options to control the project which include a dedicated website, NodeMCU based robot, customized cloud dashboard & voice control (we have not used any drag and drop feature of Blynk or IFTTT applications)

  4. Rather than using simple and pre-built ML systems we used the Iterative Dichotomiser 3 algorithm and implemented it via Python so that the robot can actually make decisions on its own after analyzing the dataset.

Hardware Components

Sensors Used With Arduino

5V Relay, I2C LCD, Arduino Uno R3, 9V Battery, Bolt Wi-fi Module(in our case), IRF540 MOSFET, Water Flow Sensor, Ultrasonic Sensor X 2, 1N4007, Rectifier Diode, 12V DC Solenoid Valve, Water Lifting Submersible Pump, 4-way Capacitive Touch Switch Module, 3-6 V Mini Micro Submersible Water Pump

Sensors Used With ESP8266 (Nodemcu v1.0)

Nodemcu, Piezo Buzzer, IR Sensor X 2, DC Motors X 2, 12V DC Adapter,TCS3200 Color Sensor, Capacitive Touch Sensor, ESP8266 Motor, Driver Shield, Analog Multiplexer IC – CD4051

How we built it

One can break down our project into two major parts. One is the immobile Arduino and the mobile NodeMCU based robot. we will discuss the functioning of each of both sections.

Arduino

In the project there are 03 water tanks (which sorts of replicate the real world scenario). You can assume the first one to be the main water facility, the second one to be the nearest water tower, and the third one to be the water tanks in homes. The main water facility will get the water from the dam and the water lifting submersible pump will be turned ON and at that point of time the solenoid valve will be turned LOW. Whenever the water level in the nearest water tower will be less than 20% then the solenoid valve will turn ON and thus the water tower will get filled to a certain threshold (say 95%). When the water tower will be filled then the DC water motor will start pumping out the water from the tower to the water tanks in our home.

At the time of pumping the water flow rate will be calculated through the YS-401 water sensor. Then the total time to fill the water tank will be calculated and accordingly, the instructions will be sent to the robot so that it can reach the destination in time to inform the user.

One major aspect of the Arduino setup is that we have to make the Arduino and the python program communicate with each other. We have to do this as WiFi Module (Bolt's wi-fi module in our case) can understand Python language, not Arduino’s language. So we have to make the Arduino pass some certain keywords to the Python program and then the Python program will act accordingly. For this, we used serial communication through the COM port. This was a tricky part as the Arduino has to pass about 6 parameters to the python program and then python program has to procced accordingly.

In order to make the passed variable understandable to the python code, we used the decode and strip methods. In this case, the decode() method converts the string from UTF-8 encoding to binary encoding. Another problem after using this decode method was that say for example the passed variable was “stop” then the decode method will append some escape sequences to the variable and now the variable will look like “stop/n/r”. In order to remove the extra escape sequences and also not to affect the binary encoding, I used the strip method as it removes any spaces or specified characters at the start and end of a string. This solved the problem of inter-communication between Arduino and python code.

Nodemcu Based Robot

The first work for the robot is to fetch the place attribute so that it can find the place where it has to go. Once the robot fetches that value then the TCS3200 color sensor comes into the picture. Basically in the dataset, there are 03 values for place attribute which are balcony, bedroom, and hall. From the starting point of the robot to the final destination we had laid down 03 different colored lines so that the color sensor will follow a particular colored line after getting the predicted value. The place has the following colors:

  • Red - Bedroom
  • Green - Hall
  • Blue - Balcony

So, the robot will find the path through the custom-made direction functions. When the robot will reach to the end then it will wait for 20 seconds and then it will check whether the user clicked on the capacitive touch sensor. If yes, then the NodeMCU will send an API request to the Bolt WiFi cloud and in this manner, the water motor will be switched off in time.

We have almost discussed the difficult tasks of the code up in the above sections. But we want to make it clear that the overall code.

We are laying out a table that tells the working of each file:

  1. robot.ino: Catch the users’ input & reach the predicted place
  2. arduino.ino: Serial comm with python & data collection

The above-listed Arduino files are for Arduino and NodeMCU respectively. The below-listed files are python files that do the manipulation with the dataset and then upload/fetch the same via Integromat.

  1. attribute.py: Gathers values for the data points to be pushed in ID3 algorithm
  2. credentials.py: Stores API keys, SSIDs, authentication variables
  3. integromat.py: Retrieval of information from Integromat’s scenarios
  4. prediction.py: Collect the attributes and uses the ML algorithm to predict the place
  5. project.py: Main file which ensures smooth functioning of the project

The best understanding of the code will be through the working video of the project. So, do look at the working video of the project at the start of this documentation.

Hosted Website (wheels4water.me)

For the front-end part of this website, we have used CSS, Bootstrap. Just to speed up the process we used Bootstrap Studio so that we can make the static website in a quick span of time. But the static website was not fulfilling the main purpose of this project. How can a user use a static website to interact with the cloud?

So, in order to turn this into a fully functional dynamic website we added a lot of transitions, JavaScript and also added the back-end (database functionality). After doing so the user can easily interact and thus login into his account whenever needed. For integrating the website into the database we used PHP language so that we can execute the required SQL commands whenever needed (or according to the users’ input).

The SQL database is named wheels4water and inside it, there are 2 tables which are users & vacation_logs. Users table stores the information related to the user whereas the vacation_logs store the information related to the scheduling of a particular account.

We have used Bolt’s WiFi Module to turn on and off the water motor through the relay. The main reason for choosing this module to turn on and off the water motor was because through Bolt’s Cloud Dashboard we can easily plot a graph that must be showing the time for which the water motor was turned on/off.

setChartTitle('W4W Motor Stats');
setChartType('areaGraph');
setAxisName('Time','Motor');
plotChart('time_stamp','motor');

let anchor = document.createElement("a");
anchor.innerHTML = "Off Motor";
//using an api request to the cloud module to turn off the motor
anchor.href = "https://cloud.boltiot.com/remote/api_key/digitalWrite?pin=0&state=LOW&deviceName=BOLTXXXXX";
anchor.target = "_blank";
anchor.style = "display: block; width: 100px; text-align: center; margin-top: 20px; margin-left: 450px;border-radius: 10px; border: 2px solid #0000FF";
document.getElementById('drop').appendChild(anchor);

Challenges we ran into

  1. Using the ESP8266 motor shield was difficult because in the shield’s official datasheet nothing is clearly explained. But after several repeated attempts we sorted the overall functioning of the shield. NodeMCU is placed on the top of the shield so that both become one in the other. A total of 2 DC motors can be connected so that is why we used a 02 wheeled robot which was controlled through the DC motors while the Caster wheel provides the stability to the overall chassis. As we used 02 12V DC motors we have to either use a 12V DC cell combination or can use a 12V DC power adapter to power up the motors. The major drawback of using the 12V cell combination was that the cells get discharged very quickly so this option doesn’t seem viable at that moment. That’s why we turned up for the 12V DC adapter solution as it seamlessly provides enough power to the motor shield and motors. Do note that we have short-circuited the Vin and Vm pins of the motor shield so that the power coming from the motors can also be utilized for powering up NodeMCU.

  2. Using the multiplexer IC with the motor driver shield was also quite a bit of a challenge as the CD4051 multiplexer IC is basically a 03 select line-based (S0, S1, and S2) multiplexer. This means that we can insert 2^3 = 8 analog sensors with this IC and use the single port i.e. A0 of the NodeMCU to read all 8 values. But in my case, we used only 2 IR sensors which means we don’t know what we have to do with the third select pins? In many attempts, the third select line was giving random values which were not even needed. After some trials, we got to know that the third select line must be provided a voltage of 0 so that the pin should not float.

  3. While using the Integromat scenarios, we were not sure how to create a scenario and how to integrate in our programming? We have used 6 scenarios for the project which includes various CRUD operations. It was challenging to get the response in the Nodemcu because the response there comes in a format which needs to separated as per our needs. So, it was good to deliver the working scenarios.

Accomplishments that we're proud of

  1. As already mentioned in the starting that we will be creating 4 custom options for the project and we did that. We have created the website, incorporated the capacitive touch sensor, automated the voice control thing and created the cloud dashboard.

  2. This is a project which can be deployed in the market as it is almost optimized. It is also cost-efficient as the whole hardware setup costs around $130. As in the real world, the magnitude of the sensors will be increased, so that the cost will only reach up to $300 (which is a quite remarkable feat).

  3. We have magnificently solved an old-age problem of water management by incorporating about 30 electrical components together and making a project which can be either used by a single person or by the entire community.

  4. We have made all the videos and the images for the project by our own. This one is also special because this was an area out of our expertise and we are sure that the videos and the images brings the best out of the project. The hardwork of our team rightly reflects in each of the project's component i.e. website, software and hardware configurations and the actual working of the project.

NOTE

For each major step in the processing, the user must be intimated regarding the same. The user will receive notifications when the motor motor will be turned ON, how much time to fill it will take, what are the 04 options through which user can turn it OFF and, when the motor will be turned OFF (either automatically or through the user's input). A total of 04 WhatsApp updates will be posted on the user’s registered number. But what if there is no Internet connectivity with the user? Then, in this case, 04 normal text SMS will be also sent which makes the project more relatable to the real world. All these notifications related work is done through TWILIO'S API.

What we learned

In the span of 30 hours, we learnt how to work as a team, how the problem should be broken down? In the last 1 and a half days, we coded the website, rectified the major portion of CPP (Arduino coding) and thus we rightly managed our time. We shaped our thoughts into reality and are sure that this project can be launched into the market to cater the needs of many people.

Talking about the technical part, we learnt how to make a beautiful fully functional website and also got to know about the hosting services. Starting form the cloud we got to know about CRON jobs and many other things which helped us making an automated project.

What's next for Wheels4Water: Let's paddle away through water mgmt issues

As this project will be directly accessible to the users, we are trying to add a feature in the website through which the user can contact with us and therefore we can make the proper arrangements for setting up the hardware as per the user needs. As the activity of the robot is being updated in a Google sheet, we will be giving the user an option to download the report on a weekly basis.

Built With

Share this project:

Updates