Escolar Documentos
Profissional Documentos
Cultura Documentos
e água potável?
A turbidez da água é uma unidade de medida importante para determinar a
qualidade da água e descreve o grau de nebulosidade da água.
Saída Digital: Sinal de nível alto/baixo (você pode ajustar o valor limite
ajustando o potenciômetro)
Temperatura de operação: 5 °C ~ 90 °C
Peso: 30g
void setup() {
Serial.begin(9600); //Baud rate: 9600
}
void loop() {
int sensorValue = analogRead(A0);// read the input on analog pin A0:
float voltage = sensorValue * (5.0 / 1024.0); // Convert the analog reading
(which goes from 0 - 1023) to a voltage (0 - 5V):
Serial.println(voltage); // print out the value you read:
delay(500);
}
int ledPin = 13; // Connect an LED on pin 13, or use the onboard one
int sensor_in = 2; // Connect turbidity sensor to Digital Pin 2
void setup(){
pinMode(ledPin, OUTPUT); // Set ledPin to output mode
pinMode(sensor_in, INPUT); //Set the turbidity sensor pin to input mode
}
void loop(){
if(digitalRead(sensor_in)==LOW){ //read sensor signal
digitalWrite(ledPin, HIGH); // if sensor is LOW, then turn on
}
else
{
digitalWrite(ledPin, LOW); // if sensor is HIGH, then turn off the led
}
}
Carregue o código acima e verifique se o fio Dout do conversor A & D está
conectado com o pino Digital D2 do Arduino. O LED acenderá e desligará
dependendo da pureza da água. Comece com água limpa e comece a adicionar
lama e você verá quando o valor de turbidez cruzar o valor limite o estado do
LED será alterado. Claro, você pode substituir este led por um relé para
controlar uma bomba ou uma campainha para avisá-lo.
Então, agora depois de cobrir o básico, agora é hora de levar este projeto a
outro nível. Desta vez, exibiremos os valores do sensor de turbidez da água no
LCD I2C. Dessa forma, você não precisará de um laptop e poderá monitorar
os valores em tempo real.
/*
Download Libraries:
https://www.electroniclinic.com/arduino-libraries-download-and-projects-they-are-used-in-
project-codes/
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); //0x27 is the i2c address, while 16 = columns, and 2 = rows.
void setup() {
pinMode(A0, INPUT);
lcd.init(); //Init the LCD
lcd.backlight(); //Activate backlight
lcd.home();
}
void loop() {
delay(500);
}
Digamos que
Turbidity_Sensor_Voltage = Y
/*
* Arduino Turbidity Meter, Water Quality monitoring
* Download Libraries
* https://www.electroniclinic.com/arduino-libraries-download-and-projects-they-are-used-in-
project-codes/
*
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); //0x27 is the i2c address, while 16 = columns, and 2 = rows.
void setup()
{
Serial.begin(9600); // for debugging purposes
pinMode(Turbidity_Sensor_Pin, INPUT);
lcd.init(); //Init the LCD
lcd.backlight(); //Activate backlight
lcd.home();
}
void loop()
{
Turbidity_Sensor_Voltage = 0;
/* its good to take some samples and take the average value. This can be quite handy
* in situations when the values fluctuates a bit. This way you can take the average value
* i am going to take 600 samples
*/
for(int i=0; i<samples; i++)
{
Turbidity_Sensor_Voltage += ((float)analogRead(Turbidity_Sensor_Pin)/1023)*5;
}
Turbidity_Sensor_Voltage = Turbidity_Sensor_Voltage/samples;
// uncomment the following two statments to check the voltage.
// if you see any variations, take necessary steps to correct them
// once you are satisfied with the voltage value then again you can comment these lines
//Serial.println("Voltage:");
//Serial.println(Turbidity_Sensor_Voltage);
Turbidity_Sensor_Voltage = round_to_dp(Turbidity_Sensor_Voltage,2);
if(Turbidity_Sensor_Voltage < 2.5){
ntu = 3000;
}else{
ntu = -1120.4*square(Turbidity_Sensor_Voltage)+ 5742.3*Turbidity_Sensor_Voltage - 4352.9;
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print(Turbidity_Sensor_Voltage);
lcd.print(" V");
lcd.setCursor(0,1);
lcd.print(ntu);
lcd.print(" NTU");
delay(10);
}
https://www.electroniclinic.com/turbidity-sensor-with-arduino-for-water-
quality-monitoring-turbidity-meter/