Turn an alternate switch into a momentary switch using a transistor and a Raspberry pi
Overview
Previously, using an RF switch and Raspberry pi, I made a daily necessities management app that "when you press a button, a notification comes to your smartphone".
However, the button that turns this RF switch on / off was an alternate switch (when you press on, it stays on until you press off). In other words, once you press the button, you have to press the off button to use it again, which is a little troublesome specification.
So, using a transistor and a Raspberry pi, I changed this button to a pseudo momentary switch (it returns to off when you press on and release it).
Method
Overview
This RF switch keeps the ON state until the OFF button is pressed, but even in the ON state, it turns OFF when the power is turned off.
Therefore, when the Raspberry pi program detects ON, the power supply to the RF switch is temporarily cut off and then restarted.
ON/OFF circuit of 12V
12V power is supplied to the RF switch, and a NOT circuit using a transistor is used to turn it on and off.
If you input the gpio output (3.3V) of Raspberry pi and output 12V, you can control the power supply to the RF switch with Raspberry pi.
Rasberry pi program
Until now, it monitored the gpio input and sent a notification to the smartphone when the RF switch was connected, but this time the process has been changed as follows.
send a notification to the smartphone
Set gpio output to 1 (= output 3.3V)
Wait 1 second
set gpio output to 0
Also, there is one more thing that makes me happy with this change. Previously, the loop that monitors the gpio input had to be shorter than the time between when the ON button was pressed and when the OFF button was pressed. However, with this change, the Raspberry pi can be turned off at a convenient time, so the loop time can be extended.
Completed
It became as follows.
The blue LED is lit while the RF switch is powered on. The clicking sound about 5 seconds after the start is the sound of pressing the ON button. After that, the LED goes out once (the power of the RF switch is cut off), and it starts up again.
Lastly
I should have bought a momentary switch from the beginning, but there was no suitable one ...
Recent Posts
See AllSummary Data analysis is performed using python. The analysis itself is performed using pandas, and the final results are stored in...
Phenomenon I get a title error when trying to import firestore with raspberry pi. from from firebase_admin import firestore ImportError:...
Overview If you want to do fitting, you can do it with scipy.optimize.leastsq etc. in python. However, when doing fitting, there are many...
댓글