Check if the pump is High or Low

I'm making a system to control a dosing machine in PHP.
But I need to always check if the pump is High.
I'm using the curl call in PHP and in ESP32. Every query returns low and if I run the pump with the code digitalWrite(pumpPin1, HIGH) the pump executes
the code below the get function
void setup() {

pinMode(pin, INPUT);

}

void setup() {
server.on("/status", HTTP_GET, {
Serial.println("Pump Status 1");
// Read the state of the digital pin
int pinState = digitalRead(pin);
// Convert the pin state to a string to send as response
String response = "Pin " + String(pin) + " state: " + (pinState == HIGH ? "HIGH" : "LOW");
// Send the response to the client
server.send(200, "text/plain", response);

});
Serial.println("Server started started");

// Start the server
server.begin();

}
Thank you, I'm still new to esp32

OK. Does it work the way you want?

1 Like

Hi @jeancarlosc

welcome to the arduino forum and happy new year.

Your description what you want to achieve is confiusing.

Your are writing about PHP? So how is the PHP-code related to your ESP32??

The code you have posted has to functions seup().
This is one too much. Any Arduino-code can have only one single setup-function

what do you mean wih

Really ? The pump itself executes code??
don't think so.

You should describe the pure functionality what you want to have without any code.
You are good with normal words and know how to use them.
In Programm your ar e yet a beginner. So it is very likely that you have somemisconceptions about code. This is the eason why should describe the wanted functionality in normal words.

Manyquestions left open.

I'm pretty sure that you agree and will follow the way how to solve your problem mimimum 200 minutes faster.
This requires to invest 20 minutes of your precious time to read how to speedup solving your problems.

Directly after registering you got presented informations how to speed up solving your problem.
You should really read it.

best regards Stefan

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.