/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: **Sensor Data**
- Source Code NOT compiled for: ESP32 DevKit V1
- Source Code created on: 2024-11-08 07:16:01
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* The FISH_POND_MONITORING project aims to automate */
/* fish pond monitoring by integrating sensors for */
/* water quality, temperature, and fish activity, */
/* ensuring optimal conditions for aquatic life. */
/****** END SYSTEM REQUIREMENTS *****/
/* START CODE */
/****** DEFINITION OF LIBRARIES *****/
#include //https://github.com/hafidhh/FlowSensor-Arduino
#include //https://github.com/adafruit/DHT-sensor-library
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t Water_flow_YF_S201_OUT_PIN_D4 = 4;
const uint8_t Temp_humidity_DHT11_DOUT_PIN_D13 = 13;
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
// Flow sensor instance
FlowSensor flowSensor(1, Water_flow_YF_S201_OUT_PIN_D4); // Assuming type 1 for the flow sensor
// DHT sensor instance
DHT dht(Temp_humidity_DHT11_DOUT_PIN_D13, DHT11); // Using DHT11 for temperature and humidity
void setup(void)
{
// Initialize serial communication for debugging
Serial.begin(9600);
// Initialize sensors
flowSensor.begin(flowSensor.count);
dht.begin();
// Set pin modes
pinMode(Water_flow_YF_S201_OUT_PIN_D4, INPUT);
pinMode(Temp_humidity_DHT11_DOUT_PIN_D13, INPUT_PULLUP);
}
void loop(void)
{
// Read flow rate and volume from the flow sensor
flowSensor.read();
float flowRate = flowSensor.getFlowRate_m(); // Get flow rate in liters/minute
float volume = flowSensor.getVolume(); // Get total volume in liters
// Read temperature and humidity from the DHT sensor
float temperature = dht.readTemperature(); // Read temperature in Celsius
float humidity = dht.readHumidity(); // Read humidity in percentage
// Print sensor data to the Serial Monitor
Serial.print("Flow Rate: ");
Serial.print(flowRate);
Serial.println(" L/min");
Serial.print("Total Volume: ");
Serial.print(volume);
Serial.println(" L");
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
// Add a delay before the next reading
delay(2000); // Delay for 2 seconds
}
/* END CODE */