As water consumption and wastage increases day by day, water scarcity has become a growing concern around the globe. While some irresponsible people are overusing water and wasting it daily, a large population remain deprived of safe drinking water. This problem is caused by the irregular distribution of water.
To deal with this, we need a solution that gives data about daily and monthly water consumption of each area and home to the government to enable proper water distribution. Good news is we have the solution now.
In this IoT project, we are going to make a smart Wireless water meter that measures our daily water usage and provides live data on our phone that is connected to a database, which can be accessed by the government.
- Water flow meter(Recommended FS400).
- Arduino pro mini(5V and 16 MHz)
- Bluetooth HC 05
- Programmer (Arduino UNO/FTDI programmer )
- OLED SSD 1306
- Water Pipe(according to your sensor inlet diameter)
- Water to tap connector
Once we have collected these components, we can start our project.
Setting Arduino IDE
Download the flow meter library and paste it in the libraries folder of Arduino
After that open Arduino and click on manage library and search Oak SSD 1306 OLED library as in the pic below (Fig.1).
Now our Arduino IDE is ready. Let us start coding part.
Open flow meter multi example code and add some of these parts.
First, we include libraries of flow meter and OLED display as in (Fig. 2).
After this, we create the interrupt handler for the sensor as in (Fig. 3).
Here, we set up the Bluetooth with Baudrate 9600. If it doesn’t work, try default Baudrate 34800.
Finally, we set the data output that will send to Bluetooth with Serial.print(data to send).
Then set OLED display function to display data on OLED screen with oled.println(data to send) refer (Fig 5)
As we are now done with the coding part, next is app making:
Open MIT App Inventor, make a layout and add the components as in Fig 6.
Main Components we added in the layout are:
- 1 Buttons one for DB.
- 5 Text view for Bluetooth connection status, Water flow rate of inlet, Total volume of water consumed, the flow rate of wastewater and total volume of water waste.
- Tiny web DB
- List picker for Bluetooth
- Bluetooth client
- Timer clock
Now go to MIT Code block and set the code as in Fig 7.
You can download the whole code and app from link below with .aia file.
Download Source Code For Smart Water Meter
We have made APP and we have finished the code. What we need now is to upload the code to Arduino.
NOTE: I have used Arduino pro mini to make the project small and easy, you can also use Arduino UNO for this project. Code and connection remain same for both, it’s all about your choice.
Uploading Code To Arduino Pro Mini:
First remove Arduino UNO IC as in (Fig. 8).
Now connect Arduino Pro Mini as follow:-
Arduino Pro Mini
Now go to Tools and select Board Arduino pro mini and upload the code to Arduino pro mini refer Fig 9.
Now we need to connect the components
|Arduino Pro Mini Pins||Components Pins|
|5V||VCC of Bluetooth|
|GND||GND of Bluetooth|
|RXI||TX of Bluetooth|
|TX0||RX of Bluetooth|
Refer Fig. 10 for connections
Do cross check all the connections, if you don’t want to end up frying your Arduino with wrong connection.
First make sure each of the connections are ok and then power the Arduino with 5V DC power supply.
Connect the water sensor pipe to the tap or water inlet of your water tank. By doing so, you can see the total volume of water and water flow rate on OLED display. Now, open Android app and press the Bluetooth icon where you will see a list of Bluetooth devices available. Pair with Bluetooth HC 05. After connecting you will get the water flow rate and water volume consumed in the app as in Fig 11.
You can tap on DB icon to upload our water usage data to the web server that can be seen from anywhere using the internet.
NOTE: Your internet connectivity must be turned on to upload data to the server.
To fetch data, click on the link given below and type your house name, that you have given in the app. I have used home 1. Click on search, You will get the details of water usage data. Refer Fig. 12.
Cheers! We have made an amazing solution that can help manage water consumption at home.
NOTE: You can also add the extra sensor to pin 2 for water wastage data. I have included code and app compatible with that. Only add a sensor to it and enjoy your project.
Prob. (Problem): I don’t find the accurate data from the sensor.
Sol. (Solution): Follow the library link for calibration tutorial.
Prob:- I get the “too large index”, “end app” during running.
Sol:- This happens because some data might be missed by Bluetooth during reading, tap out on screen or reconnect the Bluetooth of the phone.
Prob:- Can I set it up and supply power through a socket?
Sol:- Use adaptor with 5V D.C for it.
Prob:- I can’t find enough VCC pin to connect OLED, Bluetooth and sensor and as well as to power Arduino.
Sol:- Solder the extra wire to VCC and ground pins and make connections.
Prob:- I can’t see Bluetooth HC 05 in the list.
Sol:- First pair the Bluetooth HC 05 with android, go on Bluetooth setting and tap on HC 05 to pair, and it will ask for the pairing code, default code for paring is 1234 0r might be 0000 or 1111.
Prob:- Error in Bluetooth communication and program uploading to Arduino.
Sol:- Try interchanging the connections between Rx and Tx.
If you found this IoT project useful then you may also like Top 30+ IoT Projects | IoT Project Ideas for Enthusiasts.