This is about ESP8266-12F with Arduino IDE.
A simple sketch where I read GPIO16 to set all outputs GPIO0, 2, 12, 13, 47 to either HIGH or LOW.
All outputs work fine except GPIO0.
There is just a 10k pullup connected to GPIO0, but even if I remove that and rely on the internal pullup the output does not go low to a stable low voltage, instead I get oscillations: see picture attached.
I tried this with several ESP8266-12F, all show the same behavior. The load is the same everywhere: a 50R connected to a N-Channel MOSFET that is used to drive the load (LED's).
/* Testing of ESP8266-12F
*
* One digital input commands all digital outputs
* LED state change per button press
*
*/
#include <Wire.h>
const int buttonPin1 = 16;
const int LED1 = 14;
const int LED2 = 12;
const int LED3 = 13;
const int LED4 = 12;
const int LED5 = 02;
const int LED6 = 00;
int ledState = HIGH;
int buttonState1;
int buttonState2;
int lastButtonState1 = LOW;
int lastButtonState2 = LOW;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 50;
unsigned long elapsedTime;
unsigned long startTime;
unsigned long currentTime;
void setup() {
pinMode(buttonPin1, INPUT);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
Serial.begin(115200); // Setup Serial Communication.
digitalWrite(LED1, ledState);
}
void loop() {
currentTime = millis();
// debounce
if (currentTime - lastDebounceTime > debounceDelay) {
lastDebounceTime += debounceDelay;
buttonState1 = digitalRead(buttonPin1);
// then check the change of state
if (buttonState1 != lastButtonState1) {
if (buttonState1 == HIGH) {
ledState = !ledState;
if (ledState == HIGH) {
startTime = currentTime;
}
}
lastButtonState1 = buttonState1;
}
}
digitalWrite(LED1, ledState);
digitalWrite(LED2, ledState);
digitalWrite(LED3, ledState);
digitalWrite(LED4, ledState);
digitalWrite(LED5, ledState);
digitalWrite(LED6, ledState);
}
OK. I was confused by your mention of an internal pull up resistor which is not appropriate for an output pin.
Do you mean a resistor to pull the mosfet gate high ?
Anyway, state what mosfets you are using and show how these are wired.
6v6gt:
OK. I was confused by your mention of an internal pull up resistor which is not appropriate for an output pin.
Do you mean a resistor to pull the mosfet gate high ?
Anyway, state what mosfets you are using and show how these are wired.
No, the 10k pullup is connected between GPIO0 and +5V
1N60 N-channel with 50R to gate, source to ground and drain connected to load low side; load high side connected to 12V
Normally, with an ESP8266 you should not exceed 3.3 volts on a pin. It sounds like GPIO 0 is 10k away from 5 volts.
Your mosfet is not a logic level mosfet and its behaviour is not specified for a gate source voltage of less than 10 volts which may also not help.
You could try increasing the gate resistor on the mosfet, which presents itself as capacitor when switched on, and may just destabilise your circuit in the way you have described.
During the period immediately after the circuit is switched on and most pins will be at high impedance, what state do you want the mosfets to be in ? Turned off ?
It is not the problem here, but you will get nasty surprises if you add leading zeros to integers to neaten up the columns:
const int LED4 = 12;
const int LED5 = 02;
const int LED6 = 00;
6v6gt:
Normally, with an ESP8266 you should not exceed 3.3 volts on a pin. It sounds like GPIO 0 is 10k away from 5 volts.
Your mosfet is not a logic level mosfet and its behaviour is not specified for a gate source voltage of less than 10 volts which may also not help.
You could try increasing the gate resistor on the mosfet, which presents itself as capacitor when switched on, and may just destabilise your circuit in the way you have described.
During the period immediately after the circuit is switched on and most pins will be at high impedance, what state do you want the mosfets to be in ? Turned off ?
It is not the problem here, but you will get nasty surprises if you add leading zeros to integers to neaten up the columns:
const int LED4 = 12;
const int LED5 = 02;
const int LED6 = 00;
Hi 6v6gt, I am so sorry: I made two mistakes:
the MOSFET is a AO3400A which has 1.5V VGSth
the 10k pullup is to 3.3V
My sincere apologies!
Ok, leading zero's will be deleted; I had these added in a desperate attempt to get this to work.
If possible I would like the MOSFET's to be switched off, right now the are conducting after start-up.
OK. To ensure an N channel mosfet is off during the ESP8266 startup phase, it would be ideal to have a gate pull down resistor. Your problem is that GPIO 0 (and indeed GPIO 2) should be held high during the boot phase so there is a conflict.
You could invert the logic of your circuit so that a high on these pins turns the attached led off and a low turns it on.
6v6gt:
OK. To ensure an N channel mosfet is off during the ESP8266 startup phase, it would be ideal to have a gate pull down resistor. Your problem is that GPIO 0 (and indeed GPIO 2) should be held high during the boot phase so there is a conflict.
You could invert the logic of your circuit so that a high on these pins turns the attached led off and a low turns it on.
But that does I think not resolve the issue of the oscillations on GPIO0 when driving the output low.
Several new ESP8266 were tested, both with GPIO0 connected to a load and unloaded: everytime the same issue (oscillations on the output when driven to LOW).
Even GPIO15 does work well, also unloaded (open) this output nicely goes to 0V.
Does anyone have a proven record using GPIO0 as an output and being able to drive it to 0V?