I am doing a project to automate my hydroponic system. An HC-SR04 ultrasonic sensor detects the water level of tank A and if it is low, a pump from tank B will turn on and pump water into tank A. I am also controlling two peristaltic pumps that turn on and off depending on the pH level of the water in tank B. I have an analogue pH sensor that detects the pH levels in the water. Relays are being used to control the pumps. I am using a NODEMCU ESP12-E.
The problem is that when I integrate everything, my pump disregards the ultrasonic sensor reading and switches on and off irregularly. The same happens with my peristaltic pumps. I sense that the NODEMCU is torn between having to measure pH level and water level at the same time which is a problem
Is there any way to queue the inputs and the outputs so that the sensor readings do not interfere with the outputs? Or even to allow them to sense and control the pumps simultaneously if possible.