0

Issue

-When using the ESP8266 wired up in this way it will randomly disconnect the USB interface when it powers the relay. It may then re-connect but is sporadic.

-The code can be viewed below, but essentially the relay is powered for 300ms then waits 10 seconds to loop.

Wiring Diagram https://i.stack.imgur.com/4mycx.png

Tests:

I have swapped out the relay, pump, ESP8266, aswell as re-wiring the circuit multiple times to check for a short. I also have a integer incrementing every loop cycle, when the ESP8266 is able to re-connect it will print this variable, which shows the board is not crashing:

Serial output https://i.stack.imgur.com/ziM8g.png

I then modified the diagram so the 5v power was not in parallel, but where two different power sources, one for the ESP8266 and one for the pump circuit, however the same issue was observed:

Test Wiring Diagram https://i.stack.imgur.com/7S0aP.png

Question:

Why does the USB disconnect when sending the control signal to the relay? Is there a way to mitigate this?

Code:

int relayInput = 5; // the input to the relay pin
int debug_test = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(relayInput, OUTPUT); // initialize pin as OUTPUT
}

void loop() {
  // put your main code here, to run repeatedly:

  debug_test ++ ;
  Serial.println(debug_test);
  digitalWrite(relayInput, HIGH); // turn relay on
  Serial.println("Water on!"); 
  delay(300);

  digitalWrite(relayInput, LOW); // turn relay off
  Serial.println("Water off!"); 
  Serial.println("Waiting 10 seconds");
  delay(10000);


} 

Parts:

Pump - https://www.ebay.co.uk/itm/Mini-Water-Pump-DC-3V-4-5V-Fish-Tank-Fountain-Aquarium-Submersible-White-Parts/174211676084?hash=item288fd337b4:g:128AAOSwfQteYWF3

ESP8255 - https://www.amazon.co.uk/gp/product/B07F5FJSYZ/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

Relay - https://www.amazon.co.uk/gp/product/B07BVXT1ZK/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

  • Reading the article below, explains that it could be an issue with pulling too much amps from the PC, however I also just tested the circuit with an external power supply (rated for 4.4a) for the pump, with the ESP8266 USB connected to the PC, but still have the same issue: https://forum.arduino.cc/index.php?topic=496581.0 – Joe Hutchinson Mar 07 '20 at 18:29

2 Answers2

0

Ok, so researching in to this, it seems when the pump is on it pulls more current (amps) than the PC can provide. This will be used connected to a external power source which should supply enough current to it, however I also wanted the flexibility to connect it to a PC with a serial connection to troubleshoot.

So in the end something like this: https://i.stack.imgur.com/MKD1h.png

0

You are driving a 5v relay module with 3.3v output, which works perfectly for some people but it depends on the relay module and the board, this might be the problem. or the relay draws more than 12mA which is the maximum current can the ESP8266's GPIO deliver.

so I suggest you use an external power source for the relay and control it through the pin (D1 in your case).

Or just use a generic 5v relay with an external 5v power source and control it using a transistor, here is a circuit.

enter image description here

Additional information: https://electronics.stackexchange.com/questions/213051/how-do-i-use-a-5v-relay-with-a-3-3v-arduino-pro-mini?

Taha teber
  • 20
  • 7