You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
803 B
32 lines
803 B
#include <OneWire.h>
|
|
#include <DallasTemperature.h>
|
|
|
|
#define ONE_WIRE_BUS 2
|
|
OneWire oneWire(ONE_WIRE_BUS);
|
|
DallasTemperature sensors(&oneWire);
|
|
void setup(void)
|
|
{
|
|
Serial.begin(9600);
|
|
Serial.println("SMART WATER IoT (Koutkou-Hidri-Skouloufianakis)\n");
|
|
sensors.begin();
|
|
}
|
|
void loop(void)
|
|
{
|
|
//TEMPERATURE SENSOR
|
|
sensors.requestTemperatures();
|
|
Serial.print("Temperature is: ");
|
|
Serial.print(sensors.getTempCByIndex(0));
|
|
Serial.println(" °C");
|
|
|
|
//TURBIDITY SENSOR
|
|
int sensorValue = analogRead(A0);
|
|
float voltage = sensorValue * (5.0 / 1024.0);
|
|
float ntu = -1120.4*square(voltage)+ 5742.3*voltage - 4352.9;
|
|
|
|
Serial.print ("Turbidity is: ");
|
|
Serial.print (voltage);
|
|
Serial.print (" V ");
|
|
Serial.print (ntu);
|
|
Serial.println (" NTU\n");
|
|
delay(1500);
|
|
}
|
|
|