ES32s - only 0.8v on a pin


I’m using an ESP32s module (not a dev board). voltage is supplied cleanly via an AMS1117 LDO. Measured at 3.279v.

when I write a pin to HIGH, i’m only measuring 0.8v at the pin. I’ve tested this both on pins that are connected to something (the base of a BC459) and on an unconnected pin. The behaviour is the same.

after writing the pin to HIGH, a subsequent read records the pin is low.

can anyone think of any reason why this would be, or have I got (another) bust module?

the code, fwiw, is as you would expect

#include <WiFi.h>
#include <ArduinoOTA.h>

const byte livePin = 4; //IO4
const byte neutralPin = 21; //IO21
void setup() {
  pinMode(neutralPin, OUTPUT);
  pinMode(livePin, OUTPUT);
  pinMode(16, OUTPUT);
  turnOff(); // just in case.

void loop() {

  int state = digitalRead(neutralPin);
  if(state == LOW){
    Serial.println("Turning pins on");
    digitalWrite(neutralPin, HIGH);
    digitalWrite(livePin, HIGH);
  } else {
    Serial.println("Turning pins off");
       digitalWrite(neutralPin, LOW);
    digitalWrite(livePin, LOW);


  Serial.println("Port State:");
  Serial.print("Live Pin: ");
  Serial.print("Neutral Pin: ");


the output is as described

Port State:
Live Pin: 0
Neutral Pin: 0
Turning pins on
Port State:
Live Pin: 0
Neutral Pin: 0

thanks in advance

I've tested this both on pins that are connected to something (the base of a BC459) and on an unconnected pin.

I only know the BC549 (obsolete NPN transistor).
How did you connect that transistor to the pin.
Did you use a base current limiting resistor.
What is the transistor driving (inductive load?).
Post a diagram.

yes BC549. apologies. mistype. The design was for BC548 but I don’t have any of those in the lab at the moment.

a cleaned up schematic is attached to the post. the connections are direct. No current limiting resistor. There is scope for a resistor between the base and ground but this is not implemented.

not sure how relevant it is anyway, as there are unconnected pins that are also showing only 0.8v when switched to high.

I think that this may be a limitation of the ESP32s (or perhaps Arduino-ESP32s port). it may be that trying to read the state of the port inherently sets the register to an input, and brings it low.

that would explain the always LOW serial output, but not the 0.8v on the pin.

BC549 is the same as a BC547/548, just selected for low noise.

You are basically shorting the ESP pin to ground through the BE junction of the BC549.
A current limiting resistor must be used between pin and base. 330ohm would do (for 3.3volt logic).

It seems you are driving a relay coil (not a relay module) with this transistor.
Then you also need a (1N4148) diode across the relay coil, to kill the high voltage spike when the relay turns off.

If you try and source too much current from a pin, the voltage will drop and the pin may burn up.

At least put enough resistor to limit the pin current to <= half the pin maximum.

Also, the ESP pin you have used may be damaged already.

you're all quite right. Thank you. Indeed, removing the two transistors returns the ESP32s to a HIGH level of 3.24v. Which is as expected.

But the behaviour returns when I put in a 2.2k series resistor (in fact slightly worse as the resultant voltage at the pin drops to 0.67v).

Just for clarity, at the moment, there is nothing connected to the collector (the relays are not on the board).

measuring the total current consumption of the board, I see a variation between 99mA and 110mA. The on/off duty cycle of the pins is currently set to 5secs; although the current oscillation is closer to 500mS.

i'm a little stumped. It doesn't seem to exhibit the behaviour I'd expect of a burned out pin, but perhaps so. If noone has any better ideas I will transplant a new esp32s module.

@Wawa - thank you for reminding me about the flyback diode. Not necessary yet but it will be there. I don't think I've got any signal diodes in the lab but plenty of 1N4001s.

1N400x is fine.