Translate

Monitor PH dan Turbidity TDS Serta Water Level JSN-SR04 IOT BLYNK 2.0 ADS1115 Nodemcu ESP8266

Monitor PH dan Turbidity TDS Serta Water Level JSN-SR04 IOT BLYNK 2.0 ADS1115 Nodemcu ESP8266


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor PH dan turbidity serta water level atau ketinggia air secara realtime online dengan server IOT Blynk 2.0 sehingga bisa dimonitor secara jarak jauh. untuk lebih jelasnya berkut adalah koding dan skemanya.


a. Skema dan Komponen



b. Program Nodemcu ESP8266

#define BLYNK_TEMPLATE_ID "TMPL6wOCxxxxx"
#define BLYNK_TEMPLATE_NAME "monitor ph tds"
#define BLYNK_AUTH_TOKEN "VOK0cWiFN5ycHj3SV_snEDXTfTfeixxxx"
#define BLYNK_PRINT Serial  

#define  BLYNK_PRINT Serial  
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_ADS1015.h>

#define trigPin D6
#define echoPin D7

LiquidCrystal_I2C lcd(0x27,16,2);

Adafruit_ADS1115 ads1115;

long duration, distance;
float TempC;
float pHValue;
long ntu;
int ntunew;
int adcntu;
int adcPH;
int h;
int rawValue;
int TempCx;
int pHValuex;
int ntux;
float ntufix;
int relay1 = D8;
int relay2 = D5;
WidgetLED led1(V3);
WidgetLED led2(V4);

BlynkTimer timer;

char ssid[] = "hotspothpku";
char pass[] = "1234567890";

void sendSensor()
{
 Blynk.virtualWrite(V0, pHValue);
 Blynk.virtualWrite(V1, ntux);
 Blynk.virtualWrite(V2, distance);
 delay(1000);
}

void setup(){ 

pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
      
ads1115.begin();
ads1115.setGain(GAIN_ONE); 
    
Wire.begin();  

Serial.begin(9600);
lcd.begin();

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(1000L, sendSensor);
}

void loop(){

  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(2); // Added this line
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
 
adcPH = ads1115.readADC_SingleEnded(0);
pHValue = (adcPH - 2136.84) / 440.283;

adcntu = ads1115.readADC_SingleEnded(1);                   
ntu = (adcntu - 30700.0) / 1;

if(ntu < 0){
 ntu = 0; 
}

ntux = map(ntu, 0, 100, 190, 0);

if(ntux < 0){
 ntux = 0; 
}

  lcd.setCursor(0,0);
  lcd.print("Ph: ");
  lcd.print(pHValue);
  lcd.print(" ");
  lcd.print(distance);
  lcd.print("  ");
   
  lcd.setCursor(0,1);
  lcd.print("NTU: ");
  lcd.print(ntux);
  lcd.print(" %     ");

if(distance <= 4){
 digitalWrite(relay1, LOW);
}
if(distance > 4){
 digitalWrite(relay1, HIGH);
}

if((pHValue > 6)&&(pHValue < 9)&&(ntu < 5)){
  led1.on();
  led2.off(); 
}else{
  led1.off();
  led2.on();
}

  Blynk.run();
  timer.run();
  delay(200);
}



c. VIDEO HASILNYA




No comments:

Post a Comment