Please select To the mobile version | Continue to access the desktop computer version

OrangePi

 Login            
 Register            
Search
Hot search: orangepi
123
Return to list New
Author: Boten

GPIO ADDON & OPENELEC

[Copy link]

4

Threads

1128

Posts

8248

Credits

Moderator

Rank: 7Rank: 7Rank: 7

Credits
8248
Post time 2016-12-12 00:40:32 | Show all posts
campioncino replied at 2016-12-11 12:09
I have some problem when i try to switch off the fan controlled by a pin.

I don't know why it remai ...

Thanks for reminding me to remove gpio_sunxi module. It is not better than standard sysfs gpio interface and Allwinner already stopped using it.

About your problem: oppai is right, shutdown in GUI actually does suspend. It was discussed before and I won't change it to shutdown. Your problem can be easily solved by using systemd service file. For example, LED systemd service file solves almost same problem, so you can reuse it:
https://github.com/jernejsk/Open ... nxi-suspend.service

ExecStart is executed when system goes to suspend and ExecStop is executed when system is resumed.

According to this page:
http://wiki.openelec.tv/index.php/Mounting_network_shares

you should place service file in /storage/.config/system.d/ and then execute command "systemctl enable <yourservice>.service"

Be aware that I didn't try this, so there might be some additional steps.

10

Threads

55

Posts

345

Credits

Intermediate member

Rank: 3Rank: 3

Credits
345
Post time 2016-12-12 02:27:58 | Show all posts
Thanks a lot jernej.
I'll try.

10

Threads

55

Posts

345

Credits

Intermediate member

Rank: 3Rank: 3

Credits
345
Post time 2016-12-17 19:47:21 | Show all posts
Edited by campioncino at 2016-12-17 20:16

According with the LED example I create my own service
  1. [Unit]
  2. Description=fan suspend service
  3. Before=sleep.target
  4. StopWhenUnneeded=yes

  5. [Service]
  6. Type=oneshot
  7. RemainAfterExit=yes
  8. ExecStart=-/bin/sh -c "echo 110 > /sys/class/gpio/export; echo "out" > /sys/class/gpio/gpio110/direction; echo 1 > /sys/class/gpio/gpio110/value"
  9. ExecStop=-/bin/sh -c "echo 0 > /sys/class/gpio/gpio110/value"

  10. [Install]
  11. WantedBy=sleep.target
Copy the Code


Placed the service file in /storage/.config/system.d/ and then execute command "systemctl enable fan-suspend.service" And get :
Created symlink from /storage/.config/system.d/sleep.target.wants/fan-suspend.service to /storage/.config/system.d/fan-suspend.service.

But nothing happend, the fan still remain active.


I add also a fan-start service
  1. [Unit]
  2. Description=fan loader
  3. After=network.target

  4. [Service]
  5. Type=simple
  6. RemainAfterExit=no
  7. ExecStart=-/bin/sh -c "echo 110 > /sys/class/gpio/export; echo "out" > /sys/class/gpio/gpio110/direction; echo 1 > /sys/class/gpio/gpio110/value"
  8. ExecStop=-/bin/sh -c "echo 0 > /sys/class/gpio/gpio110/value"
  9. [Install]
  10. WantedBy=network.target
Copy the Code
In this way I can start the fan...but I cannot switch off.

4

Threads

1128

Posts

8248

Credits

Moderator

Rank: 7Rank: 7Rank: 7

Credits
8248
Post time 2016-12-18 00:17:10 | Show all posts
Try invert ExecStart and ExecStop. IIRC, start means action at suspend and stop means action at resume. AFAIK, export and direction settings need to be done only once, at first use.

10

Threads

55

Posts

345

Credits

Intermediate member

Rank: 3Rank: 3

Credits
345
Post time 2016-12-21 02:44:44 | Show all posts
Edited by campioncino at 2017-6-11 18:35

I feel stupid.


It's correct, now it works.That's the complete working solution
Fan-start.service
  1. #bin/sh
  2. [Unit]
  3. Description=fan loader
  4. After=network.target

  5. [Service]
  6. Type=simple
  7. RemainAfterExit=no
  8. ExecStop=-/bin/sh -c "echo 110 > /sys/class/gpio/export; echo out > /sys/class/gpio/gpio110/direction; echo 1 > /sys/cla$
  9. ExecStart=-/bin/sh -c "echo 0 > /sys/class/gpio/gpio110/value"

  10. [Install]
  11. WantedBy=network.target
Copy the Code


Fan-suspend.service
  1. #bin/sh
  2. [Unit]
  3. Description=fan suspend service
  4. Before=sleep.target
  5. StopWhenUnneeded=yes

  6. [Service]
  7. Type=oneshot
  8. RemainAfterExit=yes
  9. ExecStop=-/bin/sh -c "echo 110 > /sys/class/gpio/export; echo "out" > /sys/class/gpio/gpio110/direction; echo 1 > /sys/c$
  10. ExecStart=-/bin/sh -c "echo 0 > /sys/class/gpio/gpio110/value"

  11. [Install]
  12. WantedBy=sleep.target
Copy the Code

So, I ask another "stupid" question. There is a way to wake it up after suspend? Using remote controller o CEC or ...

4

Threads

1128

Posts

8248

Credits

Moderator

Rank: 7Rank: 7Rank: 7

Credits
8248
Post time 2016-12-21 05:32:50 | Show all posts

There is FAQ for "stupid" questions, even for this. It is under IR remote.

0

Threads

1

Posts

14

Credits

Novice

Rank: 1

Credits
14
Post time 2017-7-31 14:40:54 | Show all posts
jernej replied at 2016-12-21 05:32
There is FAQ for "stupid" questions, even for this. It is under IR remote.

Good afternoon. How to program the automatic switching on or off the fan on the GPIO PIN when reaching a certain temperature to cool the Orange PI?
You have to log in before you can reply Login | Register

Points Rules

Archiver|Mobile edition|Darkroom|OrangePi En ( 粤ICP备14086627号-2

2021-11-27 07:49 GMT+8 , Processed in 0.035035 second(s), 20 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list