✅ 1. System Overview

This system consists of three main components:

  • Sensors: Collect water quality data.
  • Microcontroller (ESP32/NodeMCU): Sends sensor data to the Favoriot platform.
  • Favoriot Platform: Stores, analyzes, and visualizes the data.

✅ 2. Main Component List

Component Description Quantity
ESP32 or NodeMCU Microcontroller 1
pH Sensor Measures water acidity 1
Turbidity Sensor Measures water turbidity 1
TDS Sensor Measures total dissolved solids 1
Temperature Sensor (DS18B20) Measures water temperature 1
Breadboard For prototyping 1
Jumper wires Circuit connections as needed
Power Supply 5V Adapter or Battery 1

✅ 3. System Architecture

+-----------+    +-------------------+    +------------+
|  Sensors  | -> | ESP32/NodeMCU MCU | -> |  Favoriot  |
+-----------+    +-------------------+    +------------+
(pH, TDS, Temperature, Turbidity)        (Cloud IoT Platform)

✅ 4. Step-by-Step Approach

📌 Step 1: Hardware Setup

Connect sensors to NodeMCU/ESP32 as follows:

Sensor Sensor Pin NodeMCU/ESP32
pH Sensor Analog Out A0 (ADC)
Turbidity Analog Out A1
TDS Sensor Analog Out A2
DS18B20 Data pin GPIO 4 (D2)

Use 5V/GND from NodeMCU pins for power.


📌 Step 2: Favoriot Account Setup

  1. Register or log in at platform.favoriot.com.
  2. Create a new project, e.g., SmartWaterMonitoring.
  3. Add a new device and note the Device Developer ID and Access Token.

📌 Step 3: ESP32/NodeMCU Programming

Use Arduino IDE.

Install required libraries:

  • ESP8266WiFi or WiFi.h (ESP32)
  • OneWire.h & DallasTemperature.h (temperature sensor)
  • HTTPClient.h (ESP32) or ESP8266HTTPClient.h (NodeMCU)

Complete Sample Code (ESP32):

#include <WiFi.h>
#include <HTTPClient.h>
#include <OneWire.h>
#include <DallasTemperature.h>

const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";

// FAVORIOT API
String device_developer_id = "YOUR_DEVICE_ID";
String access_token = "YOUR_ACCESS_TOKEN";
String url = "https://apiv2.favoriot.com/v2/streams";

// Sensor Pins
#define PH_SENSOR_PIN 34
#define TURBIDITY_SENSOR_PIN 35
#define TDS_SENSOR_PIN 32
#define ONE_WIRE_BUS 4

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("WiFi connected!");
  sensors.begin();
}

void loop() {
  sensors.requestTemperatures();
  float temperature = sensors.getTempCByIndex(0);
  
  // Read analog sensor data
  float phValue = analogRead(PH_SENSOR_PIN) * (14.0 / 4095);
  float turbidityValue = analogRead(TURBIDITY_SENSOR_PIN) * (100.0 / 4095);
  float tdsValue = analogRead(TDS_SENSOR_PIN) * (1000.0 / 4095);

  // Display readings in Serial Monitor
  Serial.printf("Temp: %.2f C, pH: %.2f, Turbidity: %.2f NTU, TDS: %.2f ppm\n",
                temperature, phValue, turbidityValue, tdsValue);

  // Send data to Favoriot
  HTTPClient http;
  http.begin(url);
  http.addHeader("Content-Type", "application/json");
  http.addHeader("Apikey", access_token);

  String postData = "{";
  postData += "\"device_developer_id\":\"" + device_developer_id + "\",";
  postData += "\"data\":{";
  postData += "\"temperature\":" + String(temperature) + ",";
  postData += "\"ph\":" + String(phValue) + ",";
  postData += "\"turbidity\":" + String(turbidityValue) + ",";
  postData += "\"tds\":" + String(tdsValue);
  postData += "}}";

  int httpCode = http.POST(postData);
  String payload = http.getString();

  Serial.println(httpCode);
  Serial.println(payload);

  http.end();

  delay(10000); // Send data every 10 seconds
}

📌 Step 4: Data Visualization in Favoriot

  • Login to Favoriot.
  • Go to Dashboard → Create Dashboard.
  • Add Widgets for sensor parameters:
    • Gauge Widget: Temperature, pH, TDS.
    • Line Chart: Real-time trends.
  • Monitor data in real-time.

📌 Step 5: Setting Up Alerts

Use Favoriot’s built-in alerts to send notifications via Email or Telegram when sensor readings exceed thresholds (e.g., pH too high or low, high turbidity).

Example:

  • Set alerts if pH is below 6 or above 8.
  • Set alerts if Turbidity exceeds 5 NTU.

✅ 5. Testing and Deployment

  • Test sensors in clean and polluted water to ensure monitoring accuracy.
  • Continuously monitor data stability and platform responsiveness.

✅ 6. Results and Benefits

  • Ensures a safe water supply.
  • Real-time monitoring and rapid response capability.
  • Long-term data storage for detailed analysis.

✅ Conclusion

This approach provides a complete, scalable, cost-effective, and user-friendly IoT solution using Favoriot to intelligently and automatically monitor urban water quality.

References

Disclaimer

This article provides a step-by-step guide and only serves as a guideline. The source code may need adjustments to fit the final project design.

Podcast also available on PocketCasts, SoundCloud, Spotify, Google Podcasts, Apple Podcasts, and RSS.

One response

  1. […] [Tutorial]: Smart Water Quality Monitoring for Cities using Favoriot IoT Platform. […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share This

Share this post with your friends!