Turn an alternate switch into a momentary switch using a transistor and a Raspberry pi
top of page

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).



The RF switch I am using has both ON and OFF buttons

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.

  1. send a notification to the smartphone

  2. Set gpio output to 1 (= output 3.3V)

  3. Wait 1 second

  4. 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 All

[Python] Output pandas.DataFrame as json

Summary Data analysis is performed using python. The analysis itself is performed using pandas, and the final results are stored in pandas.DataFrame format. I want to output this result to a file in j

[Python] Conditionally fitting

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 cases where you want to condition the fitting parameters. For

Let's do our best with our partner:​ ChatReminder

iphone6.5p2.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Let's do our best with our partner:​ ChatReminder

納品:iPhone6.5①.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Theme diary: Decide the theme and record for each genre

It is a diary application that allows you to post and record with themes and sub-themes for each genre.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png
bottom of page