Parts + How it works…

To demonstrate our project we have made a sink and tap. This is purely just to show how we have used an Arduino and flow sensor to measure the flow of water passing through a system. Our product could be connected to a shower, toilet, etc.

We have come across some issues for example if we were to have an actual tap the build up of pressure would brake the pump. So we have decided to go with a copper pipe, which will allow the water for flow freely.

Another problem we have had to face are connecting the pipes to the flow sensor, pump and copper pipe. However we managed to find a 1/2″ to 8mm coupler and piping to set it up.IMG_0708

Sending Data to

The final step of our project was to connect everything to our NodeMCU esp8266. As the Node is a board itself, we attached the flow rate sensor, LCD and LEDs to its D pins and shared the power between the Arduino and the Node. We then changed our code to correspond to the amendments we made.


Screen Shot 2018-04-17 at 18.28.59.png



Once connected, we had the problem that the flow rate sensor was not responding and not giving any readings. We knew this because when opening the serial monitor there were no readings being taken. After analysing the new setup, we narrowed down the possible reasons for this below:

  • LCD sucking power from the Flow Rate Sensor
  • Need external power
  • Pins on the NodeMCU esp8266 doesn’t support interrupt pins
  • Code was wrong

Firstly, we took the LCD out of the setup and ran the code again which proved not to be the problem. Next was applying an external power supply which again made no difference.

On the Arduino, the interrupt pins are mapped to pins 2 and 3 whereas the Node after some further research we found out that it didn’t specifically have any interrupt pin but it was the code relating to the interrupt that had to be changed. So because of this we needed to change the syntax to allow the flow rate sensor and the esp8266 to communicate with each other. As you can see below, the change was very simple but without it it would never work. We found the new code by looking up the syntax for the esp8266 interrupt.

Old Line of Code

attachInterrupt(sensorInterrupt, pulseCounter, FALLING);

New Line of Code

attachInterrupt(digitalPinToInterrupt(sensorPin), pulseCounter, FALLING);


Sending Data to

Sending data to is a fairly simple process, supply lines of code published on their website which allowed us to define the sensor we were using and the data we wanted to transmit on the dashboard. Below is the line of code we used to transmit our data.

Code Supplied

thing[“variable”] >> outputValue(myVar);

Our Code

thing[“sensorPin”] >> outputValue(totalLitres);

To set up a dashboard widget, it uses the “sensorPin” as what its reading and the “totalLitres” as whats it displaying.

Below is a video showing our dashboard in use:


Although we did want to display more than just the total litres used, we were unable to because each widget uses one sensor and as all the data comes from the flow rate sensor we couldn’t display more than one set of data. But using this dashboard shows the potential it has and is a great way for the user to check how much water is being used when they are away from the LCD.

Link to the dashboard:

Full code:






Changing Behaviours

How Does it Change Behaviour?

In our project, we set out to change the mindsets of users by directly showing them the amount of water they are using and how much they were spending. This would then urge them to use less water as they are now able to see the cost of their actions, of which they previously may not have known and therefore making our prototype sustainable through changing behaviours.


A Government report published in 2012, set out explore how the implementation of “smart” electric metres changed peoples attitudes towards how they powered their homes and the changes they made because of this.

“Display in £s and pence was thought to be much more meaningful and effective as a prompt to behaviour change than display in kWh which was a largely meaningless concept to this audience. IHDs were felt to have had a role in prompting one or more of:

  •  Turning items off (at the plug) that did need to be on such as TVs, laptops, phone chargers
  • Reducing heating; for example, lower temperature, turning it off in unused rooms or in areas such as halls, stairwells, having it on for less time
  • Identifying and replacing ‘culprit’ or ‘high use’ appliances such as an ageing fridge freezer, or changing spotlights tor LEDs”

In conclusion from the findings from the report, users started turning off electrical appliances more when they were able to directly see the energy they were using and the cost behind it and therefore using less energy and becoming a ‘greener’ household.

Full Report: 


Connecting To

