giladger / ElectraWifi

Control Electra AC with esp8266
GNU General Public License v3.0
29 stars 13 forks source link

Can the transistor in the circuit be removed? #14

Open itay7564 opened 1 year ago

itay7564 commented 1 year ago

Hello there, nice project! In the circuit, when the output GPIO goes HIGH, the transistor pulls the IR pin down to GND through a 1K resistror when the output is LOW, the transistor is in high impedance, and likely the IR pin is pushed up to 5V by an internal pullup in the AC

However, the esp can also pull the IR pin to GND directly (through a 1K resistor) and instead of using a transistor, to go high impedence directly from the esp, we can set the output pin to "input".

So the code would change from: Initializer: pinMode(output_pin, INPUT); // GPIO is an output Low output: digitalWrite(output_pin, HIGH); // IR output pulled to 0V by transistor High output: digitalWrite(output_pin, LOW); // IR output pushed to 5V by pullup

To: initializer: digitalWrite(output_pin, LOW); // Always have a LOW output Low output: pinMode(output_pin, OUTPUT); // IR output pulled to 0V by pin sourcing current Hight output: pinMode(output_pin, INPUT); // GPIO goes high-z and IR output pushed to 5V by pullup

The circuit would change to just a 1K resistor between the GPIO to the IR output, instead of the transistor and two resistors.

(Maybe I have missed something about this circuit, tell me if I'm wrong)