View: 11018|Reply: 5

Detect SW4 (Power Button) +

[Copy link]

3

threads

9

posts

61

credits

Registered member

Rank: 2

credits
61
Published in 2015-12-8 04:41:40 | Show all floors |Read mode
I am looking for a way to detect the power button has been pressed. I am refering to the small button near the barrel power jack. On the OPiPC it is on the end of the board, between the microSD slot and the barrel power kack.


Is there a way to detect the switch state? I would like to detect SW4 has been pressed and script an action.

2

threads

10

posts

182

credits

Registered member

Rank: 2

credits
182
Published in 2015-12-8 17:20:23 | Show all floors
Hi, SW4 is connected to PL3. You can check state of PL3.

1

threads

9

posts

278

credits

Intermediate member

Rank: 3Rank: 3

credits
278
Published in 2015-12-22 09:28:03 | Show all floors
gpio read PL3
[digitalRead2162] the pin:-1 is invaild,please check it over!
0

12

threads

30

posts

150

credits

Registered member

Rank: 2

credits
150
Published in 2016-1-15 19:36:51 | Show all floors
I was able to read out PL3

I explained this in a new thread, because the same technique can be applied to other gpio ports as well.

In order to read the switch, you have to set the control register of port PL3 to input first.
You can read out the data-register for port PL3 afterward.

have a look under the thread -- I included two scripts -- one to set the register -- another to read the register
Pressing the switch key will change the value of the read-register script.

--thread= data / control register (example onboard switch)

0

threads

4

posts

46

credits

Novice

Rank: 1

credits
46
Published in 2016-1-19 05:34:04 | Show all floors
Edited by Dermenslof at 2016-1-19 08:20

work perfect.TIPS:

if you want configure PL3 as INPUT on boot
just modify your script.bin as:
  1. [gpio_para]
  2. gpio_used = 1
  3. gpio_num = 20                                                            
  4. gpio_pin_1 = port:PL10<1><default><default><0>
  5. //...
  6. gpio_pin_20 = port:PL03<0><default><default><1>      
Copy code
and you can check the status of PL03 with:
$> cat /sys/class/gpio_sw/PL3/data



now my question:
i can not find where the switch SW2 is connected. (OPI2)
any help?


1

threads

7

posts

37

credits

Novice

Rank: 1

credits
37
Published in 2026-8-10 21:00:02 | Show all floors
Searching for purebred cats for sale near me can feel exciting yet overwhelming, as local breeders, shelter rescues, and online ads all compete for your attention. Before you commit, always visit the cattery in person to check for clean conditions, health records, and the kitten’s temperament, since reputable breeders prioritize wellness over profit. If you're set on a specific breed like a Siamese or Maine Coon, verify the breeder’s registration and ask about genetic testing—this ensures you're not supporting unethical practices. Ultimately, patience and research will lead you to a healthy, well-socialized companion who fits your home and lifestyle perfectly.

You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list