Summary
I am having an issue with my board esp8266 reading if a switch is on/off. I am simulating the switch with a wire at the moment.
Context
I can connect to my network, but I cannot read an input pin.
What I have tried
I remove the switch for a button. I tried many different ports numerically and with D1, D2... format. I tried to use a second esp8266. I used the multimeter and I can see the voltage around the resistance. I tried the 3v and 5v for the power source.
mrdesjardins:
5v to switch (white cable in the picture)
switch to 10k resistance
10k resistance to ground
the switch is also connected to the D1 pin
Well, for a start, connecting switches to the power rail ("Vcc") is a generally bad idea, they should connect to ground and you either use INPUT_PULLUP to enable the internal pullup, or provide a pullup to Vcc - or in fact, do both if the internal pullup is insufficient.
But you did worse than that - you have connected an ESP input to 5 V.
We understand the ESP will probably not be damaged by this, pulling an input to 5 V when its supply voltage is only 3.3 V; this has been a point of tremendous discussion over the years since they were first available, but it is strictly not recommended.
The pullup resistor - if you need it - should go to the 3.3 V terminal, not 5 V.
TomGeorge:
Hi,
Does the Serial.print on the IDE monitor show the change in button state?
Do you have a DMM?
Tom..
The ide shows "1" in repeat
I have a multimeter, I see 3.29 volt (when I tried with the source of 3.3v)
Well, for a start, connecting switches to the power rail ("Vcc") is a generally bad idea, they should connect to ground and you either use INPUT_PULLUP to enable the internal pullup, or provide a pullup to Vcc - or in fact, do both if the internal pullup is insufficient.
Okay, so I need to move the resistor between the red wire (VCC) and the white wire (my "fake switch"). I will give a try.
I wasn't aware of INPUT_PULLUP
I will check it out!
you have connected an ESP input to 5 V.
The ESP has a 3.3v and 5v output, why do they put a 5V is that is bad? I will use the 3.3v I used the 5v from an online tutorial which I used only once in the past. Might be a bad example
So let me try tonight with changing the resistance and use 3.3v
If there is anything else, let me know. I'll post back my experiments later.
mrdesjardins:
The ESP has a 3.3v and 5v output, why do they put a 5V is that is bad? I will use the 3.3v
The ESP8266 operates at 3.3 V. The WeMOS D1 Mini (which most of us here feels is the most generally useful version of the ESP8266) is usually powered from 5 V because that is what the default "standard" is, what USB provides (though the actual USB signalling is in fact 3.3. V) and is the readily available voltage from USB "phone chargers".
So it incorporates a regulator to drop the 5 V from the USB jack - or the "5V" pin if you wish to power it that way - to 3.3 V. Both supply voltages are brought out to pins on the D1 Mini board as both are available. But the voltage used by the actual ESP chip is 3.3 V, so you should only apply voltages within this range to the chip (and only up to 1 V on the ADC pin).
mrdesjardins:
I used the 5v from an online tutorial which I used only once in the past. Might be a bad example