What is is an Open Source platform for the Internet of Things, it provides a ready to use scalable cloud infrastructure for connecting things. Makers and companies can start controlling their devices from the internet in minutes, without worrying about the required cloud infrastructure.

Using the library you will be able to connect almost any Arduino board using Ethernet, Wifi, GSM, or other supported boards like ESP8266, NodeMCU, and TI CC3200.

The client library allows connecting the IOT devices to the cloud platform. This is a library specifically designed for the Arduino IDE, so you can easily program your devices and connect them within minutes.

It supports multiple network interfaces and boards, like Ethernet Shield, Wifi Shield, and GSM. It also supports other boards like ESP8266 (or NodeMCU), Texas Instruments CC3200 Launchpad, and Adafruit CC3000 board. It requires a modern Arduino IDE version, starting at 1.6.3.


The first step to start building devices is to install the required libraries in the Arduino IDE to support exposing device resources like sensor values, lights, relays, and so on. In our case it was our Water Flow Sensor.

The easiest way to install new libraries is by using the library manager available in the Arduino IDE shown below:

Screen Shot 2018-04-17 at 15.59.00

After installation, we used an example piece of code supplied by that would connect our Node MCU esp8266 to an available wifi network. From there we would be able to create a dashboard and start sending data supplied by the flow rate sensor. Below is the code that connected us to the wifi and the website:

#include <SPI.h> 
#include <ESP8266WiFi.h> 
#include <ThingerWifi.h> 

ThingerWifi thing("username", "deviceId", "deviceCredential"); 

void setup() { 
thing.add_wifi("wifi_ssid", "wifi_credentials"); } 

void loop() { 
thing.handle(); }

All we had to do to use this code was to change the username, deviceId, and deviceCredential with our own credentials, and the wifi_ssid, wifi_password with the WiFi credentials.

Testing the WIFI and Commands 

Below we added 2 lines of code which allowed us to turn on and off the built in LED through the dashboard.

Declaring a control over a digital pin so we can alternate over on/off states. It is required to define the digital pin as OUTPUT in our setup code, or the resource will not work properly.


#include <ESP8266WiFi.h>
#include <ThingerESP8266.h>

#define USERNAME "Jack1bates"
#define DEVICE_ID "esp8266"
#define DEVICE_CREDENTIAL "jackbates"

#define SSID "iPhone (2)"
#define SSID_PASSWORD "jackbates95"


