0

I connect gnd>gnd, 5v>5v and d1>d1 - nothing works with relay blink code

I change connection to d5 on wemos (still d1 on relay) and it works fine with code change to d5

Any ideas, as at present I can't stack the relay on the wemos? (because the d1 goes to d1)

According to pinout, D1 is "I/O, in the default mode, SCL of I2C" and GPIO5.

Thanks

Code:

/*
 * Relay Shield - Blink
 * Turns on the relay for two seconds, then off for two seconds, repeatedly.
 *
 * Relay Shield transistor closes relay when D1 is HIGH
 */

const int relayPin = D1;
const long interval = 2000;  // pause for two seconds

void setup() {
  pinMode(relayPin, OUTPUT);
}

void loop() {
  digitalWrite(relayPin, HIGH); // turn on relay with voltage HIGH
  delay(interval);              // pause
  digitalWrite(relayPin, LOW);  // turn off relay with voltage LOW
  delay(interval);              // pause
}

Also on GitHub.

Wemos D1 mini:

https://www.amazon.co.uk/gp/product/B071S8MWTY/ref=oh_aui_detailpage_o00_s01?ie=UTF8&psc=1

5V relay:

https://www.amazon.co.uk/gp/product/B07DK1FZF9/ref=od_aui_detailpages00?ie=UTF8&psc=1

  • post your code directly in the question. It helps others search for your post on SE – MichaelT Dec 24 '18 at 18:16
  • D1 is io 5. the labels on the board have constants in code but the real io pin numers are different. if you use 5 it is D1. if you use D5 it is io 14. D1 is I2C only if you use the Wire library. the shield uses only one pin. you can't choose which one – Juraj Dec 24 '18 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.