Controlling remote with pnp for openhab
I have a ventilation system in the house, which came with a RF remote:
I wanted to be able to control my ventilation system from anywhere in the house, and had some pnp transistors which I thought would be nice to use as a switch and replace the buttons.
First starrt off with a detailed sketch of your work 😉
– connected to collector
+ connected to emitter
Base connected with 10k resistor to a gpio pin.
When the pin is high, the pnp transistor will be closed, when it is low the pnp transistor will pass current from the emitter to the collector.
I opened up the remote and desoldered the coincell holder & the first button and replaced them with wires to create a test setup:
Red & Orange are the power + & – sorry, no black wire left for gnd 🙁
The blue a d yellow wire replace the buttons – & +
To simulate a buttonpress I just pull the gpio pin low for 500ms and return it back high:
Test code, to see if my buttons work:
void setup() { //Setup my 3 pins for the buttons Serial.begin(115200); digitalWrite(16,HIGH); pinMode(16, OUTPUT); digitalWrite(18,HIGH); pinMode(18, OUTPUT); digitalWrite(19,HIGH); pinMode(19, OUTPUT); } void loop() { //This code is used to debug, you can toggle your switch through serial ( if (Serial.read() == "1") { Serial.println("set to 1"); digitalWrite(16,LOW); delay(1000); digitalWrite(16,HIGH); } if(Serial.read() == "2"){ Serial.println("set to 2"); digitalWrite(18,LOW); delay(1000); digitalWrite(18,HIGH); } if(Serial.read() == "3"){ Serial.println("set to 3"); digitalWrite(19,LOW); delay(1000); digitalWrite(19,HIGH); } }
Testing it with my whisper node, and it worked!
I decided to put the pnps on a seperate pcb and connecting it to the remote and my raspberry pi.
More on using gpios and setting it up with openHAB in my next post.
After this I decided I will also make an esp8266 & AM2302 (wired DHT22) sensor, which will send humidity data to openHAB via MQTT. This way openHAB will be able to switch my ventilation system automatically when the shower is running, and the humidity is rising. 🙂