void setup() {


thing.add_wifi(SSID, SSID_PASSWORD);

thing["led"] << digitalPin(BUILTIN_LED);

void loop() {



Although this was a very large step in the right direction, we still had the matter of rewiring our circuit to the eps8266 and changing some of the code to ensure the setup works as it should.

Below is an image of what out dashboard may look like, where we could display current flow and total litres used.

Screen Shot 2018-04-17 at 16.32.57.png



Connecting to Wifi – esp8266 VS NodeMCUesp8266

The biggest challenge in our set up would be to send our data to a website to be shown graphically and help the user understand how much water they are really using. After some research, we decided to buy two WIFI enabled modules, the first being the esp8266 and secondly the NodeMCU8266. Both being part of the same family, but as we soon found out very different modules. Below is the process of connecting them both to the internet (or not) and which one we chose to use.

The ESP8266:

“This tiny and extremely cheap communication module allows you to establish a full and autonomous WiFi connection with your Arduino or Raspberry Pi microcontroller. A WiFi Serial Module works in both directions: it not only uses a TX/RX serial link to receive and send data, thus acting as a host for your WiFi applications, but can also entrust all the WiFi network-related functions to another application processor. By using serial commands, you’ll also be able to change the configurations of the WiFi Serial Module.”

At first glance, this module was quite small and didn’t really look like much, which made us a little skeptical at the start. But the module only having 8 pins and with a plethora of tutorials online we were very hopeful that this would be a quick and easy set up and we would be sending data to a website in no time.


Little to our knowledge, this module is notoriously difficult to set up. We first started with testing a simple blink test, the ‘hello world’ of the IOT community. After hours of countless failed setups and uploads, rolling back of software updates and error messages we decided we had spent too much time trying to get it to work and ditched the process there. We had read about similar issues online with no resolution which was also a factor for not using this module. Below shows the continual error message that stopped us connecting.

Screen Shot 2018-04-14 at 17.28.18

Although further research into the module showed that cheaper versions of the eps8266 had countless issues but the more expensive and ‘genuine’ modules mostly ran perfectly, so this is something to think about in the future and for anyone else looking to buy a similar moduel.


The NodeMCU ESP8266

“NodeMCU is an open source IoT platform. It includes firmware which runs on the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module. The term “NodeMCU” by default refers to the firmware rather than the dev kits.”

Straight out the box we were infinitely more impressed with this module and in the end was fairly easy to set up and connect to a webpage.

The Process:

Here is the online tutorial we used to firstly set up the module:

To use the module, we first had to download a series of drivers, which would allow us to communication with the module through a micro usb and give us the ability to directly upload custom code.

Next was downloading a series of libraries and board managers shown in the above video and uploading the ‘blink’ test as a first communication with the Nodemcu ESP8266.


Now the initial set up is complete, it should be a matter of uploading code to the Nodemcu esp8266 to connect it to the wifi which we will then use to send our raw data to a visual dashboard on a ready made website.

The IOT ecosystem contains a number of different types of companies focusing on hardware, device management, middleware, connectivity, security, analytics, and more of which we can use to display our data. Below is a list of 12 platform companies simplifying the process of implementing an IoT application which we will be considering.

  • Initial State
  • Cayenne – myDevices
  • Ubidots
  • Pubnub
  • Medium One
  • Bug Labs
  • Particle
  • MoBagel
  • Grove Streams
  • thethings.iO
  • Losant

Week 5 – Printing the Flow Rate to an LCD

Continuing on from last week, we now had the flow rate and total flow printing to the serial monitor and the LED’S working. We now want this information to be shown on an LCD which can be placed in front of any tap to give the user a direct visual of how much water they are using.

We bought the Smraza LCD 2004 Display Module which had a built in potentiometer and supported 4 lines and 20 characters which will allow us to supply more information to the user.

Upon testing the LCD, we were blissfully unaware that this Module only needed to be connected through the pins on the back as it had an i2c add on, and not the ones on the front as first thought. Although this set us back sometime and resulted in some very strange messages being printed we soon worked it out using the below youtube tutorial and started using the below pin setup.


GRD – Ground

VCC- 5v





The first step was to run a quick test to ensure the lcd was working and that it was able to print the information we wanted. Below we created a short piece of code which printed the flow rate and automatically increased it by 10ml every half second. The LCD would then print HIGH, MEDIUM or LOW, depending on the value.

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd (0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup () {


void loop(){

int num = 0;

while(num <100){
 lcd.setCursor(9, 0); 
 if(num <= 20){
 lcd.setCursor(0, 1);
 lcd.print("Flowrate is LOW ");
 delay (500);
 num += 10;}

else if(num > 20 && num <70){
 lcd.setCursor(0, 1); 
 lcd.print("Flowrate is MEDIUM");
 delay (500);
 num += 10;}

else {
 lcd.setCursor(0, 1); 
 lcd.print("Flowrate is HIGH ");
 delay (500);
 num += 10;}



After establishing the correct wiring, screen size value and libraries needed for the LCD to run, we were then ready to incorporate it into our master code and circuit. We first needed to decide what we were going to print on the LCD from the raw data we were already printing to the serial monitor.  This information had to be what would be most useful to the user, as the LCD would be placed in front of the tap they will be using. We had a choice of 4 different pieces of data we could use:

  • Current Flow Rate (litres per min)
  • Current Liquid Flowing (ml per sec)
  • Total Litres (Current period)
  • Average Usage

We decided that the ‘Current Liquid Flowing’ and ‘Total Litres’ would be the most useful for the user as it gives them direct readings of their water usage.

Applying this into our code was very straight forward and only took a small bit of manipulation of the existing code we had for the serial print. Below is the manipulated code we used to print to our LCD.







Screen Shot 2018-04-17 at 18.47.43.png

Full Code:








Flashing LED’s based on Flow Rate

The first stage of our setup was to get a green and red LED to respond to the flow sensor, turning on the green LED when the water flow is good, turning on the red LED when the water flow is too high and a flashing red LED when the water flow is in excess.

As we already had out basic code for the Flow Rate sensor we could dive straight in. We knew that the flow sensor was working because we were able to print the information to the serial monitor, shown below:


Flow Rate sensor code:

Implementing the LED’s was a very simple process, we attached the red LED into pin13 and the green into pin12. We then used and ‘if else’ statement to turn on the LED’s at different flow rates.

This is shown in the below video:

Full  code:

The next step in the process is to incorporate an LCD to provide real time information to the user.

Water Efficiency


I live with 6 friends in a Georgian town house, our water usage could definitely be more efficient, however it is hard to manage without having a gauge to look at.

Washing Machine Usage

Every time we use the washing machine, we use up to 80 litres of water. We use the washing machine 6 times per week. During the year, we use approximately 24000 litres of water at a cost of £70.06 per year

As it is a student house we do not have the choice to change to a more water efficient model. I calculated, we could save 9000 litres per year at a cost of £26.27.

If you did one less washing load each week, you would save 4000 litres per year. This could save me £11.68 per year.


Dishwasher UsagePicture2

We wash all our dishes by hand. This method can use less water than a dishwasher, but also depends on how often you wash the dishes, if you put plug in, have a full sink load or run the tap. I try to avoid washing just one or two items at a time. I also, remember to put the plug in and I don’t wash dishes under a running tap. If we washed the dishes half as often, we could save 7500 litres per year at a cost of £ 21.89 per year.

However it is hard to keep control of everyone’s washing up habits, unless something is there to help as a deterrent. After working this out it makes a lot more sense to use the washing machine because people keep the tap running instead of filling the sink which is far more efficient.



Flow Rate Sensor


‘The Arduino flow meter works on the principle of the Hall effect. According to the Hall effect is the production of a voltage difference across an electrical conductor and to an applied magnetic field perpendicular to the current (discovered by Edwin Hall 1879). Here, the Hall effect is utilised in the flow meter using a small fan/propeller-shaped rotor, which is placed in the path of the flowing liquid.’

We are using a flow rate sensor to help change the attitude of other around us by fitting it to faucets/showers/toilets. The flow rate sensor will measure the amount of water coming out of the tap and when the daily allowance in used the user/s will be notified.

We were initially considering a traffic light system above the sink as this would inform the user at the time. However, we thought that maybe more people should know; for example if it is a rented house, the landlord could be notified. According to my research the majority of tenants would feel more conscious of using more water than they should, if they knew that their landlord had an eye on it.

Blog 1 – Smart Water Metre

Project Aim

Create a smart water metre that tracks water usage around a home and gives a live feed of whats being used and where . For this project we will focus on the main tap used in the kitchen.


While we seem to be able to track many things in our life with a push of a button, our water usage isn’t one of them. Around the world, more and more cities are now experiencing major droughts leaving hundreds of thousands of people without water and they are only expected to get worse.

Taps are widely left on for long periods of time, whether this is while doing the dishes or brushing your teeth there are always savings to be made. If we had the ability to directly track what we were using on a minute by minute basis, we may be able to make small changes that can make a big difference.

Proposal Features

  • Minute by minute tracking of water consumption
  • Ability to set daily, weekly and monthly goals
  • Alerts when water consumption is too high
  • Suggestions of how to improve
  • Tangible conversions    i.e: 30litres = 85 cups of tea

Components Needed

  • Flow Rate Sensor
  • Motion Sensor
  • LCD Display

End Goal

Influence and educated people into how much water their really using and encourage them to set goals to reduce their water consumption.