UPDATE: the sticking problem has gone away but I don't know why. I am using the Vin, which is a 4.6ish volt source, to power the pump. When the board is sensing but not pumping I measure a total draw of 30 mA using a USB J7-c digital tester. When the pump is activated but dry and not pumping water I measure 150 mA. If I immerse the pump in water, which is its intended design, the total circuit uses 300mA. I'm a little worried how much that number will jump when I add tubing. I have a feeling it will fry the board. Thoughts?
Hello, I'm new to using microcontrollers with relays. I purchased a kit on Amazon - https://www.amazon.com/dp/B09BMVS366?psc=1&ref=ppx_yo2ov_dt_b_product_details - that I want to control with an ESP8266 (specifically NodeMCU Amica / ESP8266MOD) following these instructions: https://poanchen.github.io/blog/202...system-that-is-connected-to-azure-iot-central. I am able to upload the software to the ESP8266, monitor the serial port to see the capacitive moisture sensor's reading and to calibrate the software to trigger the relay, which controls the pump. However, while both the software (via the serial monitor) and the relay (via the indicator lights) says I am turning the pump on and off, the relay stays on. I can get it to turn off by pulling the "In" pin or the VCC but it won't stop as it is supposed to do. I am using the "Vin" pin to power the relay, which measures 4.6V. I also tried powering it with the 3.3V pin from the 8266 and both result in the aforementioned situation.

Hello, I'm new to using microcontrollers with relays. I purchased a kit on Amazon - https://www.amazon.com/dp/B09BMVS366?psc=1&ref=ppx_yo2ov_dt_b_product_details - that I want to control with an ESP8266 (specifically NodeMCU Amica / ESP8266MOD) following these instructions: https://poanchen.github.io/blog/202...system-that-is-connected-to-azure-iot-central. I am able to upload the software to the ESP8266, monitor the serial port to see the capacitive moisture sensor's reading and to calibrate the software to trigger the relay, which controls the pump. However, while both the software (via the serial monitor) and the relay (via the indicator lights) says I am turning the pump on and off, the relay stays on. I can get it to turn off by pulling the "In" pin or the VCC but it won't stop as it is supposed to do. I am using the "Vin" pin to power the relay, which measures 4.6V. I also tried powering it with the 3.3V pin from the 8266 and both result in the aforementioned situation.

C-like:
const int AirValue = 733; // you might need to calibrate this number, instruction is down below
const int WaterValue = 355; // you might need to calibrate this number, instruction is down below
const int DrySoilMoisturePercentage = 50;
const int SoilMoisturePin = A0;
const int RelayPin = D2;
int soilMoistureValue = 0;
int soilmoisturepercent = 0;
void setup() {
Serial.begin(9600);
pinMode(SoilMoisturePin, INPUT);
pinMode(RelayPin, OUTPUT);
digitalWrite(RelayPin, HIGH);
}
void loop() {
soilMoistureValue = analogRead(SoilMoisturePin);
soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
Serial.print(soilmoisturepercent);
Serial.println("%");
if (soilmoisturepercent <= DrySoilMoisturePercentage) {
Serial.println("Water pumps running...");
digitalWrite(RelayPin, LOW);
delay(1000);
}
if (soilmoisturepercent >= DrySoilMoisturePercentage) {
Serial.println("Water pumps stopped...");
digitalWrite(RelayPin, HIGH);
delay(1000);
}
}
Last edited: