Commit 95f46db8 authored by Samaranayake S.L's avatar Samaranayake S.L

Nutrition dosing 1st phase

parent c4d808d4
#include <EEPROM.h>
#include "GravityTDS.h"
#define TdsSensorPin A1
GravityTDS gravityTds;
const int RELAY_PIN = A5; // the Arduino pin, which connects to the IN pin of relay
float temperature = 25,tdsValue = 0;
void setup()
{
Serial.begin(115200);
gravityTds.setPin(TdsSensorPin);
gravityTds.setAref(5.0); //reference voltage on ADC, default 5.0V on Arduino UNO
gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC
gravityTds.begin(); //initialization
pinMode(RELAY_PIN, OUTPUT);
}
void loop()
{
//temperature = readTemperature(); //add your temperature sensor and read it
gravityTds.setTemperature(temperature); // set the temperature and execute temperature compensation
gravityTds.update(); //sample and calculate
tdsValue = gravityTds.getTdsValue(); // then get the value
Serial.print(tdsValue,0);
Serial.println("ppm");
if (tdsValue>350){
digitalWrite(RELAY_PIN, LOW); // turn on pump
delay(1000);
Serial.println("pump off");
tdsValue = gravityTds.getTdsValue(); // then get the value
}
else if(tdsValue<350){
digitalWrite(RELAY_PIN, HIGH); // turn on pump
delay(500);
digitalWrite(RELAY_PIN, LOW); // turn on pump
delay(1000);
Serial.println("pump on");
tdsValue = gravityTds.getTdsValue(); // then get the value
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment