I'm pulling my hair out!! I have one D1 mini purchased a while ago and can control it just fine. It is packaged and I'm using it to automate my heater. But I baught another couple recently from a different seller and just can't get them both to work. I can control the LED_BUILTIN, but the rest of the pins do nothing. Is there any reason why these particular ESP8266 D1 Minis might not work the same way? Have I done something stupid in my code?
Here I'm trying to light an LED from Pin D1, but I get no voltage. I've tried every other pin and they're all the same.
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
pinMode(D1, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(D1, HIGH);
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
digitalWrite(D1, LOW);
delay(1000); // wait for a second
}
DrAzzy:
Are you sure you are using the right pin numbers? There are several pin mappings used for ESP8266 boards...
This is the cause of constant confusion to me! I wouldn't have a clue, but I tried a blink app that blinks pins referenced by D1, D2, D3..D7 also 1, 2, 3...13.
As far as I remember, if you do select the WeMos D1 Mini as board, the numbers do match. So digitalWrite(4, HIGH) should set D4 HIGH (if it's an output!)
Does the code you try to upload actually get uploaded?
Also, the ESP8266 does has some sidenotes about which pins you can (or should) use. I don't have a good link ready but you can find loads with Google. Although do note, a lot of pages talk about the ESP pin numbers (GPIOx), not the WeMos pin numbers. Pinout shows how they match:
OK so I didn't change anything significant but restarted my machine at some point and eventually it works now!! hmm..
What I do see is that I'm referring to pin D3 in order to control D1 as marked on the ESP. I have to use that pin as it aligns to the relay shield I'll be controlling.
CheeseNWine:
but restarted my machine at some point and eventually it works now!! hmm..
If restarting your machine helped it sounds like the upload (or compile even) to the ESP was failing for some reason.
CheeseNWine:
What I do see is that I'm referring to pin D3 in order to control D1 as marked on the ESP. I have to use that pin as it aligns to the relay shield I'll be controlling.