All outputs work fine except GPIO0.
There is just a 10k pullup connected to it, 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 SEP8266-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).
[code]
/* Testing of ESP8266
*
* One digital input commands all digital outputs
* LED state change per button press
*
*/
#define DS3231_I2C_ADDRESS 0x68
#include <Wire.h>
const int buttonPin1 = 16;
// const int buttonPin2 = 13;
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;
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
return ( (val / 10 * 16) + (val % 10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
return ( (val / 16 * 10) + (val % 16) );
}
void setup() {
pinMode(buttonPin1, INPUT);
// pinMode(buttonPin2, 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);
}
/**************************
R E A D T I M E
**************************/
void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
Wire.beginTransmission(DS3231_I2C_ADDRESS);
Wire.write(0); // set DS3231 register pointer to 00h
Wire.endTransmission();
Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
// request seven bytes of data from DS3231 starting from register 00h
*second = bcdToDec(Wire.read() & 0x7f);
*minute = bcdToDec(Wire.read());
*hour = bcdToDec(Wire.read() & 0x3f);
*dayOfWeek = bcdToDec(Wire.read());
*dayOfMonth = bcdToDec(Wire.read());
*month = bcdToDec(Wire.read());
*year = bcdToDec(Wire.read());
}
void actionTime() {
// do something once, using Ds3231: read time and
// act only if certain time criteria are met
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
// retrieve data from DS3231
readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
static byte lastSecond = 0;
if ( second == lastSecond ) {
return;
}
lastSecond = second; // remember what minute was last time we looked
// minute has changed... what is it now?
if (second == 01)
{
// do something once
}
}
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);
/*
// manage LED2
if (currentTime - startTime > 3000 && ledState == HIGH) {
digitalWrite(LED2, HIGH);
}
else {
digitalWrite(LED2, LOW);
}
*/
actionTime(); // do something, time based
}
[code]