Hi guys, my want to control the water motor with esp8266 thourgh the relay. This is wiring diagram, im wiring base on it except im using 6V power instead of 9V:
This is my code just to test if the relay is blinking:
void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(D0, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(D0, 1);
delay(2000);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(D0, 0);
delay(3000);
}
So the problem is that when i connect VCC of the relay to VIN on esp the led on esp working fine, its blinking but not the relay, the green led on the relay always turn on and the motor run nonstop. But when I tried to change VCC of relay to 3V on esp then the relay start to blinking same with led on esp, but the motor not running anymore. What am i doing wrong here?
P/s: Sorry if my english was bad
If this is your complete wiring you probably fried your ESP. The ESP8266 cannot drive a relay directly it needs an amplifier (usually a transistor). Also the relay must get a free run diode to catch the return current of the solenoid.
It may be that you're using a board containing all that stuff but if you do so you failed to provide the necessary information.
We need a wiring diagram and links to the used hardware.
if you have difficulties to write in english use the help of google-translate.
Write down all words in your native language and let do google-translate the translation. The grammar won't be brilliant but is good understandable. You can do the same with the english postings and translate them to your native language.
You should post a handdrawn schematic of your wiring.
I emphasize
handdrawn
everything "above" handdrawn has no additional technical information except beeing an pedant user investing time at the wrong place.
The microcontroller-word is not superstandardised like usb-devices. You have to take care of more things than just "does the plug fit into the socket?"
The real important information what is wired to what is harder to retrieve from a fritzing-picture than from a handdrawn schematic
On a handdrawn schematic you
just write down those IO-pins that are really connected
draw the text in a size that is big enough to be easy to read
additional information means adding downloadable-links to datasheets or attaching the PDF-file of the datasheets or at least links to the onlineshops where you bought the parts.
as there are
the relay,
the moisture-sensor,
the dht-sensor
In the fritzing-software you found "some" relay that looks similar to the one you have but it is not exact the same. And therefore it might be that it gives wrong information and less exact information
Input: low-active or high-active
opto-coupler: Yes or No
jumper for supplying relay-coil from main power-supply or not
This is information that can be relevant and can be found in the datasheet
Usually this is made by another post and not by editing the original post.
Anyway, in your wiring diagram you don't power the NodeMCU. As you provide the power for the relay from the same source I guess you have some power for it but doesn't it provide enough current for the board and the relay?
the problem is cause you have connected relay to Vin try to connect it to 3v3 V this should work i had the same problem but i fixed it with one easy replace