Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By schufti
#23545 there has been a change in PIN_INPUT function recently; it was about automatically activating the internal pullup. Now it should be possible via OUTPUT, INPUT, INPUT_PULLUP, INPUT_PULLDOWN

Don't know the version of esp 8266 IDE you have installed. Depending on that "INPUT" either behaves as tristate or pullup.

in general, I would not wonder about not functioning at all, since you never pul lthe chargePin high ;)

so I would suggest to modify the source a littel e.g.:
Code: Select allconst int chargePin = 14;
const int drainPin = 12;

unsigned long chargeTime = 0;

void setup() {
  pinMode(chargePin, INPUT);
  pinMode(drainPin, INPUT);
  Serial.begin(115200);
  delay(10);

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
 
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

}

void loop() {

  unsigned long cycleStart, cycleStop;

  // drain cap first                best via both pins
  pinMode(drainPin, OUTPUT);
  pinMode(chargePin, OUTPUT);
  digitalWrite(drainPin, LOW);
  digitalWrite(chargePin, LOW);

  Serial.print(micros()); Serial.print(" - ");
  Serial.println("Discharging...");
  delay(9000);

  digitalWrite(chargePin, HIGH);   // prepare charging yet not possible because drainPin still low
  cycleStart = micros();
  pinMode(drainPin, INPUT);        // now start really by tristating drainPin

  Serial.print(cycleStart); Serial.print(" - "); Serial.println("Charging!!!");

  Serial.println(digitalRead(drainPin));
  while (digitalRead(drainPin) == 0) {yield();};
 
  cycleStop = micros();   
  chargeTime = cycleStop - cycleStart;

  Serial.print(cycleStop); Serial.print(" - "); Serial.print("Done...");
  Serial.print(chargeTime);
  Serial.println("ms");
  delay(1000);

}
User avatar
By Daemach
#23569 Yeah I just noticed that I pasted the wrong code in there. I wondered if there wasn't enough current available directly from the charge pin so I used the charge pin to fire a PNP transistor instead as a test. That digitalWrite(chargePin, LOW) would normally be HIGH.

Thanks for the heads-up. I'll try installing the newest version of the arduino code and see if that makes any difference.
User avatar
By schufti
#23624 Hi,
I tried your setup and with a "output" pin that is "high" and able to drive a LED it is not possible to drive an "input" pin via 1M resistor higher than appr. 1V (even w/o cap).
With the input-pin disconnected from the resistor/cap junction I can observe the voltage rise above 3V at the cap.
If I take your setup and do the "charging" via the pullup of the input pin, the intended measurement is possible.

3n3 XXXms
8n2 34ms
33n 335ms
68n 749ms
100n 1095ms

I couldn't figure out what is happening but an "input" pin obviously is not really just "input" (tristate in regard to output)
maybe the author of "core_esp8266_wiring_digital.c" can shed some light on this.