0% found this document useful (0 votes)
5 views

Coding

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Coding

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <ESP8266WiFi.

h>

// WiFi credentials

const char* ssid = "YOUR_WIFI_SSID";

const char* password = "YOUR_WIFI_PASSWORD";

// Pin definitions

const int pump_a_pin = D1; // GPIO5 for Pump A

const int pump_b_pin = D2; // GPIO4 for Pump B

const int mixing_pump_pin = D3; // GPIO0 for Mixing Pump

const int sensor_pin = A0; // Analog pin for sensor

// Variables for sensor readings

float sensor_reading = 0.0;

void setup_wifi() {

delay(10);

Serial.println();

Serial.print("Connecting to ");

Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {

delay(500);

Serial.print(".");

Serial.println("");

Serial.println("WiFi connected");

Serial.println("IP address: ");


Serial.println(WiFi.localIP());

void setup() {

pinMode(pump_a_pin, OUTPUT);

pinMode(pump_b_pin, OUTPUT);

pinMode(mixing_pump_pin, OUTPUT);

Serial.begin(115200);

setup_wifi();

void loop() {

// Read sensor data

sensor_reading = analogRead(sensor_pin);

// Perform control logic based on sensor reading

if (sensor_reading > 500) {

// Turn on Pump A

digitalWrite(pump_a_pin, HIGH);

digitalWrite(pump_b_pin, LOW); // Ensure Pump B is off

digitalWrite(mixing_pump_pin, LOW); // Ensure Mixing Pump is off

} else if (sensor_reading > 300 && sensor_reading <= 500) {

// Turn on Pump B

digitalWrite(pump_a_pin, LOW); // Ensure Pump A is off

digitalWrite(pump_b_pin, HIGH);

digitalWrite(mixing_pump_pin, LOW); // Ensure Mixing Pump is off

} else if (sensor_reading <= 300) {

// Turn on Mixing Pump

digitalWrite(pump_a_pin, LOW); // Ensure Pump A is off

digitalWrite(pump_b_pin, LOW); // Ensure Pump B is off


digitalWrite(mixing_pump_pin, HIGH);

// You can add additional control logic here as needed

delay(1000); // Adjust delay based on your requirements

You might also like