element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Better World with Arduino
  • Challenges & Projects
  • Project14
  • Better World with Arduino
  • More
  • Cancel
Better World with Arduino
Blog Water awareness
  • Blog
  • Forum
  • Documents
  • Events
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Better World with Arduino to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: amgalbu
  • Date Created: 21 May 2022 5:55 AM Date Created
  • Views 4542 views
  • Likes 6 likes
  • Comments 0 comments
  • water-awareness
  • better world with Arduino
  • betterworldch
Related
Recommended

Water awareness

amgalbu
amgalbu
21 May 2022

This winter my area has been hit by a terrible drought: we had no rainfalls for more than 100 days. Even if -till now- there has not been outages of running water, I realized how precious water is and, for this reason, I would like to create something that can build awareness about water use and abuse. I was thinking of a small device based on Nicla Sense ME  to install on the top of the tap lever. By measuring the tilt of the tap lever, the device will make a rough estimation of water flow (in liters per minute). Additionally, thanks to the 3-axis magnetometer, it will also be possible to determine the horizontal orientation of the tap lever and make an estimation of the amount of fossil fuels required to heat the water and, consequently, the amount of CO2 released. With proper calibration, the same device could be installed in a shower, where the tap is installed vertically on the wall

This was a sketch to show the original idea

image

Element14 was so nice to send me a Nicla Sense ME board, but I was so clumsy that I damages the board during the build. For this reason, I felt back to Arduino Nano 33 IoT. The main issue, however, is that the IMU of the Arduino 33 Nano IoT does not have a magnetometer, so I have not the absolute heading of the tap lever

To build the hardware, you need

  1. An Arduino Nano 33 IoT
  2. A 0.91 inches I2C OLED display
  3. a push button
  4. a DC-DC converter 
  5. a 3.7V Lipo battery

Here is the wiring diagram

image

Arduino sketch performs three basic tasks

  1. Reads accelerometer to determine how open the tap is. If the tap is open, then water flow is calculated
  2. Reads gyroscope to extrapolate, from angular velocity, an approximation of the orientation of the tap lever. When tap is open, heading is needed to compute the amount of energy (and thus the amount of natural gas) to heat the water
  3. Reads the status of the button. When long-pressed, the sketch enters a calibration mode. User will have to 
    1. Switch fully on the tap, then press the button. The sketch will store the accelerometer readings for this position
    2. Close the tap, then press the button. The sketch will store the accelerometer readings for this position

To calculate the amount of water provided, we make an interpolation based on a maximum flow rate when tap is fully open. The code to calculate the current flow rate is

double perc = (accelZFull + (accelZ - accelZClose)) / (accelZClose - accelZFull);
double flow = FLOW_MAX_MILLILITRE_SEC * perc;
double deltaMs = millis() - prevMs;
double milliLitres = flow * deltaMs / 1000.0; 
  
partialMilliLitres += milliLitres;
totalMilliLitres += milliLitres;

where 

  • accelZ is the current accelerometer reading
  • accelZFull is the accelerometer reading when the tap is fully open (stored during the calibration procedure)
  • accelZClose is the accelerometer reading when the tap is closed (stored during the calibration procedure)
  • FLOW_MAX_MILLILITRE_SEC is the flow rate when the tap is fully open expressed in millilitres per second. This constant is defined as

    #define FLOW_MAX_MILLILITRE_SEC ((FLOW_MAX_LITRE_MIN * 1000.0) / 60.0) 

    and

#define FLOW_MAX_LITRE_MIN  24.0

To estimate the "heading" of the tap, I will use the gyroscope. Currently the algorithm is in it initial stages, and needs to be improved

  // make a moving average of the readings
  avgGX = (avgGX * 0.9) + (gX * 0.1);
  
  float delta = millis() - prevFastMs;
  if (delta > 0)
  {
    // update heading only when velocity is greater than a threshold (IMU has an offset)
    if ((appStatus == APP_NORMAL) && (abs(avgGX) > 5.0))
    {
      heading = heading + (avgGX * delta / 1000.0);
    }

    prevFastMs = millis();
  }

The value of the heading is later used to calculated the amount of energy

double percHot = (heading - ORIENT_MIN) / (ORIENT_MAX - ORIENT_MIN);
double co2 = CO2_GRAMS_PER_LITER * percHot * milliLitres / 1000.0;

where CO2_GRAMS_PER_LITER has been calculated from the amount of natural gas required to raise the temperature of a liter of water from 10 °C (the average temperature of cold water) to 40 °C. 

#define CO2_GRAMS_PER_LITER   60.0

One liter of water weights about 1 kg

The specific heat capacity of water is approximately 4.2 J / g.K

The increase in temperature is 25 Kelvin (40-15)

So the energy needed is 1000 [g] x 25 [K] x 4.2 [J / g.K] = 1.05 MJ

I assumed the calorific value of gas to be 35 MJ / standard cubic meter, so to heat 1 liter I need 1.05 [MJ] / 35 [MJ / smc] = 0,03 [smc]

A standard cubic meter of methane weights 550 g, so to heat the water I will burn 0,03 [smc] * 550 [g / smc] = 16,5 g

For a chemistry

image

Burning 16.5 g of methane will produce 16.5 [g] * 2.75 = 45 [g] and I rounded to 60 [g] to take into account boiler efficiency etcetera

Here are some pictures of the device

image

image

image

image

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Full code for this project is available on my github repository

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube