As we all know that water scarcity has affected almost every continent and was listed in 2019 by the World Economic Forum asone of the largest global risks in terms of potential impact over the nextdecade. My eyes were filled with tears when I read that at some places in African and Asian continents children cannot go to school because they have to stand in a long queue along with their parents to fill water for their daily household courses. Even farmers are not able to grow crops in such places. Some places of the world are enjoying clean, healthy water whereas some places have to suffice their needs from water in muddy pools formed by the rain. We donate blood because it can save life, so why are we not donating water which can save our existence. IoT has already paved the way for us but we fail to establish itin real life.
The places where potable water is available easily they will have option to donate water to other areas. The donated water will be directed to the common rainwater harvesting channel of the society and a social community van would transport that water to nearby places where it is needed. The minimum amount of water that one can donate is one litre. If there is sufficient amount of water collected then a notification would be send to the remote places. Mobile app would handle all data regarding water purity, saturation point, water reserved, amount to donate and request for water.
Hardware required:Setup your argon using this tutorial and upload your first code(Blink code or hello world code).
Connect your sensors as shown below:
The libraries used are :
#include <Adafruit_DHT.h>
#include <SparkJson.h>
#include <LiquidCrystal_I2C_Spark.h>
I have functions for DHT11, rain sensor
void readDht()
{
// Wait a few seconds between measurements.
delay(2000);
float h = dht.getHumidity();
float t = dht.getTempCelcius(); // Read temperature as Celsius
float f = dht.getTempFarenheit(); // Read temperature as Farenheit
if (isnan(h) || isnan(t) || isnan(f)) // Check if any reads failed and exit early (to try again).
{
Serial.println("Failed to read from DHT sensor!");
return;
}
float hi = dht.getHeatIndex(); // Compute heat index
float dp = dht.getDewPoint();
float k = dht.getTempKelvin();
humid = h;
temp = t;
dPoint = dp;
hIndex =hi;
}
// unfortunately my rain sensor is not working but code would be like this
void rainSensor()
{
int sensorReading = analogRead(A5);
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
lcd->setCursor(0,0);
switch (range)
{
case 0:
lcd->print("RAINING");
break;
case 1:
lcd->print("RAIN WARNING");
break;
case 2:
lcd->print("NOT RAINING");
break;
}
delay(1000);
}
These functions were used to read data from webhook, update data to webhook
void resetWaterAmt()
{
donateAmount = 0;
char buf[128];
snprintf(buf, sizeof(buf), "{\"sendL\":%.2f}", donateAmount);
Serial.printlnf("publishing %s", buf);
Particle.publish("Database", buf, PRIVATE);
delay(3000);
}
void dataRead(const char *event, const char *data)
{
StaticJsonBuffer<255> jsonBuffer;
char *mutableCopy = strdup(data);
JsonObject& root = jsonBuffer.parseObject(mutableCopy);
free(mutableCopy);
donateAmount = atof(root["sendL"]);
if(donateAmount>0)
digitalWrite(pump,HIGH);
}
void publishData()
{
char buf[256];
snprintf(buf, sizeof(buf), "{\"temp\":%.2f,\"humid\":%.2f,\"dp\":%.2f,\"hi\":%.2f}",
temp, humid, dPoint, hIndex);
Serial.printlnf("publishing %s", buf);
Particle.publish("Database", buf, PRIVATE);
delay(3000);
}
The full code is attached below.
Particle webhooks for Firebase:Step 1: Go to firebase and sign in using your google account and click on create project. Enter name for your project and click create.
Step 2: Create a realtime database for your project. Click start in test mode while creating database.
Step 3: Note the auth token from project setting->Service accounts->Database Secret-> add secret and copy it.
Step 4: Go to Particle Console and create a new integration like shown below. Look and note which integration is for PUT and which is for GET.
You are now only left with app development in thunkable or MIT app inventor.
App for the project:
Comments